/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

lmgtfy.com/?q=is there a reddit api
grisha.org/blog/2013/04/02/linus-on-understanding-pointers/
reference.wolfram.com/language/ref/WordCloud.html
wolfram.com/programming-lab/?source=nav
reference.wolfram.com/language/ref/Compile.html
static.mrfeinberg.com/bv_ch03.pdf
github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js
asciinema.org/a/7jlodigt8vkldvjjzq40393z3
hastebin.com/rodosiheyi.rb
twitter.com/NSFWRedditImage

And the parallel functional programming thread:

Finally a separate thread for those retards.

Programming related anime?
new game doesn't count, you could change the setting to a high school and it wouldn't change a damn thing

To the dude making the decentralized TV:

can you explain the point of your project. It seems interesting, but why would I, a humble normie, want to use decentralized and encrypted television?

Any other takers? Posting mine.

f[] := Partition[RandomSample[{0, 1, 1, 1, 1, 1, 1, 1, 1}], 3]
g[x_] := If[x == 1, f[], Table[0, 3, 3]]
s[n_] := NestList[ArrayFlatten@Map[g, #, {-1}] &, f[], n - 1]

Export["~/Pictures/s.gif", ArrayPlot /@ s[8], "DisplayDurations" -> .75]


:^)

How would you make a program to pick a random subreddit from a list, go into that subreddit and just make a thread saying "NIGGERNIGGER FAGGOTNIGGER ANLA YOUR UGLY GOOSEMOM"?

Python? js? is there a reddit api?

t. noob

Neato. Mathematica?

haskell btfo'd

>is there a reddit api?
lmgtfy.com/?q=is there a reddit api

python + reddit API

you'll probably get banned in days

Yep. The real lifesaver is the Map[ ... {-1}] bit.

Since the infrastructure for BasicTV is free, you don't have to pay anything to use it.

The entire network functions as a decentralized DVR as well (quality may vary), so you can infinitely rewind or fast forward (up until it is live).

You also can watch television in 4K and 8K, 3D (red and blue, Oculus Rift (possible, but APIs are beyond me), and others), multi channel sound, multiple different languages (dubbed and subbed), multiple physical screens, multiple windows (tiles like tmux).

You can donate Bitcoin to the nodes who run the network, along with the content provider (if you feel inclined to).

It can also be set up as a cheap Chromecast audio system (although I haven't tried that, nor is it ready). It would be pretty technical, but it isn't beyond Sup Forums to use

It can also do some geekier things which I think is cool (extensible macros with IR remotes, exporting MP4, FLAC, and others to SSH, FTP, DVDs, BD-Rs, and others), but those won't be things that most people use.

The best part of all is that it should all run on a Raspberry Pi (working on a Kodi frontend so not everybody needs a dedicated unit for this).

It is also possible to double-encrypt the stream information, so it goes out to the network before it is "live". Once this happens, and everybody who is interested in watching it has downloaded it, then upload the corresponding public key so it can be decoded in 1-minute chunks (customizable) in "real time", so you can get 1080p over dial-up if you put it far enough in advance

It can also do some really cool technical stuff (open up 20+ Tor circuits so more content can be downloaded and forwarded anonymously), but that falls outside of what a "humble normie" would want

What can I do about mediocre developers on my team who are willing to learn? Every result online is philosophical drivel. I need practices, strategies, and material. Firing is not an option for a few months

>mediocre developers
what did you mean by this?

what's a mediocre dev?

It can also do a TV Guide and different refresh rates

Come up with a solid architecture for your application and divide up the work.
Fire people who are ineffective.
That's the only way to get anything done.

Give them concrete tasks with explicit requirements for quality.

Hmm, make it create new random account on some email service? Would it work to do it via TOR to counteract site-wide IP-ban?

don't know but what's the fucking point?

annoy redditors?

waste of time desu

A mediocre dev is a dev that makes things more complicated, not more simple. You can throw every anti pattern in the world at them through code review and their fundamental architecture still won't reflect the real world. Their code works, but try to add something and it needs to be refactored. Refactor it, and it breaks. The mediocre dev is one that writes code and it works, but it doesn't work well. The mediocre dev still works hard but is just missing some piece.

doesn't your company have code guidelines?

We're not old enough for mature code guidelines. I add bad design patterns to it as often as they come up, but that's just treating the symptom. Inevitably more bad patterns just pop up when they encounter something new. I can guide them on new tasks, I can even create an entire skeleton for them, and they will only lack understanding, resulting in them not taking advantage of built in extensibility but instead stapling their own bad designs on top.

(your own | your company | your startup) fault, in hiring them in first place

I know that. And if were up to me, they would be gone tomorrow. There must be something I can do to improve the situation.

...

This might be drastic but have you considered having a whitelist of good practices rather than a blacklist of bad ones?

That's a good start. I still feel bad not instilling fundamentally good skills in devs themselves though.
We are introducing mandatory test coverage soon. At least that will help refactoring.

I'm also going to be helping to write a technical blog that will introduce more abstract fundamental ideas than I can inside work.

where are you from?

USA?

Canadia.

and then people wonder why they import indians to write code

The imported Indians are the worst programmers I've ever seen. They payed for their degrees and they literally never even owned a computer. No one wants them. We're all about those Asians. I'm lucky to work for a nationalist company though. It's good for the economy to not export our money.

>tfw solved a project euler problem with the solution I got after solving half the problem and don't want to go back and do the rest, especially if I can't confirm that it's working

Is there a good way to ingrain the finer intricacies of C-Pointers in practice?

For example a extensive set of exercises.

>grisha.org/blog/2013/04/02/linus-on-understanding-pointers/
I wonder if something like this would come to me naturally.

On the other hand: My lacking experience with this topic might simply be due to my limited experience with C in my coursework.

I guess reimplementing common data structures in C (incl. Free-handling or reeuse of Objects from a fixed pool) would help.

(
I'd also like to get deeper into locking and locality while I am at it.

A different sticking point would be "good enough" solutions or limited applicability to real world projects / very big input datasets.
)

It might also be good in the long run too avoid poorly written shit.

IoT Botnets are a very fun kind of accumulated garbage.

That stuff should require more robustness before you release it into the wild.

button2 = (Button) findViewById(R.id.add_button);
button2.setOnClickListener(new View.OnClickListener() {
public void onClick (View v) {
if ((newGrade.matches("Grade")) || (newCredits.matches("Credits"))) {
Toast.makeText(getBaseContext(), "Missing input", Toast.LENGTH_SHORT).show();
} else {
gradesArray[i] = newGrade;

switch (newGrade) {
case "A":
newGradeInt = 4;
break;
case "B":
newGradeInt = 3;
break;
case "C":
newGradeInt = 2;
break;
case "D":
newGradeInt = 1;
break;
default:
break;
}

gradesIntArray[i] = newGradeInt;
newCreditsInt = Integer.parseInt(newCredits);
creditsIntArray[i] = newCreditsInt;

//shit breaks right here, mang.
gradeList = (ListView) findViewById(R.id.muhlist);
listAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, gradesArray);
gradeList.setAdapter(listAdapter);

i++;
}
}
});


trying to pass string array content to a listview. my shit breaks on the 3rd to last line on the "else" section. What gives. complete noob btw.

>What are you working on
Wolfram Research's new advertising campaign.

post the fucking error

Does Java allow using strings for switch statements? That might be it.

well if i comment the 'listAdapter = new ArrayAda..." then it works. when I add that on there is crashes the app. currently the whole (this. etc...) part is underlined and red and I don't know how to read into it. I was basically just copying a tutorial on youtube and don't know why it doesn't work for me.

Looking for some clever, visual way to represent certain words from a page in terms of their frequency. Now the challenge is to make them not overlap. Pic related, a scan of the Windows 10 discussion thread.

>windows just never works faggot
lmao

...

3/6 master race

I was in that Sup Forums thread too aha :)

