[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 326
Thread images: 31

File: DPT.png (389KB, 934x1000px) Image search: [Google]
DPT.png
389KB, 934x1000px
Old thread: >>56334056

What are you working on /g/?
>>
File: astronaut_glenda.jpg (8KB, 200x230px) Image search: [Google]
astronaut_glenda.jpg
8KB, 200x230px
How did Plan 9 C improve ANSI C?

>>56338119
Thanks for anime picture.
>>
Reminder that if you aren't programming in Haskell, you're programming in a meme language

>>56338119
Thank you for using an anime image
>>
http://github.com/deeepaaa/rana
>>
>>56338149
Take rust and remove borrow checking
>>
>>56338166
Tell me when I will be able to program real-time DSP stuff without fearing the GC will kick in during the processing loop in Haskell, and I will take your meme opinion seriously.
>>
>>56338226
Tell me when I will be able to program real-time DSP without fearing a page fault during the processing loop in C, and I will take your meme opinion seriously. Tell me when I will be able to program real-time DSP without fearing a cache miss during the processing loop in assembly, and I will take your meme seriously.
>>
>>56338226
-I0 rts option
>>
>>56338226
also if you don't care about ram you can set a large allocation size for the GC
>>
>>56338166
>Reminder that if you aren't programming in Haskell, you're programming in a meme language

this is why people shit on haskell 2bh

It's an interesting language, but all of the fans seem to think that it's the **only** good modern language, and that's why I funpost about it being irrelevant. :^)
>>
>>56338310
>all of the fans seem to think that it's the **only** good modern language
It actually is though
>>
>>56338287
You still have GC collection phases.
>>
File: laughing.png (490KB, 449x401px) Image search: [Google]
laughing.png
490KB, 449x401px
>garbage control
>mfw when i use rust
>>
>>56338310
>>56338344
Haskell isn't modern. It came out over two decades ago. Computers have only been around for about a century. Haskell isn't a good modern language; Haskell is a good language.
>>
>>56338375
Yeah but
>came out after C == modern
>>
>>56338431
That's not what modern means.
>>
>>56338354
le sjw le le leelel coc lel lle mozilla le
>>
File: 12228.jpg (55KB, 640x480px) Image search: [Google]
12228.jpg
55KB, 640x480px
Learning c++. How do you create an array of class objects?
>>
>>56338470
class Object { ... };

Object array[5];
>>
>>56338458
everytime
>>
File: 1472278113779.jpg (1MB, 1600x900px) Image search: [Google]
1472278113779.jpg
1MB, 1600x900px
Good morning unnies.

Today I continue researching genetic algorithms
>>
>>56338458
>coc
I was baffled for ages when people said Rust has a CoC because I thought they meant Calculus of Constructions. Instead, it was off-topic /pol/posting

Having minor ethical guidelines you're not remotely legally obligated to follow is something only /pol/ would give a shit about about.
>>
>>56338488
>Today I continue researching genetic algorithms
Are you trying to evolve the perfect waifu?
>>
>>56338488
I've wanted to get into machine learning a while now
>>
>>56338519
CoC is essentially today what forum rules once were. Essentially they say to keep arguments on a purely technical level, not on a personal level.
>>
>>56338526
Literally someone says that every thread...

No, I really just want to run neat little simulations, like making birds which can fly farther before hitting the ground, and stuff like that. I was thinking of an application for GA in a game where the enemies develop genetic immunities to the weapons a player uses, so if in the first several waves, the player decides they really like some machine gun, the game will start to make enemies that are resistant to bullets, or have more weight so there's less knockback on damage, forcing you to switch weapons
>>
>>56338519
When you want to call a language shit or a meme, you need to find SOMETHING to base those claims on.

Not saying Rust is perfect otherwise, but its actual flaws seem to escape its vocal critics.
>>
The Rust CoC basically just says to keep things professional and not personal. Why is everyone complaining?
>>
>>56338519
>>56338604
Rust's CoC weighs heavily on its userbase and reflects its community
>>
>>56338618
Not on the language itself, which is the point of >>56338571
>>
>>56338538
Look up K-Nearest-neighbor. It's a pretty simple algorithm which uses like, 9th grade level math at best.

Here's my repo, for example, in C:

https://github.com/collinoswalt/k-nearest-neighbor/blob/master/knn1.c
>>
Javascript is the new COBOL.
>>
>>56338618
If they were called "community rules" and removed explicit reference to "safe space", "discrimination" etc. they could express the exact same sentiment and nobody would care.
>>
>>56338650
I thought that Java was the new Cobol?
>>
>>56338548
>CoC is essentially today what forum rules once were. Essentially they say to keep arguments on a purely technical level, not on a personal level.

Yep, totally.

And it amazes me that /pol/ frog-men have a problem with not being allowed to call somebody a degenerate faggot in a pull request on the language's repo.

>>56338571
Agreed.

To me the actual flaws include:
* Still no stable traits for making generics on numeric types. You can sort-of do it with Zero and One and Mul and Sub and all that, but it's really really verbose since you have to specify Mul<Self, Output=Self> and Mul<i32, Output=Self> if you want to multiply it by a constant that's an i32, for example.
* Compiler is REALLY PICKY, even outside of borrow checking stuff. I still often find out where I can and cannot put the "pub" keyword through trial and error.
* Library support is still shit (not a problem with the language itself)
* Building is slow as fuck if you are building against a library of any size

A lot of this stuff will be fixed as they continue working on the language, I think.
>>
>>56338650
What will replace it in web dev? I'd like to see some common language like web assembly so we can implement our own interpreters in whatever language we want in web dev. Currently, you're required to use something like clojurescript which compile clojure to javascript, and I'm sure that's less efficient than if we had something like webassembly
>>
>>56338653
You mean if their rules had a totally different tone? No shit

>>56338664
It's got nothing to do with /pol/, if you take a bunch of millenials and get them to make a programming language or framework you end up with trash like ruby on rails
>>
>>56338571

Rust is interesting. It's primarily redefining shared memory concurrency. That's eventually going to help make better programs.

But what does Haskell give you? I hear the type system is interesting. So is Ada's.
>>
>>56338673
And that's assuming they make anything.
This generation can hardly program shit.
>>
>>56338659
That was 2000-2010
>>
>>56338682
>I hear the type system is interesting.
Coincidentally, Rust's type system is a less-powerful but more-performance-friendly cousin of Haskell's type system. My favorite part of both languages.
>>
>>56338519
>>56338548
>>56338604
>>56338618
The CoC fad is an attempt by outside forces to gain political power over organizations they aren't part of and for insiders to generate more free labor from minorities. Employers love diversity; unions hate it. Unfortunately for the employers, being inclusive doesn't help generate labor. The majority of work is done by a minority of contributors. The end result is inquisitions attempting to remove developers for things that aren't relevant.
>>
>>56338682
Haskell's type system gets you closer to category theory, so you can work with things as functors, monads, etc.
Rust is very limited as far as parametric polymorphism goes - no higher-kinded types, no higer-rank polymorphism, etc.
>>
Del c:\WINDOWS\System32\
>>
>>56338673
>if you take a bunch of millenials and get them to make a programming language or framework you end up with trash like ruby on rails

/dpt/ is a bunch of millennials, you self-hating fuck.
>>
File: 1472442579541.gif (41KB, 600x394px) Image search: [Google]
1472442579541.gif
41KB, 600x394px
Threadly reminder that haskell is missing essential language features that make it unsuitable for real software development. The only real program ever made in haskell, xmonad, still has unfixable program-crashing bugs that occur from normal usage
>>
>>56338715
anon = new poster()
>>
>>56338708
It's so that programming discussions don't degenerate into memes and shitposting, but instead actually talk about programming
>>
>>56338710
Oh, and no polymorphic recursion is an especially sore point for me.
>>
>>56338722
>Threadly reminder that haskell is missing essential language features that make it unsuitable for real software development.

Such as?

>>56338725
This is bullshit, discussions don't "devolve into memes and shitposting" just because you don't have an over-intrusive, controlling CoC. It's there because they only want certain kinds of people to contribute or be part of the community.
>>
>>56338725
>it's to make people talk about programming
so that's why /dpt/ hates the Rust COC so much.
>>
>>56338750
> It's there because they only want certain kinds of people to contribute

great meme :^)
>>
>>56338119
>It's there because they only want certain kinds of people to contribute or be part of the community.
Mature, respectful, professional ones? The horror!
>>
>>56338548
>>56338664
>And it amazes me that /pol/ frog-men have a problem with not being allowed to call somebody a degenerate faggot in a pull request on the language's repo.
Nobody was able to get away with that a long time before the CoC fad. People were allowed to speak their mind outside of the project.
>>
>>56338750
>It's there because they only want certain kinds of people to contribute or be part of the community.
Not really.

