Programming

Why do companies reinvent the wheel and make their own in-house libraries?

Learn Programming - Thu, 11/15/2018 - 15:20

I had a chat with an experienced programmer and he told me most companies maintain their own libraries. He said most programmers in a company are library users, and only a small team makes and maintains the libraries. But isn't creating and maintaining a library a daunting task? He also told me the library of his company was a bunch of special case programming and macros. Why? Also, why even reinvent the wheel? For example, a science company can fork NumPy instead of creating its own library... I don't understand. Why is that? Thanks a lot for your answers.

submitted by /u/Lithy_Eum
[link] [comments]

[Python 3.7] When using classes, how do I assign different __str__(self) functions to print different data?

Learn Programming - Thu, 11/15/2018 - 15:07
# Error msg = 'Enemy' object has no attribute 'Name' <-- I understand what this means, but can't figure out how to have 2 different __str__ commands for data in the same class # desired output is to print... # Slime # Slime has 5 hp & 3 mp class Enemy: def __init__(self, name, hp, mp): self.name = name self.hp = hp self.mp = mp class Name(Enemy): def __init__(self, name): Enemy.__init__(self, name) def __str__(self): return("%s") % (self.name) class Stats(Enemy): def __init__(self, name): Enemy.__init__(self, name) def __str__(self): return("%s has %d hp & %d mp") % (self.name, self slime = Enemy("Slime", 5, 3) print(slime.Name) print(slime.Stats) # many thanks if you know what I should be doing instead!

edit: used code block

submitted by /u/nightman365
[link] [comments]

C++ cin >> name and cin >>age

Learn Programming - Thu, 11/15/2018 - 15:02

Ok so i don't know what stupid mistake im doing here and hope someone can help me. When i try to make program ask name and age it first ask name and allows me to write my name but when it prints age it wont let me write anything anymore.

the line goes like this:

#include <iostream>

using namespace std;