my nigro

I used to have a gif where they stitched all the pictures together, it was mesmerising.

reference.wolfram.com/language/ref/WordCloud.html

Since the functional thread is pretty much dead. Is there any way to get a slime like repl with scala in emacs?

Neat. Thing is, I only have a coordinate for the bottom left corner of the word.

No I mean just do this.

what language is this?


dafuq

Mathematica/Wolfram Lang.

neat

Where's the fun in that?

You can try it out and look at little sample programs here if you're interested
wolfram.com/programming-lab/?source=nav

You get to do other fun stuff.

>You can try it out and look at little sample programs here if you're interested
>wolfram.com/programming-lab/?source=nav

can you install it on your computer like python or C++?

Should I use the below to get variables/objects from other classes?

private OrthographicCamera gameCam;

public CheckGameOver(OrthographicCamera gameCam) {
this.gameCam = gameCam;
}


Or should I make the original public and static so I can access it from anywhere

public static OrthographicCamera gameCam;


What's the best for performance?

Yeah of course. It costs money though (unless you do something else...)

Also comes preinstalled on Raspbian.

Mathematica/Wolfram Lang sounds great and all, but the thought of paying for using a programming language..

fuckin jews

I wouldn't call it a programming language.

Yeah I got it heavily discounted through university. It's the same with Matlab except you've got open-source stuff like Octave that's basically as good. No one has come close to replicating what Mathematica does. Sage is trying but it's still a long way off.