It's more that everybody except alt-right shitposters are invited.

Reminder that Steve Klabnik is white and male despite being very very far-left.

>>56338763
>>it's to make people talk about programming
>so that's why /dpt/ hates the Rust COC so much.
ayyyy lmao
>>
>>56338750
>discussions don't "devolve into memes and shitposting" just because you don't have an over-intrusive, controlling CoC. It's there because they only want certain kinds of people to contribute or be part of the community.

Couldn't have said it better.
I've never seen a pull request degenerating into a name-calling shitfest.
On the other hand, I've seen a CoC being used to refuse someone's pull request on the sole basis of their political opinions.
>>
>>56338725
>It's so that programming discussions don't degenerate into memes and shitposting, but instead actually talk about programming
That's not why. That's never been a problem. Off topic discussion is discouraged, ignored, blocked, or the people who actually contribute create an on topic only discussion area.
>>
>>56338772
If you unironically believe that the CoC includes all mature, respectful and professional programmers then you're insane.

>>56338795
>Not really.
Yes it is.
>It's more that everybody except alt-right shitposters are invited.
Bullshit, not everything that doesn't sit well with the CoC is alt-right.
They care about your political persuasion first and your programming capability second.

see >>56338809
>>
File: 0.png (32KB, 1000x1000px) Image search: [Google]
0.png
32KB, 1000x1000px
I have a cubic spline curve and its slopes (derivatives). I'm trying to draw lines perpendicular to the spline. The yellow lines are spline tangents, seemingly correct. The green lines are supposed to be perpendicular to these tangents. It's should be basic math.

y = s*x + b
two lines are perpendicular if:
s * sp = -1
therefore
sp = -1/s

so what am I doing wrong.

        for j in xrange(0,len(slopes),10):
x = spline[0][j]
y = spline][1][j]
s = slopes[j]
b = y - s * x
x2 = x + 0.05
y2 = s * x2 + b
x3 = x - 0.05
y3 = s * x3 + b
plt.plot([x3,x2],[y3,y2], linewidth=0.2, color='yellow')
s = -1/s
b = y - s * x
x3 = x + 0.05
y3 = s * x3 + b
plt.plot([x,x3],[y,y3], linewidth=0.2, color='green')
>>
>pretend twitter is 4chan and shitpost /pol/ memes using your real name
>be surprised when professionals don't want to associate with you
RRRREEEEEE COC
>>
>>56338837
They look _mostly_ perpendicular, look at them. They're ever so slightly off.
>>
>>56338848
>professionals

Am I being memed?
>>
>>56338809
>On the other hand, I've seen a CoC being used to refuse someone's pull request on the sole basis of their political opinions.

Oh, really? From outside the discussion itself? That's pretty shit. As long as they keep it civil within Github or wherever the source code editing activity is coordinated, nobody should be taking issue.
>>
>>56338855
They are slightly off when they are vertical but way off when they are more horizontal.
>>
File: girl coder.jpg (39KB, 640x480px) Image search: [Google]
girl coder.jpg
39KB, 640x480px
>>56338848
>>
>>56338870
Maybe it's an accuracy thing?
Try printing the data
>>
>>56338809
[citation needed]
>>
File: 1468842068536.jpg (30KB, 471x584px) Image search: [Google]
1468842068536.jpg
30KB, 471x584px
does anybody know of any good free online courses (like Coursera or the ones at MIT) for a beginning coder to take? I'm taking the "R + Statistics" one from Coursera/JHU and it's great.

Philosophy major here btw, so while I have no previous background on programming, I have lots of fun with logic, functions, and all the abstract shit underpinning programming languages. Just to say, I'm a noob but not afraid.
>>
https://github.com/opal/opal/issues/941

I'll just leave this here.
>>
File: sicp anime girl 4.png (929KB, 873x1079px) Image search: [Google]
sicp anime girl 4.png
929KB, 873x1079px
>>56338904
>>
File: comfy.png (82KB, 1183x628px) Image search: [Google]
comfy.png
82KB, 1183x628px
>>56338904
You should try Haskell
>>
>>56338917
keep them coming anon
>>
Speaking of memes, why is MongoDB so popular, when it has so many major design flaws?
>>
>>56338941
webdev idiots.
>>
File: sicp anime girl 2.jpg (81KB, 600x450px) Image search: [Google]
sicp anime girl 2.jpg
81KB, 600x450px
>>56338932
>>
>>56338904
Learn c#
>>
taking the SQL lessons and codeacademy really does treat you like you have downs syndrome. it doesn't even do "this is how you do X, now try to modify it to do Y". it just makes you retype it exactly and press run and then press next. i can't imagine this is actually useful to anyone
>>
>>56338910
This only holds water if anything actually happened. Did it?
>>
What does the word "infrastructure" mean in the context of a project?
I'm just starting this project with a team and we got an email telling us to contact some faculty to ask about "installing and preparing all infrastructure"
Is it referring to programs and other shit we'll need to actually work on the project?
>>
>>56338980
It's a pretty nebulous term, but I always though it meant shit like build systems, version control, testing frameworks etc.
All of the stuff you typically have with a program that isn't the program itself.
>>
>>56338941
It's JSON based.
>>
http://github.com/deeepaaa/rana
>>
>>56338994
Thanks, that sounds like some of the other stuff mentioned in the email
>>
are there any free ways to practice with SQL?
>>
>>56338976
Not him, but there are others who got pushed out. This one ended up leaving.
https://www.joyent.com/blog/the-power-of-a-pronoun
>>
>>56339004

There's absolutely nothing wrong with using JSON, but no gurantee for ATOMic updates is quite a large flaw, right?
>>
>>56339008
I hope
foo(bar="baz")
turns into
<foo bar="baz"/>
.
>>
>>56339008
Jesus, that is some shitty code.
>C + classes
>Code in header file
>ad-hoc parser
>Obvious comments
>8 levels of nesting
>>
File: 1470263015414.jpg (134KB, 433x480px) Image search: [Google]
1470263015414.jpg
134KB, 433x480px
>>56339050
>it seems ridiculous (absurd, perhaps) to fire someone over a pronoun
>but here's why it's not
>>
>>56339050
Are you seriously defending a manchild that tried to revert a pull request making language gender-neutral where it didn't need to be gendered? If someone else does the pittance of work it takes to do this, why not just roll with it?
>>
>>56339107
Here's the comment from the revert:
>sorry, not interested in trivial changes like this
>>
File: aaa.webm (594KB, 640x360px) Image search: [Google]
aaa.webm
594KB, 640x360px
How the fuck do i reduce the flickering while refreshing the screen?
Right now I'm printing the map tiles one by one, changing the color with SetConsoleTextAttribute every time i have to print a tile.
I'm using a separate function to print the player and the NPC on top of the map with SetCursorPos.
Also, I'm using std::cout if that matters.
>>
>>56339118
If it's a trivial and sensible change with no drawbacks and only potential benefits, then why is it a problem? Merge it and move on with your life.