int main() {

bool name; int age;

cout << "name: " << endl; cin >> name;

cout << "age: \\n"; cin >> age; while (age < 0);

{ cout << "Not real age" << endl; cin >> age; }

{ if (age < 10); } cout << "Hello" << endl; { if (age > 10); } cout << "You are young" << endl;

return 0; submitted by /u/ThatQuietFriend
[link] [comments]

Atbash encrytion: Iterating through property values of an object that stores string characters using 'for in'

Learn Programming - Thu, 11/15/2018 - 14:46

What is Atbash?

The Atbash cipher is a particular type of monoalphabetic cipher formed by taking the alphabet (or abjad, syllabary, etc.) and mapping it to its reverse, so that the first letter becomes the last letter, the second letter becomes the second to last letter, and so on. For example, the Latin alphabet would work like this:

Source: https://en.wikipedia.org/wiki/Atbash

Link to code:

https://codepen.io/dragonzenie/pen/JePEgY

What is your code sample you provided supposed to do?

DOM manipulation, extract input value from HTML, iterate the input value through the 'for-in'. The for-in has conditional statements that would grab the property value from the atBashCipher object. This will encrypt the input value using the atbash cipher.

What exactly is the problem you're seeing?

I have not written code that will output the input value back to HTML, but when I am using the dev tools and see if the input values are being encrypted and then stored into the var 'ciper' based on the conditional statements, I am getting 'undefined'.

What is the expected output or behavior of your program?

"HOW ARE YOU', should return "SLD ZIV BLF", when the variable 'cipher' is returned.

What output or behavior do you get instead?

The variable 'cipher' is returning 'undefined'

If your code doesn't compile or crash, is there an error message of any kind? If so, what is it? If not, what happened?

No error messages.

What have you already tried to debug your own problem? Where do you suspect the problem is? What uncertainties do you have?

https://zellwk.com/blog/looping-through-js-objects/

What precisely are you confused by?

My code is grabbing the input values from HTML, it recognizes it is a string, but the conditional statements aren't storing anything in the variable 'cipher' after running through the conditional statements.

Feel free to add comments about my syntax, I am beginning open to constructive criticism. Thank you in advance!!

submitted by /u/the_e_user
[link] [comments]

ARM Assembly - stack structure

Learn Programming - Thu, 11/15/2018 - 14:37
push {r1,r7} push {r5} pop {r2} push {r1-r4} pop {r2} BL func1 b func2 func1: pop {r6-r7} push {r2,r9,r10} BX LR func2: POP {r2} push {r0-r1,LR} bl func1 BL func1

So I have to go through this program and say how the stack looks like after it finished. My result was, from top to down: r2,r9,r10,r10,LR,r9,r10,r4,r1,r7

can someone check if I am correct?

submitted by /u/kriptoo123
[link] [comments]

Creating a site like Zillow, Redfin etc

Learn Programming - Thu, 11/15/2018 - 14:26

I'd like to build a website that aggregates real estate data and improves upon the user experience on that I am finding on Zillow and Redfin. What type of programming languages would i need to start learning to do this on the web and ios? Thank you!

submitted by /u/YouGotJammed
[link] [comments]

What's your React/Django project structure look like?

Learn Programming - Thu, 11/15/2018 - 14:26

Learning to combine react frontend with django backend. Project is a little social gathering site for drunkards. So far it looks like:

├── requirements ├── api_app │ ├── migrations ├── project │ ├── settings ├── node_modules │ └── @fortawesome └── frontend ├── node_modules ├── public │ └── img ├── src └── build ├── img ├── static submitted by /u/TacosBuenos
[link] [comments]

Falling in a bottomless pit of despair trying to find an interesting project idea

Learn Programming - Thu, 11/15/2018 - 14:13

Hey everyone,

I’ve been trying to find an interesting project idea for a while, but it seems impossible. I’ve read project ideas lists, watched videos and streams, but I haven’t find an idea that makes me say “Oh, I would really want to make this!” yet.

I don’t have a favourite field of programming. Every field of software development seems very interesting and enjoyable.

I love programming, I do it pretty much everyday. Though, I’m fed up with Project Euler / HackerRank / algorithmic / competitive programming problems.

I read the FAQ and other posts. I have the right mindset, I’m motivated, enthusiastic, determined and disciplined, but this situation keeps me from getting to “work”.

I need some piece of advice. I know there’s a way to get out of this situation. Thank you in advance for your advice!

submitted by /u/kroolayer
[link] [comments]

*rant* Attending DrupalCon is becoming too expensive

Drupal - Open Source Content Platform - Thu, 11/15/2018 - 13:58

I like the concept of tracks and I'm sure it will be successful.

However, the price of attending DrupalCon is another example that Drupal is an Enterprise framework.

$900 + staying in an expensive city like Seattle is not cheap.

submitted by /u/Tabestan
[link] [comments]

How do I develop a graphical programming tool like scratch or blocky

Learn Programming - Thu, 11/15/2018 - 13:51

As a university project I wanted to create a graphical programming tool easier IoT application development but could not find any resource. Any help!?

submitted by /u/MukundhBhushan
[link] [comments]

Programming Books

Learn Programming - Thu, 11/15/2018 - 13:50

I’m an intermediate programmer. I know Python, and. almost know java. I also know HTML and CSS. I’m wanting to expand my knowledge of data structures and databases, simple machine learning development, and more about algorithms. I’m 15 so I’m going to have a lot of time over winter break to study, so I’d love some good books or alternative resources to learn from! I’m also really into math (Almost done with calc 2) so I’d also enjoy a very mathematical-programming book. Thank you so much for your help

submitted by /u/AviouslyAK
[link] [comments]

Is TreeHouse a good place to learn.

Learn Programming - Thu, 11/15/2018 - 13:43

Has anyone ever used TreeHouse and been successful through it, or is it just a cash grab for new programmers trying to learn.

submitted by /u/IwntTubBurd
[link] [comments]

Help me with my shambling project ?

Learn Programming - Thu, 11/15/2018 - 13:42

So, I've got to make a to-do list purely made from html,css and javascript,problem is, I've barely been taught any javascript at my school and even then,I haven't touched front-end in over a year So I'm quite stumbed here ..

The idea is that there should be an input field where I can add list items to my to-do list and once they're completed,I click on them and they get transfered to a "completed " section while also counting the percentage of how many list items are completed and not completed.

I don't expect anyone to take the time to write out the code(though I would,obviously,appreciate it ),but atleast if I got some direction as to what parts of javascript I should look into,it'd be a great help as is..

<html> <head> <title>Site</title>

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true">
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="style.css">

<link rel="stylesheet" href="style.css"> </head>

<body>
<div class="container">
<form>
<div id="myDIV" class="header">
<h2>To-Do</h2>
<input type="text" id='uzd' placeholder="Užduotis">
<input type="button" id='todoadd' >
</div>
</form>
<ul id='uzduotys'>

</ul> <script src="script.js"></script> </div> </body>

</html>

//////javascript

document.getElementById("todoadd").onclick = function() {

var node = document.createElement("Li"); node.setAttribute("id","li"); var text = document.getElementById("uzd").value; var textnode =document.createTextNode(text); node.appendChild(textnode); document.getElementById("uzduotys").appendChild(node); }

/////////css

body{ background-color: lightgrey; } .container{ margin: 100px 300px; } h2{ margin-left: 75px; font-size: 36px; color:cornflowerblue; } input{ line-height: 30px; font-size: 20px; border-radius: 7px; margin-left: 30px; } ul { list-style-type: none; margin: 0; padding: 0; } ul li { cursor: pointer; position: relative; padding: 12px 8px 12px 40px; background: #eee; font-size: 25px; transition: 0.2s; /* make the list items unselectable */ -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } ul{ margin:20px; border-radius:15px ; } li{ background-color: white; line-height: 30px; border-radius:7px; margin:10px; } ul li.checked { background: #888; color: #fff; text-decoration: line-through; }

submitted by /u/Kam1Collo
[link] [comments]

How do I apply this formula for working out the abstractness of a component?

Learn Programming - Thu, 11/15/2018 - 13:40

I've just finished watching this talk on the principles of component design. In it he defines a formula for measuring the instability of a component (51:18) and one for the the abstractness of a component (54:30). Both of these metrics are continuous from 0 to 1, much like probability.

I understand abstraction to be defining the essence of something without going into specifics, which simplifies it. Hence abstract art being quite out there and far removed from realism, while still managing to represent its subject for example. In the case of a successful component, it would be as general as possible and take the broadest range of inputs possible and still be able to perform its task on them.

The formula for abstractness is given as A = # of abstract classes / # of classes. Presumably this requires you to already know whether the classes in the component are abstract, so they must have the formula used on them first?

I don't have a computer science background and I'm trying to understand this within the context of Javascript, specifically React.js. Within this context, what would a class (abstract or not) be? Methods attached to the component? Nested components? Both or something else?

Whether the class is abstract in this formula seems to be binary, so how would I decide whether it is or not?

Ideally, I'm looking for someone to give me a simple example to get my head around it, but I would appreciate any input!

submitted by /u/Zz1995aJ
[link] [comments]

How do I hook into a particular program to determine when events happen? (PokeMMO)

Learn Programming - Thu, 11/15/2018 - 13:39

My son is 5 years old and learning to read. He likes to play PokeMMO, so I wanted to do two things:

  1. When dialogue pops up, highlight words individually.
  2. Use some sort of text-to-speech to read the words, moving the highlight along as the words are read.

The scripts for all of the interactions are available online, so I can do the second part fairly quickly, I think.

However, I'm not sure how to figure out when a particular event is happening to correlate it to the text in the script. Is there any way to hook into the program to see what event occurs when you walk up to a NPC and talk to them?

The majority of programming I do is for scientific research (data processing, image processing, etc.), so I'm a bit out of my element, but I would absolutely love to learn.

Thanks!

submitted by /u/ChemistBuzzLightyear
[link] [comments]

Pages