What's your definition of a programming language?

It's scripting/querying at best.

Can you use it to write an actual program?

Wolfram Alpha is written in Mathematica. Yes you can use it to write actual programs with it.

It is technically a scripting language I guess. But you can compile parts of your code into C and load it back into the interface.
reference.wolfram.com/language/ref/Compile.html

>Now the challenge is to make them not overlap.
-give each word a radius based on its size
-calculate the distance between the center of each and the direction between them
-move them apart until the distance is >= the sum of the radii

I have a question, in g++, does it include functions that are never called in the executable?

What about variables? If I define a variable, does it actually exist on the executable?

And if it does, what if I have sections of code that can be skipped over at compile time
Eg
bool debugging = false;
// code
if(debugging)
cout

does it actually exist if I never use it*

Still working on that. Obviously it's gonna depend on the length of the word and its size.

This seems like it could be useful:
static.mrfeinberg.com/bv_ch03.pdf

How does this make you feel, Sup Forums?

It's bad.

I checked it out because I really like Clojure, but that thread is filled to the brim with smug functional weenies who seem to care more about language pissing contests than actually making anything neat with the things they champion.

Are all future developers doomed to have to learn and use JavaScript?

indifferent, i don't do web so i don't have to deal with it

>separate HTML, JS and CSS
>CSS does jack shit without html
>html is shit without css
>js does shit
This guy is retarded

If you plan on doing anything web related, yea probably. You could always learn an alternative that compiles to js though.
github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js

separate in the sense you don't write them all in one file but rather in separate unit files

Makes me feel bad for him as he has not understood the benefit of declarative UI programming.

I use angular 2 for web development, so it's a non-issue for me

I'm not really a web guy but I don't see that being very viable if you want to create html in your JS files. PHP seems much worse though but even then it's not really a problem

Just learn Typescript instead.

it is
if you ever worked with something like that and then switched to a proper template system it's a hell and heaven difference

>tfw you will never make a OS for evangelion

Try implementing a linked list for starters.

And then a doubly linked list
And then binary trees, etc

I just wrote the dumbest thing trying to do an insert for a binary search tree, I feel like a retard after seeing how it's normally done

Can someone explain anonymous functions as simply as possible please? I don't understand when you would use them.

Preferably with some kind of example of real world usage.

They're simply functions that aren't assigned to a variable.

For example consider this C++ lambda as a sort callback to sort the objects by their age field.

struct Person {
int age = 0;
};

std::vector people{};
// fill the data

std::sort(people.begin(), people.end(), [](const Person &a, const Person &b) -> bool {
return a.age > b.age;
});

I think you are looking for
(Math/pow ...)