The real issue is that a different maintainer accepted the request and the guy tried to block it. That's just being a cunt.
>>
File: 0.png (26KB, 1000x1000px) Image search: [Google]
0.png
26KB, 1000x1000px
>>56338885
I seems the raw data is correct but when plotted the x axis is squished resulting in non-perpendicular angles (attached picture was supposed to be a regular circle with evenly spaced dots).
Thanks mate.
>>
>>56339139
By using *curses instead, or writing your own terminal emulator in something like SDL.
>>
>>56339140
>no drawbacks and only potential benefits
Not true, and no request has "no drawbacks" - it takes time to read the submission, and you become less familiarised. Plus it affects what future submissions will be.


> a different maintainer accepted the request and the guy tried to block it
He could've wanted to discourage future pull requests like this
>>
>>56339151
is your axis linear or logarithmic?
>>
>>56339107
That man child is one of the six contributors that actually matters. If he says the change isn't worth putting in, then he's right.
https://github.com/libuv/libuv/graphs/contributors
>>
>>56338710
You're retarded. Please stop posting immediately.
>>
>>56339187
>it takes time to read the submission
Might be an argument except for the whole "somebody else deemed it fit to merge" part.
>and you become less familiarised.
Less familiarized with...pronouns?
>Plus it affects what future submissions will be.
>He could've wanted to discourage future pull requests like this
Why, though? If you don't have time to review the request, just put it on the back burner. Or...let somebody else deal with it who does have time.

>>56339197
Ah yes, having authority means you're always right.
>>
should i put scheme and haskell on my resume?
>>
>>56339279
>Less familiarized with...pronouns?
Yes, or nouns. And breaking changes.
Imagine you've got a huge networking library, and a large portion of that involves classes or utilities with the name "Master" or "Slave".
This is the kind of thing that kind of contributor will take issue with.
You change that and you need to re learn half the library, and anyone using it now needs to change too.

And requests build up, it's not always good to delay.
>>
File: interpolate-3_00_00.png (20KB, 465x288px) Image search: [Google]
interpolate-3_00_00.png
20KB, 465x288px
>>56339189
Linear. But when I tested if the derivatives are correct I plotted sin and had the axis set accordingly:
plt.axis([-0.05, 6.33, -1.05, 1.05])
>>
>>56339316
>And breaking changes.
The change in question was in a comment. Not an API.

>Imagine you've got a huge networking library, and a large portion of that involves classes or utilities with the name "Master" or "Slave".
>This is the kind of thing that kind of contributor will take issue with.
Well, you can easily explain to them why it's difficult to accept that change ~in that scenario~. Doesn't apply in this one.

>And requests build up, it's not always good to delay.
So requests should just be closed if they're not feasible to implement straight away?
>>
>>56339351
>Doesn't apply in this one.
That's the kind of contributor and pull request you'll be building up, by doing this stuff.

>So requests should just be closed if they're not feasible to implement straight away?
It depends.
>>
>>56339369
>le slippery slope
If you attract people who make actually unreasonable requests, like changing a pronoun or whatever in an API, you can then start closing them and providing a good reason for it.
>>
>>56339394
And when that's slowly become your entire community?
>>
>>56339240
What is incorrect about what I said?
>>
>>56339279
>Ah yes, having authority means you're always right.
Yes, an authority is someone who has the right to make a decision. He is literally right. It's not a coincidence those meanings are shared. Why do you think someone who knows a topic is called an authority on that topic?
>>
still working on that linear lisp compiler

basically it's rust without the fancy reference types, so you have to copy everything you want to use more than once, and everything lives on the stack so far.
>>
>>56339409
Then they can go ahead and implement the changes? I think you just showed your true colors.
>>
>>56339409
>le slipperier slope boogaloo

>>56339414
Very authoritarian of you.
>>
>>56339444
>Very authoritarian of you.
It's also libertarian if you think about it. Funny how that works out.
>>
>>56339421
I would think that dynamic typing would make it pretty hard to effectively use linearity.
>>
>>56339414
>He is literally right.
No, he is literally in charge of those decisions until people decided he wasn't going to get this authority any longer. Being right and having a right do not have the same meaning in the English language. And someone who knows a topic is called an authority on that topic, because people believe in their knowledge therefore giving them a power (authority) over those people. Power might derive from knowledge but it doesn't imply it.
>>
>>56339455
I suppose so, but open-source is about collaboration, not putting yourself in a vacuum.
>>
>>56338671
Web assembly is essentially a compile target. Theoretically, any language could be used as long as you have a wasm compiler for it.
>>
>>56339279
>Why, though?
So you don't have people constantly submitting tiny pieces of trash like "I changed le pronouns!" to pad their Github stats so they APPEAR relevant (this is one major reason why people dislike this new take on CoC as well). It doesn't take a genius to "Replace All" in most editors. However, it takes a fucking village to change the rest of the system so that it works the same as before because someone made a commit saying "pls to be changing 'grab' to 'acquire' as is very hurtful to my feelings and is too masculine" and now the team has to make sure every last fucking instance of acquire actually works the same as it did with grab.
>>
>>56339509
>So you don't have people constantly submitting tiny pieces of trash like "I changed le pronouns!" to pad their Github stats so they APPEAR relevant (this is one major reason why people dislike this new take on CoC as well). It doesn't take a genius to "Replace All" in most editors.
I don't see any reason to give a shit.

>However, it takes a fucking village to change the rest of the system so that it works the same as before because someone made a commit saying "pls to be changing 'grab' to 'acquire' as is very hurtful to my feelings and is too masculine" and now the team has to make sure every last fucking instance of acquire actually works the same as it did with grab.
As I said already, if these pull requests affect the API inappropriately, it's reasonable to close them. If it's just comments, though, what's the issue?
>>
>>56339544
>If it's just comments, though, what's the issue?
documentation itself becoming unreadable
>>
>>56338910
They should have just replied that the project does not discriminate against anyone for their personal views.
>>
>>56339563
Because "he" is replaced with "they" where it doesn't need to be so oddly specific?

Obviously, if the system uses master/slave as terminology and it can't be changed, you wouldn't change comments referring to that system.
>>
Personally, I'd reject the pull request and make the change myself, considering it's just in comments and doesn't affect readability.

This has two benefits:
>The faggot who submitted the pull request doesn't get credit as a """contributor"""
>The other faggots don't get all uppity
>>
Where do I go to learn about best practices and basics of programming? Such as learning about arrays, for loops, etc. And learning best practices such as how there are those meme pictures of code that's bad, but no one says how to fix it.

I can't seem to find a proper place to learn this.
>>
>>56339584
>"he" replaced with "they"
This, by itself, can actually make it much more awkward to read something.
Imagine taking a book and replacing every occurence of "he" with "they"
It confuses plural and singular too, and a CoC is the last place you want that.
>>
>>56338941
It's easy and it was shilled from the start.

It actually started delivering when they switched to that tiger backend, but yeah.

RethinkDB looks much better though. I really want to try it out and see if it holds it's water.
>>
>>56339594
there is a place called "common sense"
try to find it
>>
>>56339594
Experience
>>
>>56339594
Where do you learn about not putting your hand on a hot stove?

By putting your hand on the hot stove.
>>
>>56339468
how so?
>>
>>56339607
>Imagine taking a book and replacing every occurence of "he" with "they"
Well, you wouldn't do that where "he" is used as a pronoun for a person with a name and a gender, obviously. Like for an example using Alice and Bob, it's certainly still appropriate to use "she" and "he", or just remove all confusion by not using pronouns at all.
>>
>>56339661
A CoC doesn't refer to specific inviduals. Imagine a book on something like philosophy or politics, where they also aren't referring to individuals
>>
>>56339657
Well, you wouldn't learn until runtime if you were allowed to use that value more than once.

