/dpt/ — Daily Programming Thread

Previous: What are you working on, Jow Forums?
>Why aren't you using a language with zero-cost abstractions yet?
>youtube.com/watch?v=B2BFbs0DJzw

Attached: vlcsnap-2018-01-06-00h52m30s468.compressed.png (1280x720, 728K)

Other urls found in this thread:

tutorialspoint.com/spring/spring_bean_definition_inheritance.htm
thecodeship.com/patterns/guide-to-python-function-decorators/
play.integer32.com/?gist=d90c66e3261344f1d95fdc6a2227e090&version=stable&mode=debug.
play.rust-lang.org/?gist=854e3eb56ecaaba5399530e9815053ed&version=stable&mode=debug
play.integer32.com/?gist=2e009983459ed16ea68b7fae7d2e3329&version=stable&mode=debug
twitter.com/SFWRedditGifs

[CODE]
int x;
unsigned char a[sizeof int] = &x; //assume big endian
unsigned char l[256] = {/* ffs(x) for 8 bits */};
r = l[a[0]]+
!!a[0]*l[a[1]]+
!!a[1]*l[a[2]]+
!!a[2]*l[a[3]];
// r = ffs(x)
[/CODE]
Why is this implementation of ffs(x) not used more? It's easy to change for little endian, of course.

>he doesn't know
Here is a hello india bean:
>tutorialspoint.com/spring/spring_bean_definition_inheritance.htm

>What are you working on, Jow Forums?
On my fucking qualifying work that I need to present in 11 hours. Yet here I am, lol.

Trying to learn SAS. Anyone got some good resources? Also, how much memory should this and the virtualbox take up? My 8gb are starting to be a nuisance.

>"they're making me use PyQt at work, it sucks"
>why does it suck
>"it's an old technology, isn't it?"
>uh not really no
>"well it sucks that they're making me use this"
>what would you rather be using?
>"react"
i hate pajeets

Is stella no mahou worth watching?
It's not cookie cutter cute girl sol shit like new game, right?

uh…

Where to get adderall for my C programming class?

>It's not cookie cutter cute girl sol shit like new game, right?

Attached: 1476111082775.jpg (540x652, 46K)

I have a coworker. Unfortunately, he is dumb. Not the What-The-Hell-Are-You-Doing-tier dumb, not Stop-Breaking-Stuff-tier dumb, but simply dumb: he doesn't read error messages, he doesn't look up things on google, he gets stuck in very trivial situations and so on. Also, he has very weirdly crippled understanding of programming concepts, even adapting to C# after many years of Java seems to be hard for him.
But, despite that, he is able to produce some working results, so the situation is not bad enough to get him fired. The only real problem is that he distracts me and other way too often. Telling him to fuck off is not nice(we try to be a good team here), so I wouldn't consider it as an option.

What would you suggest to improve situation? What would you do with such a coworker?

Attached: aho-girl-cover-e1515003715150.jpg (770x514, 60K)

From which anime does this image come from?

I ask this 5 threads ago, and nobody answered

do you work at siemens?

>I ask this 5 threads ago
this hasn't been used as an OP for a lot longer than that
also see

Well PyQt is actually trash. Python can't into proper signal/event interfaces. And even if it could - it only covers some basic Qt calls without allowing you to go indepth

Why are C programmers depicted as autistic?

Attached: C stella no mahou.jpg (1280x720, 154K)

No. Why do you ask?

Bloody beginner here, which formatting is better left or right?

Attached: 23451236.png (710x258, 15K)

newlines of the right, spacing of the left

I personally prefer the one on the left because usually you'll have more than 1-2 lines inside loops & conditions

Thx user.
Probably more than 5, I don't really count how many iteration of /dpt/ has been passed

the right side is the smallst and best

fortunately his argument was that it looked ugly and he didn't like using QtCreator.

>not Tcl/Tk
>not libui
>not wxWidgets
>not nuklear
Shit taste

Well, right now I'm studying signal processing

Programming-wise, I'm working on a K-Means algorithm so I can make pretty pictures and get cool colors.