Also you should try to avoid using def when you can. loop and recur allow you to bind and rebind values, kinda like a let. So instead of def-ing your way through, you can:
(loop [pass 1
total base]
(if (< pass power)
(recur (inc pass) (* total base))
total))

This is better because you aren't setting anything. In Clojure you very rarely need to set anything, you would instead rely on functions and temporary bindings. So, uh, using def for intermediary things is kinda bad. Sorry. There are little things that you learn soon that help you get past a lot of this though.

As for the second block, you are using loop for a range of things, so here's how I would generally approach a problem like your powers function, I would first realize two things:
> I want a range of something (powers in this case), so I will likely use (range ...)
> I have a function that can give me the power of something (Math/pow ...)

So, the result would basically just be mapping the two:
(defn powers [base power]
(map #(Math/pow base %) (range 1 (+ 1 power))))

Also, if you are allergic to all the nesting, you can use ->> to limit that to one step per line.
You should use -> and ->>, because they are amazing.

(defn powers [base power]
(->> (+ 1 power)
(range 1)
(map #(Math/pow base %))))

anonymous functions are a quick way to pass your own logic into a function in the same way you would pass your own values into a function.

It's kinda hard to explain, but basically, it makes things like this possible: asciinema.org/a/7jlodigt8vkldvjjzq40393z3

The argument to the .map call basically the same thing as an anonymous function, and what it is doing is transforming a messy list of values into a nice list of information we care about.

Functions with no names

It offers really easy solutions like
reduce(lambda x,y: x+y, range(101)) #sum of all numbers from 0 to 100

Imagine a callback function except you can define it as a function literal and pass it as a variable.

how do i write C code and compile it and execute it in the simplest way (what text editor, compiler, etc). I'm on Windows unfortunately

I think I understand now. Thanks.

A function that doesn't have an identifier. You can sort of imagine it as the data that represents the function.

>I don't understand when you would use them.
Delegates/callbacks. Maps. Generic functions.

eg: I could implement a sorting algorithm, but instead of writing one for every reasonable use case and telling the user he's shit out of luck if they wanna sort something else, I could make it so that my sorting function takes a compare function which can do the comparison between to objects, so they can use my algorithm for anything they can write a compare function for (and if you can't write a compare function, sorting is impossible anyway). Sure, you could use a named function to pass in, but maybe the function is really small and you don't want to clutter up the environment with identifiers that people could potentially misuse, and you don't wanna scroll any more than necessary just to follow the natural flow of the program, so you declare it inline.

example:
function sort(data, compare)
-- ...
if compare(a, b) == 1 then
-- ...
end

sort(vectors, function(v, w) return v.x * v.x + v.y * v.y > w.x * w.x + w.y * w.y end);

with an ubuntu live image, gedit, and gcc

insert(node){
if head = null
head = node
else
currentnode = head
notinserted= true
while(notinserted){
if current = null
current = node
notinserted=false

else if current < node
current = current.right

else if current > node
current = current.left
}
}

Should I give up if this is what I thought of doing for a binary search tree insert instead of a recursive function

Having a problem in Ruby. Making an RPG with RPGMaker and we are trying to get text to display on screen during a battle after a skill is used.

hastebin.com/rodosiheyi.rb

@window = MyClass.new


is the line i'm talking about specifically, it will work if you manually go and type that in to an event script, but just trying to have it autorun as part of any of the main scripts will result in an error.

>gedit
>simplist
nano or vi
recommend vim though

I don't know what you mean by "simple" but on Windows I install msys2, add it to my path, install clang & make via pacman, then compile shit via the cli. I use a native Windows version of GVim as my text editor but you should use whatever. Same with the compiler, use what you want.

Learn how to write a makefile then all you'll have to do is write the C project and type `make` in the project directory to build, if it's portable you shouldn't even have to worry about the compiler, have a default compiler that you use but let the user define one for make to use if they want/need.

If you meant simple for development, maybe code::blocks, I'm not really sure.

Is it being called too often?

That looks roughly correct. What's wrong with it?