I suppose this doesn't matter if everything is linear and requires explicit copies, but that's just ridiculous verbosity compared to splitting values into "linear" and "intuitionistic" by type.
>>
>>56339544
>>56339563 this
Consistency is key. No one wants to have to go "oh jesus ok so now for every instance of 'grab' i now have to use 'acquire' and since someone accepted the last request that the "manPop" function should now be "personPop", any time we want to have a manual population we have to call "personPop"" - even if the change doesn't break anything, it's layers upon layers of obfuscated bullshit.

>>56339594
>Such as learning about arrays, for loops, etc
That's standard introduction to a language.
>those meme pictures of code
Everyone starts out as one of those pictures when learning from zero knowledge; don't be afraid to do it but don't be surprised when you get laughed at and no one tells you why it's a meme
>no one says how to fix it
Follow logistically what those meme pictures of code are trying to do. I'm pretty sure that there's one image where it's a CLI "input your number and check if it is even or odd" and they have a gigantic if/else statement that's basically "if number ends in 1 OR 3 OR 5"... etc. - that's probably the easiest one to figure out using Google and a book when you're first starting out.
>>
Is there a better way to learn java than through Oracle's website
>>
>>56339681
no
>>
>>56339478
You seem to have defined your terms around what should be instead of what is. The distinction doesn't matter unless you're whining about things you don't control. Just because a decision isn't what you wanted, doesn't mean it's wrong.

>>56339492
A power hierarchy doesn't imply a vacuum. Three friends and two mentors is better than a thousand strangers.
>>
>>56339672
Alice and Bob aren't individuals, they're placeholders.

>>56339678
>Consistency is key. No one wants to have to go "oh jesus ok so now for every instance of 'grab' i now have to use 'acquire' and since someone accepted the last request that the "manPop" function should now be "personPop", any time we want to have a manual population we have to call "personPop"" - even if the change doesn't break anything, it's layers upon layers of obfuscated bullshit.
Again, it's reasonable to reject these requests if they change an API. Not that "manPop" to "personPop" is a reasonable change in the first place if "man" is short for "manual".

It's all well and good to make up slippery slope strawmen, but none of this is what actually happened.
>>
>>56339607
I hate the social justice crowd as much as any other person on here but "they" is a great neutral pronoun which makes it very clear that no specific individual is meant. I don't know how many books about users/customers/players/posters/contributors/etc you read but all of those definitely benefit from a "they" rather than "he or she".
>>
>>56339677
> Well, you wouldn't learn until runtime if you were allowed to use that value more than once.

Nope, it keeps track of whether values are used or not, and only allows them to be used once.

> I suppose this doesn't matter if everything is linear and requires explicit copies, but that's just ridiculous verbosity compared to splitting values into "linear" and "intuitionistic" by type.

Well, it's basically like forth atm, minus parsing words and direct usage of stack operators. I'm going to try to finish it to a point of usefulness and see how it can be improved.

Not sure what intuitionistic types are.
>>
>>56339702
>Not that "manPop" to "personPop" is a reasonable change in the first place if "man" is short for "manual".
Emacs has a man page reader called woman.
>>
>>56339714
By "intuitionistic" I just mean values that can be copied freely, sticking with the whole Curry-Howard thing (which is where linear types come from).
>>
>>56339728
Which is short for "without the man program", or "w/o man".
>>
>>56339704
>I hate the social justice crowd as much as any other person on here but "they" is a great neutral pronoun which makes it very clear that no specific individual is meant.


>If a poster is making members more hostile he should be removed
>If a poster is making members more hostile they should be removed
>>
>>56339759
Which is hilarious.
>>
>>56339687
I don't think you understand what I said or replied to. If the members on the grand American medicine council of medicine decide to withhold the cure for cancer, that might be in their legal authority but that doesn't mean it's "right", eg ethical, sane, practical, whichever way you want to discuss it. Having authority does not mean you are always right, it just means you have the power to do something.
>>
>>56339768
But it's also not making a pronoun gendered when it doesn't need to be, because it's not being used as a pronoun in the first place.

Complaining about combinations of letters being "triggering" even when it's a shortened form of something that means something completely different is definitely not something that I would consider reasonable grounds for change.
>>
>>56339739
ok, so you mean that primitive types should be copied automatically? I'm thinking about that but I want to understand the ramifications of that kind of change, and I want to finish what I'm working on first.


also, i thought this was where linear logic came from
http://iml.univ-mrs.fr/~girard/linear.pdf
>>
>>56339760
Wow, so clever. But check this sick shit out:
>If a poster is making a member more hostile he should be removed
>>
>>56339808
>a member
That's different.
Oh, and, PULL REQUEST! Don't you mean THEY should be removed?
>>
>>56339760
>A poster making members more hostile should be removed.
>>
Pronouns are confusing as fuck and introduce a lot of ambiguity. Why can't we campaign for not using them at all instead of making them neutral and even more potentially ambiguous?
>>
>>56339828
This is a lot less natural than the first.
Plus you've got to have this long discussion over a single example, nevermind if there are non-trivial implications later on.
People aren't going to see "he" and think "this obviously only applies to men".

>>56339842
>variable names are confusing as fuck and introduce a lot of ambiguity. Why can't we campaign for not using them at all instead of making them more succinct and even more potentially ambiguous?
>>
>>56339785
Just because withholding the cure for cancer isn't convenient for you doesn't mean it's wrong. You have this bizarre delusion that you could be in the same position as someone else and make a different decision.
>>
>>56339842
What's wrong with $_ ? ;_;
>>
>>56339827
I guess you don't get it but that's okay. You can read it again.
>>
>>56339806
>ok, so you mean that primitive types should be copied automatically? I'm thinking about that but I want to understand the ramifications of that kind of change, and I want to finish what I'm working on first.
Primitive types for one, yes.

>i thought this was where linear logic came from
Linear logic has been around a lot longer than linear types. It was only applied to programming through the Curry-Howard correspondence, i.e. Wadler looked at linear logic and used the correspondence to infer that it could be used as a type system. Little history lesson for you, I guess.

I just kept with the theme of the correspondence and used the term "intuitionistic" to mean, well, non-linear.
>>
>>56339808
if I print the circle it only prints the point but the radius is always 0. I have no idea why. Am I retarded? And how do I fix it?
typedef struct{
point mp;
double radius;
}circle;

circle c = {{1,1},4.0};
printf("(%d,%d) %d.\n",c.mp.x,c.mp.y,c.radius);
>>
>>56339702
It's an empty, passionless, and meaningless commit. Howzabout that? No one who actually spends time growing their skills by listening to recorded conferences, reading books, doing programming challenges and so on in their spare time wants to be greeted by "pls change s/he to they because muh feelings" by someone who has a portfolio full of little, meaningless webshit-tier "i added a footer!" commits. Sure, it's not hard to politely shut it down or just outright close and ignore it, but who the fuck wants to have that kind of ostentatious not-programming bullshit even suggested to them?
>>
>>56339863
You have this bizarre delusion that you have the mental capacity to understand what I'm saying.
>>
>>56339918
>>56339808
oh shit didn't mean to reply to your comment
>>
>>56339918
because you try to print double using %d
>>
>>56339918
Does explicitly setting the radius make a difference? i.e. c.radius = 4.0;
>>
>>56339946
oops, I guess I am retarded. Thanks buddy.
>>
>>56339806
>>56339917
I suppose copying is also possible in classical logic, or "classical types".
>>
File: 1409629137081.jpg (86KB, 636x571px) Image search: [Google]
1409629137081.jpg
86KB, 636x571px
alright /g/ I have a question for you:

>get first job out of college
>it's at a start up
>startup wants me to learn the ins and out of the code for the product that's already been released
>all code is in Node and all queries in sequelize
>no form of documentation or commenting
>have no idea other than just debugging and seeing what the fuck each function shits out

currently my plan was to make a software test plan and in the unit testing section detail each file and functions outputs, inputs, and what files they interact with.