Because they're overly concerned with being close to the hardware, dumb optimizations which really don't make *that* much of a difference, and making sure the memory management works out.
I know because that's my favorite thing about C programming.


Left, you should be able to immediately tell when a for loop begins/ends.

>Tcl
Stale meme
>libui
No docs. Into the trash.
>nuklear
Literally an SDL wrapper.
>wxWidgets
The only proper alternative. However I prefer Qt just cuz I use a shit ton of it's features (OpenGL) and the docs are really nice.

Right, but spaces between stuff in parens

left

>applied for a junior dev job
>phone interviewer asks me how I would go to implement the add method for a Set.
>"idk, have your set be a binary tree. Check if an element of equal value to the method argument already exists. If not insert it and return 1, else return 0."
>Interviewer audibly gets choked up and praises me because I'm the first one in two days to give an half decent answer. No further questions required, wants me to meet the team asap
I'm still wondering if this was a joke. Is the bar that fucking low for junior devs?

If only you knew how bad things are

fizzbuzz isn't a meme
people really are this fucking worthless, even straight out of uni

Attached: fizzbuzzed.png (952x1345, 177K)

Attached: all the answers.png (2752x4342, 742K)

Are interrupts handled immediately?

I know some "middle"-level coders who would ask "what is a binary tree?" if they heard your answer. :(

Trying to wrap my head around Python decorators because fuck this language. Everything I find via google likes to pretend decorators with arguments don't exist, or barely attempts to cover them.

Let's say I have FileA.py:
class ClassA(object):
'''stuff'''
And I have FileB.py:
class ClassB(object)
'''stuff'''
@FileA.ClassA('random_name')
def main(self):
'''more stuff'''

What is actually happening when File B's ClassB's "main" function is called?

I keep thinking "this can't be real", but I can't believe either that any decent programmer could even make this shit up

Right is easier to read because everything isn't so fucking spaced out.

Only pajeets don't space between operators

>these literal fucking retards can get interviews and waste people's time
>meanwhile all i get is nothing and the odd rejection email every once every 100 tries
>i've never even gotten a phone screen

Attached: KILL SELF IMMEDIATELY.jpg (597x597, 40K)

>Why is the answer a double?
>Because it needs to store the value taken from _two_ variables.
Comedy gold. I want to use this if I'm ever in a situation that calls for a bad programming joke.

Remember, that decorators are just functions with syntax sugar.

First, FileA.ClassA function is called which returns a decorator. Then when you call main(), the decorator's function is called. Inside it, the decorator calls main.

thecodeship.com/patterns/guide-to-python-function-decorators/

Thanks user this thread is much comfier and that image is very cute.

Wow. I could do that within my first month of self taught programming in c#, it might look ugly and I'd use a lot of "else if" statements but I could do it.

Attached: 1523324213553.png (1920x1080, 3.09M)

I want to thank you for these. During the past week, I've been feeling like total garbage, I have been stressing a ton over, with three in-person interviews coming soon. I feel so worthless from my lack of experience and the fact I barely know any programming frameworks and never touched front-end stuff, but now I know even a retard like me has a place in this fucking industry.

React/TypeScript > Qt/C++ > Qt/Python

I was asked the odd number question in a phone interview, my answer was "return var & 1" and the interviewer told me i'm wrong even after I explained what bitwise AND does. He said it didn't match his piece of paper.
So then I changed it to "return (!(var % 2))" and he still said NO.
At one point I was trying to teach him how binary works and asked him to google what 3 looks like in binary because saying ZERO ZERO ONE ONE wasn't working over the phone and then tried to worm his way out of the interview, I wasn't called again, obviously.

Attached: cappucirno.jpg (360x360, 24K)

I thought it was cappuchirno

Depends on what you mean by immediatly.
There's always a latency which can be anywhere from nanoseconds to milliseconds depending on the architecture, priority levels, etc.

cirno===chirno

>So then I changed it to "return (!(var % 2))" and he still said NO.
Wait. So what fucking answer do you think he was expecting? I don't fucking get it, was the ! operator too fancy for him? What the FUCK, user.

I want to write a function in Rust that accepts everything that can be iterated over with for. for accepts anything with the IntoIterator trait. So I tried this

fn print_all_integers(integers: &'a T)
where &'a T: IntoIterator

No, it is Sir no not Chirno

in japanese it's "chiruno"
the romanized version "cirno" was written with ancient anglicizing rules that predate the modern hepburn where チis actually written the way it sounds.
stuff like "tsu" is written "tu" and "chi" is "ci"

>my answer was "return var & 1"

Prelude Data.Bits> isOdd :: Integer -> Bool; isOdd x = x .&. 1

:18:37: error:
• Couldn't match expected type ‘Bool’ with actual type ‘Integer’
• In the expression: x .&. 1
In an equation for ‘isOdd’: isOdd x = x .&. 1


Probably you should have whispered "Flexible Instances" or something before giving that answer.

When it's just functions, I think I can follow everything. But it's when classes are involved that I just can't follow it. And even your link doesn't have an example of how it works when the decorator isn't a function but a class.

>First, FileA.ClassA function is called which returns a decorator. Then when you call main(), the decorator's function is called. Inside it, the decorator calls main.
So given my example code in , whenever a ClassB object calls its "main" function I will create a ClassA object with the argument 'random_text' inside the ClassB object, and then jump to ClassA's "__call__" function, which I should expect to at some point call and exec ClassB's actual "main" function by reference (and potentially utilize its return value)?

Try making it a T instead of an &'a T. That worked when I did it play.integer32.com/?gist=d90c66e3261344f1d95fdc6a2227e090&version=stable&mode=debug.

Well, Falcon (the guy who posted thes is in Thailand or somewhere near it. All the good web programmers there already work on remote, so only lowest of low are left for him to sit through.

What error are you getting? Doesn't look like anything related to the type system and IntoIterator; but a size problem. Adding the bound ?Sized to T (which removes the implicit bound of std::marker::Sized) seems to make it work.
play.rust-lang.org/?gist=854e3eb56ecaaba5399530e9815053ed&version=stable&mode=debug

you forgot to close that parenthesis

This example doesn't compile, and you're passing in a Vec, not a slice.

)

thanks user, I could also remove the lifetime on T

play.integer32.com/?gist=2e009983459ed16ea68b7fae7d2e3329&version=stable&mode=debug
this compiles

Don't know why that previous example was shared instead of the slice one, my apologies.

Why id disc "3" moving to the right so much?
Any logic error?

Attached: Screenshot from 2018-06-08 08-41-39.png (3840x2160, 480K)

It's customary to attach a picture of akari whenever you post Rust code. Let me fix it.

Attached: 1521071935057.jpg (475x731, 41K)

stop you aren't the real akariposter
the real akariposter uses C

Akariposter is a templated class.
There is Akariposter. Akariposter, Akariposter etc

There's akariposter[Nim] too

Attached: 1526461619344.jpg (750x1000, 93K)

i will destroy you impostor

Attached: 1524715780160.jpg (930x700, 448K)

Right but with spacing between operators.

You in the left

Attached: 1520121733943.png (578x560, 294K)

Well, I'm trying to reverse engineer the line algorithm in MS paint by analyzing its output and nothing else.
what are you guys doing for fun?

Attached: 1520203212907.jpg (541x319, 21K)

right, don't listen to the VS(tm) wincucks

seems pretty simple. n px difference in height from beginning to end results in n segments. Widths of various segments seem to be constant for the inner segments, and constant for the outer segments, but inner and outer are of different lengths. It would appear just from looking that the pixel length of the outer segments is based on something like m/n^2, where m is the length of the line and n is the difference in height between the starting pixel and the ending pixel. though you would need more data.

This would make sense, for if the line was at a 45 degree angle, each segment would be exactly 1/m long, where m is the length of the line, thus according to the original equation the outer line segments would be m/n^2. and since it is 45 degrees, m must equal n, so by the guessed equation:

m/n^2 = m/m^2 = 1/m, exactly as predicted. But not so for other lengths. It would appear that a constant is needed to prevent the outer segments from getting too short too quickly.

The inner segments length could then be calculated by:

(m - C*(m/n^2)) / (n - 2)

where m is the length of the line and n is the pixel difference in height from the starting pixel to the end pixel, and C is our constant which == 1 when m = n.

the second line, if it has a length of 20 pixels and a 1px difference in height from the beginning to end:

(20 - 20/1^2) / (n - 2) = 0, as expected since it has no inner segments.

But for the other segments, the inner segment lengths calculated by this equation seem to large. For instance, the third line yields an inner segment of length 17 (with C == 1) with an original line of length 20 and difference in height from beginning to end of 3. So the constant C would need to be tweaked appropriately until you get something close. figuring out what that is would be tiresome, but I'm confident you could get close to the original.

God rust looks even uglier than c++.

A friendly nim user. I gotta sleep, can't help you now.

Key value = random value from 0 to 1023
Teaser value = random value from 0 to 63
Encrypted Result = ((Key & 1008) * 64) | (Teaser * 16) | (Key & 15)


"Now show me how you will decrypt the Encrypted Result back to Key value"

I don't understand basic highschool computer class. Please help.

Only undergrads care about the looks/people/community etc

Are you SatsB by any chance?
Anyways I posted on the forum, help appreciated.

And am I supposed to care about that?

Try with 'add dest, pop(src)'

its more complex than it looks, it handles "reminder" pixels in a particular way.

How should I check whether a dot in 2D space is within some weird shape ie. a star?

Simple full text search of documents could be done by reverse index mapping word to list of documents, add posititions to support multi-word phrase search.
But how to handle substrings? Must you just decompose each word into n-grams and add these to reverse index?

ayy it worked. thanks

let mut ui = ui::Ui::new();
ui.run(&|s: String| {
let some_result = do_whatever(s);
ui.out(some_result)
});
// ui:
// pub fn out(&mut self, s: impl Into) ...
// pub fn run(&mut self, command_callback: &Fn(String)) ...

what do I even do here?

Attached: ss-2018-06-08-02-34-56.png (897x605, 28K)

>So then I changed it to "return (!(var % 2))" and he still said NO.
At the latest at this you should have demanded to speak with the head of his department. The person doing the phone interviewing is obviously not a qualified programmer.

how would you check for a point in a "non-weird'' shape?

If it was a box it would be rather simple to do. You could boxify the shape, but it seems like a poor solution.

It's pretty easy to check a point against a convex shape, so you decompose concave shapes into multiple convex parts and do it for each.

Playing with prolog at the moment. Just implementing lots of basic stuff.

Programming with logical relations is cool. Seeing append/3 work backwards was what convinced me to take it seriously.

I'm trying to make a 2D follow camera in a 3D space, but right now the camera keeps moving right for no reason.

As you can see in the print statements the limit of the camera x (right corner) always is bigger, even if Pacifica is outside the camera view (to the left).

Pls any ideas.

Attached: progress.png (1440x900, 179K)

left,anyone who tells you right is a pajeet

bit of an unrelated question here: is there a way to compile my project through all the compilers i have?I have no idea if IDEs support this

i want to learn js and w/e relevant frameworks
i know a few other languages already: c, sepples, python, java
what resources would you recommend?
inb4 js is shit
its for a potential job in and a side project

Just learn typescript instead

VS has MSBuild BeforeBuild event

just goodle the most popular js frameworks, fire up an IDE/text editor and start making websites.If you're an extrovert, you might consider putting your code on Github(inb4 the Microsoft whining)
Most jobs today in the web ""development"" industry are made through portofolios, since almost everybody knows how to make a basic website.Focus on performance and interesting ways to get user's input, design,etc.
It is probably the most documented & resourceful industry out there, just go on the /wdg/ thread

got an internship with a $71k annual salary for having experience with the python scientific stack on my resume

i'll give it a try, thanks.

>get_tree().get_root().get_node()
Jesus.
What do you mean 2D follow camera?