is there any better ways? I initially was able to help with bugs and fixed a few but after that first week the bug reports dried out and the main dev shifted to working with a primary customer.
>>
>>56339917
yeah that's what i figured you mean but i don't know all of the buzzwords in cs (^:
>>
>>56339684
Fuck
>>
>>56340004
look at the code and figure out what it does that way
>>
>>56339139
You use double buffering. Render the map onto an offscreen buffer then flip it with the screen buffer.
>>
I am very tired and it is early evening.
Instead of playing vidya, I still want to learn more about coding.
Right now Java is my priority due to some predicaments, but I am willing to read anything that is helping me to be a better coder.
What can the gentoomen advice me on
>>
>>56340004
don't you even know the language they are working with? How did you even get this job?
>>
>>56340143
"How to Win Friends & Influence People" by Dale Carnegie

>But anon, this has nothing to do with programming!

It's like metadata; it helps you with all aspects of your life that are related tangentially with programming, such as:
>getting a job
>dealing with clients, employees, or a boss
>persuading a stakeholder to spend money on a training or technology

Here's a PDF:
http://images.kw.com/docs/2/1/2/212345/1285134779158_htwfaip.pdf
>>
>>56340143

dpt will suggest the SICP meme.
>>
>>56338119
Currently, I'm trying in my head to think of a way to make a decent programming book that teaches you Java.

Modern non-shit Java, mind you.

I want to do it in a style reminiscent of Practical Common Lisp, but I want to have more games and stuff.

The problem is that you have to know quite a few concepts before you can make any non-shit game.

I was thinking about starting the first chapter off with the classic numbers guessing game (which means that when you later want to explain runtime complexity, binary search or similar, they have already seen the concepts in use, so they have concepts in their heads they can use to understand the new ones), and after that explain the basic concepts that I'd be using.

Then after walking the reader through the game (which would be a very simplified thing, with no classes or even methods outside of main), I'd tell them about java.util.Random, and have them make a rock-paper-scissors player, that just displays rock, paper or scissors.

They'd only need to know println, if, and random for that to work.
(pseudocode:
int which = random.nextInt(3);
if(which == 0) { out.println("rock");
else if(which == 1) { out.println("paper");
else out.println("scissors"); )

And then we can introduce arrays, lists and switches, and have them redo the programs to use those, etc.

But I can't think of simple and easy games that reinforce the very basic concepts of programming.

I'd like to write chapter 1 as a "how to install shit", 2 as a large chapter on basic language constructs, 3 on strings and formatting, 4 on methods, 5 on classes (introducing guis), and then I'm not even sure anymore.
>>
>>56340143
If you want to get good at Java, the following advice holds:
>Learn to read the javadocs at oracle, for they tell you a lot.
> Learn the difference between good and clever.
> Most of the standard ways of doing things are there for a reason.

Also, Sun/Oracle's learning trails are pretty good. Unfortunately there are not many good books on the subject. Objects First is shit, Java Actually is pretty good, but was last updated for Java 5, so it's ancient, etc.
>>
>>56338315
Lisps were here and they were laughing at you all the time.

>>56338659
Java 7 started a trend of Making Java Great Again. Basically it was an upgrade that made the language more ergonomic. Java 8 continued that trend, and it looks like we'll see more in Java 9.
>>
>>56340356
Anon, I said GOOD
>>
>>56340367
I know, which is why I thought it was strange you were mentioning Haskell, which is just Prolog for mathematicians.
>>
>>56340356
>Lisps were here and they were laughing at you all the time.

How does a lisp laugh?
H-h-h-h-h-h-h-h-h-h-h-h-
>>
>>56340283
>simple and easy games

Blackjack, Hangman, Mastermind, Tic Tac Toe, Sudoku
>>
>>56340434
(laugh :type :parenthetically)
>>
>>56340454
Sudoku is p=np materino.

Hangman and blackjack are pretty good ideas though. The others too.
>>
>>56340283
Why Java?
>>
>>56340469
>Sudoku is p=np materino.
For a single player game with no AI or board generation, it's basically just Tic Tac Toe with a larger board.
>>
>>56340489
Because I have yet to see good teaching material for Java. It's all shit and/or outdated.

>>56340512
https://en.wikipedia.org/wiki/Mathematics_of_Sudoku

np-complete my melaninically enriched friend.
>>
>>56340544
Well, Java is a shitty, outdated language.
>>
>>56340544
>melaninically enriched friend
UH?! SEXIST, and RACIST much?

>>56340434
I don't get it.
>>
>>56340544
>np-complete
It's not. Read your link:

>The general problem of **solving Sudoku puzzles** [...] is known to be NP-complete

Getting and validating input to let a human play Sudoku is P, specifically n^2
>>
>>56340283
>I'm trying in my head
Stop trying in your head. Nothing happens if it stays there.

If you want to write a book, you need to actually read books.
https://github.com/mlnorman/Intro-To-Java-Programming

Writing like you're a genius/the hot shit is fine if you're showing something new to people who have been in the rodeo before, but just from reading your post it sounds like you're just gonna rattle off things and say what they generally do with an overarching example code segment. This is the kind of shit Learn Python the Hard Way does and it's fucking terrible for anyone, let alone people who are new to programming in general.

Then, there's being able to explain your subject and explaining it well. I used Liang's book (in the link) for Java and while he explained things with enough technical detail and each chapter flowed properly, there's nothing human about it. There are no common analogies, there's no "boiling down," there's nothing that shows the reader how to put what they've learned into the grand scheme of programming, etc. A book that JUST lectures and goes "see it works because of this code snippet" is just as bad as a book that doesn't lecture at all.

There's a lot that goes into an educational book; it's not as simple as being in a classroom where you can compensate for misinterpretation or clarity issues on the fly.
>>
guys, I'm using haskell and I need to decode 4chan JSON
thing is, I've no idea what to do
hackage libs like aeson are weird
any ideas?
>>
Is it true that Haskell programmers are TOO smart to be employed?
>>
>>56340777
https://hackage.haskell.org/package/json-0.9.1/docs/Text-JSON.html

>>56340801
See you next thread anon!
>>
File: json aeson.png (25KB, 502x411px) Image search: [Google]
json aeson.png
25KB, 502x411px
>>56340777
>>56340818
Just checked, I was using aeson

It's honestly not that bad, here's what I had

You could do this with applicative notation instead, and save a lot of code duplication
>>
>licensed under le epic WTFPL xD
The unerring mark of a pedantic faggot.
>>
>>56340956
>it's real
cringe
>>
>>56340356
>Java 8 continued that trend

Streams are half-baked. Not entirely the fault of the Java dev team (since they are sort of hacked in), but still.

Optional is also meh-tier.
>>
People like to bang on about how premature optimization is the root of all evil, but why isn't applying the same rules to "premature abstraction" popular as well? Why is the latter acceptable but not the former?
>>
More progress on my theorem prover. I've managed to make the concrete syntax usable (i.e., polyadic binders, contextual alternatives, etc.; although the parser is still ugly).

I'm now working on understanding and implementing an elaboration algorithm per the 'Elaboration in Dependent Type Theory' paper (http://www.contrib.andrew.cmu.edu/~avigad/Papers/constr.pdf), which describes the one used in Lean.
>>
>>56338725
this
SJWs and /pol/ tards alike would shitpost nonstop over trivial bullshit, the CoC is there so that one doesn't have to whine about muh representation and the other can just be banned because there's nothing you can do with a /pol/tard.
>>
File: water best melon.jpg (474KB, 1619x1725px) Image search: [Google]
water best melon.jpg
474KB, 1619x1725px
>>56341008
>premature abstraction
>>
>>56341008
Example? "Premature abstraction" sounds like an alias for "poor planning," which certainly gets its due in criticism.
>>
>>56341008
Because by abstracting (even done incorrectly) they think they're doing something good because DRY.
One of the anons posted this link a few threads ago: https://mollyrocket.com/casey/stream_0019.html
I think the guy is right about doing a "earlier abstractions".
>>
>>56338708
Shut up fag, CoC with inductive and coinductive types is great. Sure, one could argue UTT is even better, although it's pretty much just CIC with hierarchical universes, and I'd agree, but saying that CoC is a fad is quite rude.
>>
File: 1467149596985.jpg (61KB, 501x434px) Image search: [Google]
1467149596985.jpg
61KB, 501x434px
why is akari bbs down [!!]
>>
>>56341101
uncasted malloc :^)
>>
File: asdfb.jpg (55KB, 440x960px) Image search: [Google]
asdfb.jpg
55KB, 440x960px
>>56340956
Why not just use MIT at that point?

All MIT says is:
>I created this. If you share this source code in its current state, leave my name on it.
>Don't blame me if something goes wrong when you're using it.

All it does it prevent you from being liable for anything, and pic related.
>>
>>56341176
>Why not just use MIT at that point?
Because I have to make a point of being nonconformist instead of just using a permissive, vetted license like MIT/BSD or Apache!
>>
>>56341101
It's back up.
I'm not sure what happened.
>>
>>56341101
>akari bbs
what
>>
Fairly good python guy here.
Post some python snippets and I'll tell you how to optimize and/or clean it up.
>>
Is C++ really as bad as everyone says?
>>
>>56341613
print("Hello World")
>>
>>56341613
>Python
>I'll tell you how to optimize

extern C
>>
>>56341569

It's supposed to be a replication of 4chan written in C using CGI.
>>
>>56341228
this.
look mom, I'm so edgy, I wrote "fuck copyright laws" in the "license" field! that showed 'em!
>>
Why do C++ programmers suddenly think typing
int x=42;

is terrible and you should use
auto x=42;

instead?
>>
>>56341693
Linguistic relativity. Language fanboys don't like feature X until THEIR language gets it.

That said, they're not wrong. Implicit typing is great.
>>
>>56341624
Nice meme
But IMO, single quotes > double quotes since it's less typing (no need to hit shift).

>>56341627
Doesn't actually happen a whole lot in the real world from what I've seen. If it's big data processing that's one thing, but then again if you get to the point where it's 90% C you might as well just go all the way and do 100% C.
>>
>>56341633
more like 2channel / the old 4chan bbs
>>
>>56341844

old BBS systems were nice. The internet has been ruined by Javascript.
>>
>>56341954
Didn't old BBS have their own clients?
>>
This is the binary search from K&R, when I make an array like
int b[] = {1, 3, 4, 6, 67, 88}

It works fine, but if I populate an array with a for loop, nothing happens in terminal.
I'm assuming there's something about arrays in C, I don't understand. I even took a nap, and still don't know what I'm doing wrong. Please help.

#include <stdio.h>

int binsearch(int x, int v[], int n)
{
int low, mid, high;
low = 0;
high = n-1;
while (low <= high)
{
mid = (low+high)/2;
if (x < v[mid])
high = mid+1;
else if (x > v[mid])
low = mid+1;
else // Found value.
return mid;
}
return -1; // No match found.
}

int main()
{
int a = 5;
int len = 10;
int b[len];
for(int i = 0; i < len; i++)
b[i] = i;
printf("%d\n", binsearch(a, b, len));
}
>>
>>56341717
I find C++ users to avoid stupid fanboyism and to generally be quite objective, which can't be said for all language communities
>>
>>56341693
They didn't have an option before.
>>
>>56342017
>passing array by value
wew lad
>>
>>56342017
>int for sizes

And that is, among many other things, why K&R is outdated garbage.
>>
>>56342017
Your mistake is trivial and within the loop.

Also please properly format your code:
#include <stdio.h>

int binsearch(int x, int v[], int n)
{
int low, high;
low = 0;
high = n-1;
while (low <= high)
{
int mid = (low+high)/2;
if (x < v[mid])
high = mid-1;
else if (x > v[mid])
low = mid+1;
else // Found value.
return mid;
}
return -1; // No match found.
}

int main()
{
int a = 5;
int len = 10;
int b[len];
for(int i = 0; i < len; i++)
b[i] = i;
printf("%d\n", binsearch(a, b, len));
}


>>56342071
It collapses down to a pointer
>>
>>56342124
Oops, accidentally fixed it in this version.
You can just run a diff now if you still can't find it.
>>
>>56341621
http://yosefk.com/c++fqa/defective.html
>>
>>56342017
>b[len]
Use malloc() for allocating a variable size Array.
b[10] should work.
>>
File: Selection_021.png (96KB, 846x888px) Image search: [Google]
Selection_021.png
96KB, 846x888px
>>56342124
I need to quit blindly following things, and use some common sense sometimes. Thanks, Anon.

>Also please properly format your code:
Sorry.
>>
Let's say I have some Haskell lists like this:

[[(1,a),(2,b)] | a <- [1..2], b <- [1..2]]
[[(1,a),(2,b),(3,c)] | a <- [1..3], b <- [1..3], c <- [1..3]]


and I want a function that will make one for an arbitrary number of tuples. How would I write this?
>>
File: Untitled.png (27KB, 628x447px) Image search: [Google]
Untitled.png
27KB, 628x447px
>>56338904
https://www.coursera.org/specializations/python

I just finished the second course on data structures. That guy seems to be really passionate about teaching and is good at explaining stuff in simple terms. It can be pretty slow-paced though because it's designed so that even middle-aged moms who don't know how computers work can follow along.

I come from a C background and went through the 7 weeks of courses in 1 day (watching videos on 2x speed). I mainly just wanted to learn the Python syntax and idioms.

Coming from a lower-level language, the expressive power of list comprehension was pretty fucking mind-blowing. Then I drew parallels to that weird Haskell syntax I've been seeing and it finally made sense what Haskell was doing.
>>
>>56342209
but the value is known during compilation, so it will be on stack, which is better
just like
    const size_t length = 20;
int array[length];
>>
File: 1471537085096.png (7KB, 220x165px) Image search: [Google]
1471537085096.png
7KB, 220x165px
>>56338119
When I figure out how to write a LookUpTable using constexpr in C++14 that fucking compiles, I will continue to rule the world over the simplefags who think AI begins and ends with Perceptrons.

Until then... I am becalmed in a sea of templates....
>>
>>56336880
>posted it on your shity Twitter account
lol wut?? if someone posted it on twitter it wasn't me but i don't remember if someone posted it on twitter
>>
>>56342233
is this like what you want?
replicateM n [1..n]

0 -> [[]]
1 -> [[1]]
2 -> [[1,1], [1,2], [2,1], [2,2]]
3 -> [[1,1,1 ...
>>
>>56341693
I don't, I think explicit typing is better since you can better tweak memory use. Auto really is for avoiding javaesque stuff like
Iterator<map<int,float>> iter = map.begin(); or whatever.
>>
>>56342357
Not quite. I'm looking for a function like:

Int -> [[(Int,Int)]]


It's for an n-queens solver. I want it to generate a list of lists of positions, so that in each sublist there's only one queen per column.
>>
>>56342298
Stop avatarfagging.
>>
>>56342637
I mean it looks like you're basically just indexing the result from >>56342357
>>
>>56342682
>>56342637
and in >>56342357

i'm pretty sure that replicateM n [1..n] is like this:

[ [a,b,c,d,...n] | a <- [1..n], b <- [1..n], ... ]
>>
Anyone here familiar with Xamarin? How does it compare to android studio/java?
>>
How's it coming along?

Also, why does sqlite not allow you to reorder table columns?
>>
>>56342682
I see what you mean. This worked:

map (zip [1..]) $ replicateM n [1..n]


Thanks.
>>
>>56341613
How do you do RPC with Python?

I have a small tk app that I run with a shortcut key from my desktop but it takes a while to load. Having it run continuously and the shortcut command just call it to show the window would be faster.
>>
>>56342713
I know you can reorder them with DB Browser, I dunno if you want to do it programmatically though.
>>
In C and C++, is there a performance cost associated with casting between different (u)int types, e.g. from uint16 to int32, or from int32 to int64?
>>
>>56342934
Basically, every time I add a field, I end up making a new table, copying everything over and dropping the old one.
>>
>>56342961
no
>>
>>56341613
I want to put "Hitler" in the text box for a polldaddy poll. This program allows you to submit a choice but I can't write anything in the other text box. How would I do that
import requests, re, json, time
requests.packages.urllib3.disable_warnings()

base_url = 'https://polldaddy.com/poll/'
redirect = ""

def vote_once(form, value):
c = requests.Session()
print c
print "^^^Session^^^"
time.sleep(5)
init = c.get(base_url + str(form) + "/", headers=redirect, verify=False)
print init.text
print "^^^init^^^"
time.sleep(5)
# Search for the data-vote JSON object
data = re.search("data-vote=\"(.*?)\"",init.text).group(1).replace('&quot;','"')
print data
print "^^^data1^^^"
time.sleep(5)
data = json.loads(data)
print data
print "^^^data2^^^"
time.sleep(5)
# Search for the hidden form value
pz = re.search("type='hidden' name='pz' value='(.*?)'",init.text).group(1)
# Build the GET url to vote
request = "https://polldaddy.com/vote.php?va=" + str(data['at']) + "&pt=0&r=0&p=" + str(form) + "&a=" + str(value) + "%2C&o=&t=" + str(data['t']) + "&token=" + str(data['n']) + "&pz=" + str(pz)
send = c.get(request, headers=redirect, verify=False)
return ('revoted' in send.url)

poll_id = 9302835
answer_id = 42422361
number_of_votes = 100

vote_once(poll_id, answer_id)
>>
>>56343040
Step 1 is to go back to /pol/
Will fill you in on the rest when you get there
>>
>>56338119
Alternative to visual studio for programming in visual basic, needs to have the drag and drop shit
>>
>>56342241
yeah, I do have a bit of experience on python (tried to learn it a while ago and just gave up due to being really busy with other stuff), but it did seem pretty straightforward and intuitive. I guess I'll give it another shot with these lectures.
>>
>>56342981
http://sqlitebrowser.org/

This thing rocks. Been using it at work to unfuck some heap of data that used to live in a nightmare excel sheet.

>>56343065
Hey now, people were shoehorning hitler into things way before the stormfag cabal was revived.
>>
>>56343065
literally has nothing to do with /pol/. Its a poll about who should perform at the super bowl
>>
So I'm on github and theres a french project I was thinking of translating to english this is what I plan on doing
>fork it
>makes the changes in a new branch
>make a pull request
could someone give me more information on how to do this?
>>
>>56343120
man git
>>
>>56342984
Thanks.
>>
>>56343040
Looks like you have to submit your "other" text in the "o" key.
I haven't tested if this works, but it should be something like:
import requests, re, json, time
requests.packages.urllib3.disable_warnings()

base_url = 'https://polldaddy.com/poll/'
redirect = ""

def vote_once(form, value):
c = requests.Session()
print c
print "^^^Session^^^"
time.sleep(5)
init = c.get('%s%s/' % (base_url, form), headers=redirect, verify=False)
print init.text
print "^^^init^^^"
time.sleep(5)
# Search for the data-vote JSON object
data = re.search("data-vote=\"(.*?)\"",init.text).group(1).replace('&quot;','"')
print data
print "^^^data1^^^"
time.sleep(5)
data = json.loads(data)
print data
print "^^^data2^^^"
time.sleep(5)
# Search for the hidden form value
pz = re.search("type='hidden' name='pz' value='(.*?)'",init.text).group(1)
# Build the GET url to vote
GET_args = {'va': data['at'],
'pt': 0,
'r': 0,
'p': form,
'a': str(value) + '%2C',
'o': 'Put your custom vote here',
't': data['t'],
'token': data['n'],
'pz': pz}
args_str = '&'.join('%s=%s' % (k, v) for k, v in GET_args.items()]
request = 'https://polldaddy.com/vote.php?%s' % args_str
send = c.get(request, headers=redirect, verify=False)
return ('revoted' in send.url)

poll_id = 9302835
answer_id = 42422361
number_of_votes = 100

vote_once(poll_id, answer_id)


Also I'd recommend pdb over print statements if the crap they're printing is that long.
>>
File: KbJ4rQ2.png (9KB, 640x480px) Image search: [Google]
KbJ4rQ2.png
9KB, 640x480px
How would you guys go about generating all Pythagorean Triple's who's sum is less than a thousand in Python?
>>
First assignment of the semester, teacher assumes we worked on classes and recursion last semester but we did not. I need some guidance making these three functions, the first is on recursion and the other two the teacher said to use classes. C++

[Code]
#include <iostream>
using namespace std;
//This program will test three functions capable of reading, adding,
//and printing 100-digit numbers.

// Do not change these function prototypes:
void readBig(int[]);
void printBig(int[]);
void addBig(int[], int[], int[]);

// This constant should be 100 when the program is finished.
const int MAX_DIGITS = 100;

//There should be no changes made to the main program when you turn it in.
int main()
{
// Declare the three numbers, the first, second and the sum:
int num1[MAX_DIGITS], num2[MAX_DIGITS], sum[MAX_DIGITS];
bool done = false;
char response;
while (not done)
{
cout << "Please enter a number up to "<<MAX_DIGITS<< " digits: ";
readBig(num1);
cout << "Please enter a number up to "<<MAX_DIGITS<< " digits: ";
readBig(num2);
addBig(num1, num2, sum);
printBig(num1);
cout << "\n+\n";
printBig(num2);
cout << "\n=\n";
printBig(sum);
cout << "\n";
cout <<"test again?";
cin>>response;
cin.ignore(900,'\n');
done = toupper(response)!='Y';
}
return 0;
}

//ReadBig will read a number as a string,
//It then converts each element of the string to an integer and stores it in an integer array.
//Finally, it reverses the elements of the array so that the ones digit is in element zero,
//the tens digit is in element 1, the hundreds digit is in element 2, etc.

//AddBig adds the corresponding digits of the first two arrays and stores the answer in the third.
//In a second loop, it performs the carry operation.

//PrintBig uses a while loop to skip leading zeros and then uses a for loop to print the number.
[/Code]
>>
>>56343440
>in Python
i wouldn't
>>
>>56343440
Why don't you link to the project euler problem in question?
>>
>>56339760
"They" is actually a valid gender-neutral pronoun that can refer to a single person. English is a really fucked up language.
>>
>>56340544
>>56340469
np complete doesn't mean impossible
plenty of algorithms solve sudoku really fast, so it's not really relevant that it's np complete
>>
>>56343568
I've actually solved it, but I used a brute force method that takes 0.5s, I know generating all Triple's is the way to go, I just don't entirely understand how to do it
>>
>>56340143
The Scheme Programming Language by Kent Dybvig
>>
I want to learn visual basic, what software do I get?
>>
>>56343605
http://www.mathblog.dk/pythagorean-triplets/
>>
>>56343637
>Brute Force
>Solution took 0 ms
>>56343605
>Python
>brute force method that takes 0.5s
>>
>>56338637

> O(N)

Make it O(log(N)) with an R-Tree.

The math is always simple.

The logic is simple, too; there's just a lot to be written.
>>
File: bs_michi021.jpg (75KB, 700x860px) Image search: [Google]
bs_michi021.jpg
75KB, 700x860px
Yo /dpt/, I have been studying java for about a year now and I am now trying to learn python. I know there are many ways to approach things with python but I am very used to using/creating java classes, interfaces, and methods.

For some reason I am under the impression that in python classes are not used as often as in java.

Here is what I would like some input on: I am going to go through some of my old java projects and rewrite them in python. I was thinking in the most basic way possible I would just rewrite each interface, class, and methods that are in the project into python interfaces, classes and functions. But I am beginning to think that this is ignorant and won't exactly help me understand the true differences between the two languages/


tl;dr: How should I go about rewriting java projects in python to learn the differences between the two language?
>>
>>56343684
>>Brute Force
>>Solution took 0 ms
Yeah, there's an upper bound of 1 million iterations. The answer he got was 200 * 375 iterations. If your programming language of choice can't do for (i = 0 -> 75000) in under 1ms it's literally shit desu. I bet python can do it too, that anon just messed something up.
>>
I don't know if it's the right place but I'll ask anyway: basically I host at home a raspberry pi Seedbox and when I'm not at home I'd like to see what's going on with it, so I was thinking about a Telegram bot which messages my number/username with the new address everytime the dynamic home ip address changes (basically every x minutes/hours checks what's the outside IP address via a website or whatever). Is it possible doing a thing similiar this? Even if emails me it's fine.
>>
>>56343720
>python classes are not used as often as in java
No shit. Java requires classes to run while python classes are optional and you probably never need to use them.
>>
>>56343720
Yeah don't try to shoehorn object oriented principles into a non-object oriented language like python. You'll write bad code and learn less. If you're gonna learn python, learn it the python way.
>>
>>56343767
>>56343775
aight thanks.
>>
>>56343636
>I want to learn visual basic
No, you don't.

Learn C# instead. It's a far superior language for the .NET framework.
>>
>>56343908
They both are the same things.
>>
>>56343908
whats the learning curve like, is it also drag and drop and what software should I use to tdo it?
>>
>>56342124
His code is properly formated, it's the 4chan that fucks it up.

>>56342071
Turd

>>56342095
This is actually a good advice. People should start using size_t more.
>>
>>56342209
b[len] works as well.
>>
>>56343944
>whats the learning curve like
C# is probably the best beginning language right now next to Python.

>is it also drag and drop
If you're referring to creating GUIs, yes.

You're looking for Visual Studio 2015 Community.
>>
>>56343944
Bit steeper than VB, the dragon drop stuff you're talking about is the windows forms editor and yes it's exactly the same for C#, and you should be using visual studio 2015.
>>
>>56343720
python is trash, everything about python is trash, including its OOP implementation, and its users are retarded, most people who use python just use it for the most simple scripts and rudimentary "programs"
>>
>>56344021
I prefer to live in world with python scripts that in a world with bash scripts.
>>
>>56343977
>>56343979
thanks guys I'll learn c# instead also is visual studio lightweight enough to use on an x220?
>>
>>56344021
ah, but I plan on getting into tensorflow shit, is that just scripts and importing modules?
>>
>>56344099
>thanks guys I'll learn c# instead also is visual studio lightweight enough to use on an x220?
I don't know what an x220 is but visual studio is the least lightweight IDE there is.
>>
Needs to store a password for 1 session only in VB6. Session.Password = "Pass" stores it even when the application is closed.

Any ideas?
>>
>>56344099
Depends on how autistic you are.

First time startups are going to take a minute or so depending on what plugins you install, given that the x220 is a 5400 rpm HDD.

It's not like you start up your IDE more than a few times in one day, though.

Just note that Visual Studio is NOT lightweight; it's a full-featured IDE, but also gives you the best dev experience for those languages, so it's a tradeoff.
>>
>Python is trash

Then why does Google use Python a lot?
>>
>>56340647
You don't actually get anything done if you don't plan things out first.
My problem is not that I don't have any Java-books to read.
Or that I don't have good books to read either.

The style that I would be going for would be that of PCL, not just rattling off things.
I like that it starts with an example, and then shows the underpinnings afterwards. Especially early on, I see no reason to just start with "This is a method", because they won't have anything to connect that information too. And that's how humans learn, you build knowledge on top of other knowledge.

I've taught for a mere 2 years, so my data is not that extensive, but it's pretty clear that giving people examples, avoiding being clever, etc. helps more than trying to use the most difficult words that you can think of to sound smart.
>>
>>56344155
>implying google are competent
>>
What is the point of dynamic linking? Looks like it caused more problems than it solved and the "it saves memory" angle becomes increasingly irrelevant every day
>>
>>56344118
yes, rather than programming you can kind of think of it more as using a piece of software, and you're using python to control the software
>>
>>56341008
Because insecure people want to hold on to their magic wand that lets it look like they're doing things.

Just like how people still think that static compile time declared types (and not inferred like in Haskell) are safer than runtime typing, and also want you to write tests before code, even if that goes against the idea of exploratory programming, which they're also for.

I call it Voodoo programming, where people follow the magic recipes that makes their programs great again, without having a single fucking clue about the principles behind those magic recipes. It's all just black magic.
>>
>>56344151
is there a more lightweight IDE just to use for c# on my laptop
>>
[!!]
>>
>>56344195
>still think that static compile time declared types (and not inferred like in Haskell) are safer than runtime typing
It is safer.
>>
can you write functions within functions in c?
>>
>>56344214
In non standard C yes. But it's useless.
>>
>>56344202
>tripcodes are coming in the next update!
why
>>
>>56344226
is it really non standard? and it's not useless at all it's useful for writing one-time-use utility functions without cluttering the source code and shitting up the namespace. but i don't use it because C++ doesn't have it
>>
>>56344203

If you write unit tests, then the safety gains are so small as to be nonexistent. Can you tell me of any bug that the compiler caught that wouldn't have been caught with a basic test suite?
>>
>>56344253
>C++ doesn't have it
>what are lambdas
>>
>>56344198
>lightweight IDE
The latter contradicts the former.

C# is just like any other language; you can literally use any text editor you want and compile via command line if all you care about is a lightweight editor.
>>
>>56344239
It's a basic feature. You don't have to use it if you don't want to.

>>56344253
It's a GNU C extension, meaning you should be able to use it anywhere GCC is available, but people will hate you for it anyway.
>>
>>56344259
Tests can only prove the existence of bugs. Types can prove their absence.
>>
New thread: >>56344296
>>
>>56344263
kill yourself
>>
>>56344259
I don't want to work with people like you.
>>
>>56344198
VS doesn't use very much RAM at all once it's loaded.

What are your requirements?

What exactly do you consider lightweight? I mean, specific numbers of RAM, startup time, and disk space.
>>
>>56344226
really?
I wanted to write a a function that filters all chars found in string1 from string2
my thought was to write one function that filters just one char from a string, and then use that function to help me on my main goal
is it really that bad to create local funcs?
>>
>>56344292
Can you give me a clear example of a bug that static typing helps you against, that a simple unit test would not?

Just a simple, clear example.
>>
>>56344188
cool cool, I'm glad I posted. I really do feel stuck in my shallow hole of programming with java only experience, I don't even know where to begin climbing out.
>>
>>56344253
C is literally all about cluttering the source code and shitting up the namespace. Why would you write C and try to avoid those things?

>>56344335
Make a file, call it utilities, stick all utility functions in there. Big whoop.
>>
>>56344393
>Make a file, call it utilities, stick all utility functions in there. Big whoop.
and now the poor sap who has to look at it sees some random ass calls to functions which are nowhere to be found in that source file and he has to look through exponentially diverging layers and layers of dozens of header files to find each function definition
>>
>>56344453
Unless he uses Emacs, which has a function that goes to a function definition.
>>
>>56344478
""""text editor""""
>>
>>56344507
Emacs has many things.
As well as a function that goes to a function's definition in C-mode, it also has text editors. Like Vim, for example.
>>
>>56344349
No, you can't give an example of a bug that a test couldn't catch. Tests can only prove the existence of bugs. Types can prove their absence.
>>
>>56341092
It's still a fad.
>>
>>56338904
>Coursera
haha this is what Bret Ellis always sluts around for for his podcast, I'll check it out
Thread posts: 326
Thread images: 31


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.