[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
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: 32
File: 1422385664777_7.jpg (460 KB, 2500x1000) Image search: [Google]
1422385664777_7.jpg
460 KB, 2500x1000
Old /dpt/ at >>51913682

What are you working on?
>>
Would you rather be an expert programmer or a cute girl?
>>
>>51921282
cute girl
>then I can learn programming on my own

>>51921251
learning Java, hope to make a game that isn't shit one day ;_;
>>
>>51921251
Still going at in on rendering engine. Everything my professor taught in rendering was obsolete :,)
at least I know how it works.
>>
>>51921308
>obsolete
the web generation
>>
5th for D
>>
File: CWEVTYDW4AATZEl.png large.png (45 KB, 902x419) Image search: [Google]
CWEVTYDW4AATZEl.png large.png
45 KB, 902x419
>>51921308
>Everything my professor taught in rendering was obsolete :,)
>>
Finished my first small (<1 day) python project, need ideas for something else. Was inspired by another anon to have a program that emails me when someone replies to a post of mine on here I suppose.
>>
>>51921367
Are you unhappy with any software you use? Write a better alternative.
Do you find some topic interesting? Then learn a bit more about it.
>>
>tfw need to test a function that calls a database procedure that returns a random row.

I'm contemplating just calling it 100 times, putting the results in a set, and then making sure the set's size is greater than 2.
>>
>>51921429
what? Why don't you do the query for the random row, and then check if the row is part of the table?
>>
a targeting system to map an image to a coordinate system, find a target, and fire a laser pointer at it.

So far I've got a distance sensor out front to find a reference point, then some scripts to fire the servos based on the coordinate input.
>>
>>51921409
I really don't use much software, just firefox, urxvt, i3, vim, gcc, and python. :\
Since all I do is shitpost and program, it's hard to come up with ideas I suppose.
I could just extend the project I just completed for now
>>
You can linkify URLs without having the "Linkify URLs" settings enabled, /dpt/.

https://sys.4chan.org/%64erefer?url=www.youtube.com
>>
So i've just finished reading and learning all concepts from "C programming absolute beginners guide. I really loved it, but i'm not sure where to move on from this. What do i do or read next? http://www.amazon.co.uk/Programming-Absolute-Beginners-Guide-Guides/dp/0789751984/ref=sr_1_1?s=books&ie=UTF8&qid=1450401771&sr=1-1&keywords=C+programming+absolute+beginners+guide book source
>>
>>51921523
There doesn't seem to be much validation either.

https://sys.4chan.org/%64erefer?url=cuck
>>
What's the best book for getting started with computer graphics? This one seems well regarded but it's twenty years old.
>>
>>51921534
Good work, I'll trust you that that's a good resource to learn from;

You have two options right now pretty much, one is to keep learning, i.e. find another book that is more advanced and go through it, learning about data structures and algorithms, etc.

Or, you could come up with an idea for a project that you think you might be able to pull off, and get working on it.

A healthy balance between the two is always best, of course.
>>
>>51921584

I'm interested, too.
>>
>>51921604
The problem i'm having is, I can't find any books that are more advanced.. Like i've tried looking but they're all "beginning C" etc, and thank you haha
>>
>>51921458
That wouldn't test that it was actually randomly chosen rather than just getting a specific row every time. A function that just gets the first row would pass that test.
>>
>>51921584
For the fundamentals, Foley is fine. The math hasn't changed in the last couple of centuries and won't change in the next couple.

The practical details revolve around whatever hardware nVidia and AMD are shipping this quarter, so anything in book form is guaranteed to be out of date. You just have to scour the web for articles and papers.
>>
>>51921584
>>51921610
learnopengl.com
open.gl

"The Orange Book" for GLSL/programmable pipeline

I don't know a good intro book to OpenGL though. Sorry.
>>
>>51921697

Thanks, m8.
>>
>>51921584
>>51921610
Real-Time Rendering
http://www.amazon.com/gp/product/1568814240
>>
File: resizing.png (756 KB, 836x646) Image search: [Google]
resizing.png
756 KB, 836x646
Resizing is fun. I think it needs more sample areas, though. Bit of unusual artifacting.
>>
>>51921828
>That title
>>
>>51921855

It was originally gay picture shit, and this just stuck.
>>
>>51921496
Write something to scrape shitposts from 4chan and visualize data about them.
>>
File: gee.png (165 KB, 1366x768) Image search: [Google]
gee.png
165 KB, 1366x768
building a rude password generator in python from a list of adjectives and nouns I've compiled. yee.
>>
>>51921955
I don't want stuff to do with 4chan on my github tbf but I could do something similar to that. Maybe use Facebook or something. muh 'big data'
>>
https://sys.4chan.org/%61%75%74%68?act=%6c%6f%67%6f%75%74

What does this do, /g/?
>>
File: 0132545233.jpg (90 KB, 518x648) Image search: [Google]
0132545233.jpg
90 KB, 518x648
>>51921584
read this one

>>51921659
then test the function that selects random and see if they're different elements
>>
>>51922018
says I'm logged out of 4chan Pass
>>
>>51921986
Scratch the 4chan part and pull posts or something from somewhere else. Also for fun consider writing something that takes the scraped data and uses it to generate something fun. Generating markov chains is easy and can produce entertaining results.
>>
>>51922055
I'll look into it, thanks.
>>
File: wq.gif (998 KB, 250x251) Image search: [Google]
wq.gif
998 KB, 250x251
>>
What's a good book for Lambda calculus?
>>
>>51921584
I use OpenGL a lot so ask me questions.
>>
>>51922511
Is it possible to write good openGL in C without things like the glm, which is a C++ library?
>>
>>51922604
OpenGL is a C API.
>>
>>51922612
yeah, but what about the math libraries?
>>
>>51922604
Absolutely.

>>51922640
You don't absolutely need a math library, I haven't needed one at least.
>>
>>51922604
Do -you- think it's possible to write good code for a C library in C?
>>
>>51921344
What is this image supposed to convey?
That the person writing has an obsolete education?
>>
/g/, pleb here
Anyone experienced with timers on Java?
I'm doing a small program that moves a picture around in a set period of time

            new Timer(1000, new ActionListener()
{
public void actionPerformed(ActionEvent ae)

{
// Move the object randomly, subtract 75, so that the
// object should not meet the edges
label.setLocation(ran.nextInt(getWidth() - 75), ran.nextInt(getHeight() - 75));
}
}).start();

}


I have this, but I want to ask, how can I stop the timer after the .start()?
I tried creating a reference "timer" variable and then use timer.cancel(), but java won't let me do this.

Any thoughts?
>>
>>51922810
what package is Timer from?
>>
>>51922810
put ((Timer)ae.getSource()).stop(); in your handler for whatever condition you want it to stop
>>
>>51922810
it's because declaring a variable right there would use the result of .start(). move the .start() part to a separate line and call it on an object. for example
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
// Move the object randomly, subtract 75, so that the
// object should not meet the edges
label.setLocation(ran.nextInt(getWidth() - 75), ran.nextInt(getHeight() - 75));
}
});
timer.start();
>>
>>51921251

^faverage

Nobody? I'm on day three of this.
>>
>>51922927
>>51922894
Thanks anons
>>
>
Timer timer = new Timer

nice language idiot
>>
File: 1428128505942.png (7 KB, 377x330) Image search: [Google]
1428128505942.png
7 KB, 377x330
>>51921251
Hey guys, how do I sucessfully get my Daemon to sucessfully open up a X11 program? Basically I forked the Daemon and with the child process i want to execute mpv.
I tried
 execl("/usr/bin/mpv", "https://www.youtube.com/watch?v=vJQhDkpT5aY");


The program opens up in system monitor then exists.

what do?
>>
>>51923061
Now that's a language with explicit typing xDDDDDDDDD
>>
>>51923078
then exits*
>>
File: 2015-12-17_21-39-25.png (30 KB, 963x536) Image search: [Google]
2015-12-17_21-39-25.png
30 KB, 963x536
I've taken my C# knowledge to the N E X T L E V E L
>>
>>51923061
How do you propose objects are initialised?
>>
SFML vs SDL, which do I use? I can't find any good advice on the internet.
>>
>>51922018
> What does this do, /g/?
It's just a urlencoded version of
> https://sys.4chan.org/auth?act=logout
>>
>>51923061
Timer *timer = (Timer *) malloc(sizeof(Timer))


nice language, retard
>>
>>51923133
You won't find any good advice here either.
There's one autist here who unironically suggests you should reimplement your own SDL on every platform you intend to support.
>>
(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer(timer())))))))))))))))))))


NICE LANGUAGE RETARD
>>
/** Takes a word and scrambles it*/
static String randomizeWord( String word ){

Random rng = new Random();
String randomized = "";
int indexes[] = new int[word.length()];

// fill indexes array
for( int i=0; i<word.length(); i++ )
indexes[i] = i;

// fisher-yates array shuffle
int index, temp;
for( int i = indexes.length-1; i>0; i-- ){
index = rng.nextInt(i + 1);
temp = indexes[index];
indexes[index] = indexes[i];
indexes[i] = temp;
}
// add indexes array to randomized string
for( int i=0; i<indexes.length; i++ )
randomized += word.charAt(indexes[i]);

return randomized;
}


Can someone rate this code, if you saw it in a professional environment what would you think of it?
>>
>>51923061
thanks
>>
>>51923158
SPACES BETWEEN OPERATORS
>>
>>51923155
Fuck off. If you don't understand what SDL is doing you shouldn't use it. You should write your own implementation for a platform of your choice first. If you're lazy then fall back to SDL on other platforms instead of learning how to port, but still, it's literally less than 6 hours to re-implement everything you'd reasonably use SDL for yourself.
>>
>>51923137
>casting malloc

timer = time.Timer()



>>51923133
I spent a couple months with SDL, it's pretty simple and works pretty well.
>>
>>51923158
/** timer timer timer timer timer timer*/
timer timer timer( timer timer ){

timer timer = timer timer();
timer timer = "";
timer timer[] = timer timer[timer.timer()];

// timer timer timer
timer( timer timer=timer; timer<timer.timer(); timer++ )
timer[timer] = timer;

// timer-timer timer timer
timer timer, timer;
timer( timer timer = timer.timer-timer; timer>timer; timer-- ){
timer = timer.timer(timer + timer);
timer = timer[timer];
timer[timer] = timer[timer];
timer[timer] = timer;
}
// timer timer timer timer timer timer
timer( timer timer=timer; timer<timer.timer; timer++ )
timer += timer.timer(timer[timer]);

timer timer;
}


nice fucking language retard
>>
>>51923109

>2015
>WinForms

Why?
>>
>>51923185
There he is.
>>
File: 1440822008841.jpg (34 KB, 710x720) Image search: [Google]
1440822008841.jpg
34 KB, 710x720
Stop bullying Java
>>
>>51923189
>>casting malloc

Maybe it's spooples.
>>
>>51923190
i like this meme
>>
>>51923197
what's that guy's deal?
>>
>>51922511
Why is OpenGL so fucking complicated? This is not like my CLI toy programs.
>>
>>51923210
>spooples
fuck you lmao

Fuck spooples though. Why do I have to cast malloc to be compatible with spooples? It's no longer a superset of C. >:(
>>
>>51923133
For what purpose? SFML is window management plus a babby-mode rendering API built on top of OpenGL. SDL is window management plus a babby-mode rendering API built on top of the platform's native image-blit functionality.

If you're targeting a weak platform which is too slow for software rendering and whose video hardware is limited to image blits, use SDL. Otherwise use SDL for the window management and either software or OpenGL for rendering.

SFML has no purpose. It is a solution in search of a problem.
>>
>>51923219
He's autistic and probably doesn't even use the standard libraries afforded by his programming language spec because " If you don't understand what it's doing you shouldn't use it."
>>
>>51923231
>Why do I have to cast malloc to be compatible with spooples?

Because it doesn't auto-magically cast pointers like C.
>>
>>51923196
need to jazz up the old hello world program
>>
>>51923245
And it would fuck up other language features if it did that, right?
>>
>>51923231
Casting the return value of malloc is good programming practice, even in ANSI C.

You should also be casting your frees.
>>
>>51923237
Are you serious? Are you seriously encouraging people to use libraries they don't fully understand?

There is nothing wrong with using other people's code. But you should be able to write it yourself, too. Otherwise you're just a code monkey.
>>
>>51923229
Video hardware is complicated, cross-platform and efficient access to video hardware even more so.
>>
>>51923248

But why not WPF?
>>
>>51923256
I guess I should implement Linux before I use it.
>>
>>51923251

C++ is such a clusterfuck that I wouldn't doubt it.
>>
>>51923254
>casting frees
Not this cuck again.
>>
>>51923256
>Are you serious? Are you seriously encouraging people to use libraries they don't fully understand?

Not GP, but do you ever get anything done? Or are you fooling yourself about how "fully" you understand the libraries you're using?

My money's on the latter.
>>
>>51923251
Because sepooples a shit.

>>51923256
>There is nothing wrong with using other people's code. But you should be able to write it yourself, too. Otherwise you're just a code monkey.
Sometimes, people just need to get work done.
You can reinvent the wheel on your own time, but you're never going to get anywhere if you insist on rewriting every fucking thing from scratch.
>>
>>51923137
Timer *timer = malloc(sizeof(*timer));

idiot
>>
>>51923127
FUNCTIONAL PROGRAMMING
open Lwt
open Lwt_unix
let timer time action = fun () ->
sleep time >>= fun () ->
return $ action ()
let start = async
let stop = cancel

(* In action *)
let t = timer 10. (fun () -> doSomething ())
start t
let t' = timer 5. (fun () -> stop t)
>>
>>51923237
yeah, he sure seems autistic
>>
>>51923263
Yes ideally you fucking should.
>>
>>51923266
Glad I stopped learning it tbf

>>51923276
>sizeof(*timer))
please
>>
>>51923158
I don't like that you omit optional braces from the short for loops just as a matter of principle. Makes it too easy for some other idiot to not realize the braces are missing and to think they're extending the code inside the for loop when they aren't.

Other than that, seems fine I guess, except when you're shuffling, the you have variables named "i", "index", "indexes", and "temp". given that "i" is short for index, 3 out of your 4 variables are named basically the same thing
>>
>>51923270
Again, there's nothing wrong with getting work done, but if push comes to shove, as a programmer you should understand how to write your own implementation of something if need be.

People like you are why we have web "programmers" who just copy paste code from a dozen libraries together and call it a day. People who can't write a line of Javascript without jQuery, or a line of Ruby if it's not on Rails.
>>
>>51923276
You're allocating space for a pointer to a Timer pointer, you dumb shit.
>>
>>51923158
avoid putting your variable declarations in a big chunk at the start, you should be declaring them as late as possible i.e. just before you use them
>>
>>51923290
>People like you

No, time constraints are the reason. You don't know shit, kid.
>>
>>51923297
Time constraints are why 90% of programmers are functionally retarded and couldn't re-implement 1/4 of their standard library themselves?
>>
>>51923290
Programmer time is expensive, hardware is not.
If it works, it works.
You can apply your hand-coded skills to your personal projects, but not everything requires you to reimplement malloc or other essential language idioms.
>>
>>51923311
Time constraints are the reason no one tries. Businesses are always constrained by time and that's why everything is shit.
>>
>>51923316
>Programmer time is expensive, hardware is not.
Guess I shouldn't read the internet 2 hours a day at work

oh well
>>
>>51923319
Yeah, nobody should bother doing anything unless they write their own operating system, or make their own computer from handmade PCBs.

Hey faggot, why don't you invent the universe first before you even think of pressing keys on a computer?
>>
>>51923335
"If you wish to print a string, you must first bake a pie" - Neil DeGrass Tyson
>>
>>51923348
"DUDE SPACE" - steve hawkin
>>
'george bush' - mercedes benz
>>
File: 1426557259961.jpg (20 KB, 267x179) Image search: [Google]
1426557259961.jpg
20 KB, 267x179
>tfw math major
>be forced to take some shitty programming classes
>need to keep gpa high so cheat all semester because fuck programming
>mfw answering the "computer science ethics" quiz
>>
"timer" - timer
>>
>>51923335
>Hey faggot, why don't you invent the universe first before you even think of pressing keys on a computer?

I did.
>>
>>51923398
>came all the way to /g/dpt to post this
>>
>>51923287
>I don't like that you omit optional braces from the short for loops just as a matter of principle

I don't want to agree with you, but I think I have to. Who remembers this?

hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
hashOut.length = SSL_SHA1_DIGEST_LEN;
if ((err = SSLFreeBuffer(&hashCtx)) != 0)
goto fail;
if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail; /* MISTAKE! THIS LINE SHOULD NOT BE HERE */
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;

err = sslRawVerify(...);
>>
File: ksp announced for iOS.gif (965 KB, 450x191) Image search: [Google]
ksp announced for iOS.gif
965 KB, 450x191
>>51923446
>>
>>51923290
>Again, there's nothing wrong with getting work done, but if push comes to shove, as a programmer you should understand how to write your own implementation of something if need be.

That's pretty much bullshit. You should understand, conceptually, what's going on under the covers, so that you can avoid "shooting yourself in the foot". However, by far, the people creating the most REAL VALUE are people who are best making use of existing frameworks.

This prideful obsession with "muh understanding" is just alpha-geek bullshit. You need maybe one guy like that on a team of 20 engineers.

>People like you are why we have web "programmers"

Why are you being such a complete douche?

Can you understand that it's possible for someone to disagree with you without them being stupid? That there's more gradiation to it than "1337 low level dude" and "retard copy/paste web developer"?

People like you are why software engineering is such a shitty career. Arbitrary personal opinion is taken as truth, and it's assumed that anyone who disagrees is an idiot.
>>
>>51923446
There's nothing you can do to prevent typos. Hundreds of wasted lines spent on putting extra braces pushes real code off the screen which is much more likely to cause a bug.
>>
>>51923498
Is there any reason why that entire structure can't be a single chained OR statement?
>>
>>51923498

Oh God, another extreme extrapolation argument.

Jesus, you fucks are so irritating. I need to go back to school for something else to get away from your kind.

Sigh.

>There's nothing you can do to prevent typos.

It's not about the typo. It's about the fact that, had the statement been put in braces, the duplicate code WOULD HAVE HAD NO EFFECT.

> Hundreds of wasted lines spent on putting extra braces pushes real code off the screen which is much more likely to cause a bug.

Sigh. It's not 1997. If you're writing functions so long that some vertical space is obfuscating their behavior, then maybe you should reconsider what you're doing.
>>
>>51923513
It would be very messy and the || would span multiple lines.
The coding style they used is common and effective unless you make a stupid typo.
>>
>>51923513

Maybe they don't think you can count on short-circuit logic?

On an unrelated note,

>these captchas
>select all street names
>select all the fucking street names for the 50th time today
>nope, try again
>>
>>51923446

BTW, personally, I would have written this code as:

hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
hashOut.length = SSL_SHA1_DIGEST_LEN;
if ((err = SSLFreeBuffer(&hashCtx)) != 0)
goto fail;

if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)
goto fail;

if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)
goto fail;

if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;

if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;

goto fail; /* MISTAKE! THIS LINE SHOULD NOT BE HERE */
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;

err = sslRawVerify(...);
>>
>>51923616
You should be writing it like this.
hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
hashOut.length = SSL_SHA1_DIGEST_LEN;
if ((err = SSLFreeBuffer(&hashCtx)) != 0) goto fail;
if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0) goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0) goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail;
goto fail; /* MISTAKE! THIS LINE SHOULD NOT BE HERE */
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) goto fail;

err = sslRawVerify(...);
>>
hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
hashOut.length = SSL_SHA1_DIGEST_LEN;
if (SSLFreeBuffer(&hashCtx) != 0 ||
ReadyHash(&SSLHashSHA1, &hashCtx) != 0 ||
SSLHashSHA1.update(&hashCtx, &clientRandom) != 0 ||
SSLHashSHA1.update(&hashCtx, &serverRandom) != 0 ||
SSLHashSHA1.update(&hashCtx, &signedParams) != 0 ||
SSLHashSHA1.final(&hashCtx, &hashOut) != 0) {
goto fail;
}

err = sslRawVerify(...);

idiots
>>
File: Linus.jpg (15 KB, 234x298) Image search: [Google]
Linus.jpg
15 KB, 234x298
!= 0
>>
>>51923661

Why are you terrified of vertical whitespace?

Also, you're still exactly as susceptible to a double-pasted "goto fail;" tacked on at the end.

if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail; goto fail;


It's not going to stand out, since the completely varied line lengths obscure it.

>>51923689

That should be fine. I think most people find that really ugly and/or confusing.

http://stackoverflow.com/questions/628526/is-short-circuiting-boolean-operators-mandated-in-c-c-and-evaluation-order

Unless, of course, it's C++, and those aren't returning instrinsics, and someone overloaded ||, which would be awesome.
>>
>>51923689
You're not storing the error code anywhere.

And, yes, that does actually matter.
>>
>>51923765
true
>>
>>51923728

Does "!= 0" prevent getting a "did you mean comparison rather than assignment?" warning?

i.e. the compiler thinks

(err = SSLHashSHA1.update(&hashCtx, &signedParams))


was supposed to be
(err == SSLHashSHA1.update(&hashCtx, &signedParams))
>>
>>51923798
If it's in front of an if, yeah.
>>
>>51923820

You mean like in the example we're discussing?
>>
>>51923798
No, just putting the assignment inside an extra pair of parens should get rid of that warning.

!= 0 at the end of a test is completely redundant in C, but certain misguided individuals consider it good style.
>>
>>51923852
Not everyone knows about that evaluation trick where you can simply do
while (1)
>>
>>51923229
It interfaces with the driver, which interfaces with the graphics hardware, which is pretty complicated.
However, to get a context up and running is trivial, requiring only a couple function calls.
I think it seems complicated because of all the state you have to keep track of.
Do you have code to post?
Post it.
>>
>>51923877
Pretty sure everybody knows about that one.
>>
Does time.sleep() in Python pause the entire interpreter or just the execution of that function?
>>
>>51923078
Maybe your DISPLAY environment variable isn't set
>>
>>51924235
It suspends the current thread. If you dont know what that is, you only have one thread and it will pause your whole program.
>>
>>51924285
Neat, thanks. If python has easy multithreading I might do that instead of checking the time every single second. (My program does different tasks at certain times daily, I don't want to check the time every second ykno)
>>
>>51924323
>My program does different tasks at certain times daily
have you considered cron?
>>
>>51924367
Never heard of it, will look into it, thanks!
>>
>>51924367
>have you considered cron?
She might be using Windows, you insensitive clod.
>>
>>51924391
I'm a white, straight, cis male on Arch Linux
>>
File: chloe-awkward.jpg (67 KB, 244x233) Image search: [Google]
chloe-awkward.jpg
67 KB, 244x233
>>51924414
>>
>>51924414
You're literally a walking meme. Congratulations.
>>
>>51924493
:%)
>>
>>51924493
A normal person is not a meme.
>>
File: advent tree.jpg (120 KB, 697x647) Image search: [Google]
advent tree.jpg
120 KB, 697x647
>today's puzzle is conway's game of life
come on AoC
>>
This function counts the number of times each element of each list appears in a list, as long as the list is composed of things that can be ordered.
elemCount :: Ord a => [a] -> [(a, Int)]
elemCount s = map (\x->(head x, length x)) (group (sort s))
>>
>>51923319
>being an enterprise wageslave
yup, that's a codemonkey
>>
I'm feeling pretty bored with programming /g/.

What projects could I do to get the spark back?
>>
>>51924777
rewrite the linux kernel in haskell
>>
>>51924777
rewrite the entire c++ standard library in haskell
>>
>>51924777
write a tool that emails you when someone replies to your 4chan post
>>
>>51924777
rewrite haskell in haskell
>>
>>51921429
select * from table order by random() limit 1;
>>
Why does docker for OSX have endless problems
>>
>>51923554
>the duplicate code WOULD HAVE HAD NO EFFECT.
but a DIFFERENT typo could have caused damage regardless of the braces
>>
>>51924581
Whats problem with that? Game of life is awesome. I quite like AoC, learning rust with it.
>>
>>51922810
POO
IN
LOO
>>
>>51924882
Just thought they'd be a bit creative, even an alternate take on GoL

Anyways, this is the best I could do with my code:

import copy
data=open("Advent18.txt").read().split("\n")

lights=[]
for a,i in enumerate(data):
lights.append([])
for b,j in enumerate(i):
lights[a].append(j=='#')

def calcNeighbours(x, y):
neigh=sum(((0 <= i < 100) and (0 <= j < 100) and lights[i][j])
for i in range(x-1,x+2) for j in range(y-1,y+2) if (i,j)!=(x,y))

return ((lights[x][y] and neigh==2) or neigh==3)

for i in range(100):
newList=copy.deepcopy(lights)
for x,c in enumerate(newList):
for y,d in enumerate(c):
newList[x][y]=calcNeighbours(x, y)

lights=copy.deepcopy(newList)
lights[0][0]=1
lights[0][99]=1
lights[99][0]=1
lights[99][99]=1

print sum(sum(i) for i in lights)
>>
>>51924882
>rust
why
>>
>>51924973
I find it fun and i was bored. Its not something im learning for real life xD
>>
>>51923513
It should be, but they probably think writing "goto fail" multiple times is "more readable" or something.
>>
So what's up with CS students that are actually decent programmers, but don't know a lick of math?

Like, I'm more of a math oriented guy, and I had to put up with people asking me how to solve a particular integral that wasn't giving a good result only to know they were using wrong variables due to poor understanding of the problem

and the biggest sin was a guy asking me how was he supposed to know a point wasn't inside the circle

like ffs basic pythagorean theorem shit and here he is in a CS degree
>>
File: dd.jpg (1 MB, 1080x1920) Image search: [Google]
dd.jpg
1 MB, 1080x1920
Any hipster languages that aren't Swift I can pick up?
>>
File: docker-logo2.png (78 KB, 500x500) Image search: [Google]
docker-logo2.png
78 KB, 500x500
How do i start a server with docker? This is what i tried


0 ~ $ docker run -d -p 8083:8083 -t -i echo_server
0 ~ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f9381111d1a8 echo_server "./echo_server 8083" 27 seconds ago Up 26 seconds 0.0.0.0:8083->8083/tcp dreamy_pike
0 ~ $ curl http://0.0.0.0:8083
curl: (7) Failed connect to 0.0.0.0:8083; Connection refused

Any advice?
>>
>>51925118
I found that people who are good at math tend to be good at programming as well. While you can be good at programming without math it's much more rare, at least if its non web stuff.
Once i was asked how to draw a graph of x=3 on CS ....
>>
>>51925118
You don't need heavy math background for most programming related work unless you're in compression, cryptography or physics simulations.
>>
>>51923930
Completely beginner example, but I can just tell that it gets complicated quick.

http://pastie.org/private/xdleycncyzpykwameg0ga
>>
>>51925168
Not heavy math but some light math is certanly helpful, helps you think. Discrete math some statistics and probability and linear algebra are a must at very least to understand how stuff works. Anyhow he is talking about simple stuff like integrals... Not really heavy math.
>>
>>51924963
refined a bit. for loops now made for purpose reducing enumerates, also easier to switch from part 1 to part 2:

import copy
data=open("Advent18.txt").read().split("\n")

lights=[]
for a,i in enumerate(data):
lights.append([])
for j in i:
lights[a].append(j=='#')
newList=copy.deepcopy(lights)

def calcNeighbours(x, y):
neigh=sum(((0 <= i < 100) and (0 <= j < 100) and lights[i][j])
for i in range(x-1,x+2) for j in range(y-1,y+2) if (i,j)!=(x,y))

return ((lights[x][y] and neigh==2) or neigh==3)

for i in range(100):
for x in range(100):
for y in range(100):
newList[x][y]=calcNeighbours(x, y)

lights=copy.deepcopy(newList)

#uncomment the following for part 2
#lights[0][0],lights[0][99],lights[99][0],lights[99][99]=1,1,1,1

print sum(sum(i) for i in lights)


Not sure if I can make this any better
>>
>>51925233
the required math can be learned, stop acting like you need a math degree to program
>>
>>51923446
I'd write it like this. They were asking for it writing the same shit over and over again:
hashOut.data = hashes + SSL_MD5_DIGEST_LEN;
hashOut.length = SSL_SHA1_DIGEST_LEN;
if ((err = SSLFreeBuffer(&hashCtx))
|| (err = ReadyHash(&SSLHashSHA1, &hashCtx))
|| (err = SSLHashSHA1.update(&hashCtx, &clientRandom))
|| (err = SSLHashSHA1.update(&hashCtx, &serverRandom))
|| (err = SSLHashSHA1.update(&hashCtx, &signedParams))
|| (err = SSLHashSHA1.final(&hashCtx, &hashOut))) {
goto fail;
}
err = sslRawVerify(...);
>>
>>51925244
I didn't say that, i said it's very helpful, especially if you like to know how stuff works. Besides im not advocating math degree, just knowledge of those subjects.
>>
>>51925168

You don't need *any* math background for most programming related work.

Most programming related work is taking data from A, filtering it, combining it, and presenting it at B.

I was a math minor. I've never used anything more advanced than basic algebra, and I've done some unusual stuff. I absolutely encourage mathematics, as it will fundamentally shift how you think about things (calculus being an obvious one), but if you just want to be a run of the mill programmer, you really don't need any meaningful math at all.

(that said, all programming actually is math, but you don't need to know that)
>>
>>51924963
>>51925239
>python

get out
>>
File: aww.jpg (724 KB, 3360x2100) Image search: [Google]
aww.jpg
724 KB, 3360x2100
Open source calculator programmed on Swift, r8 h8 gib advice etc
>>
>>51925276
This is much better. It's shorter, more readable, and has less duplication.
>>
>>51925308
>anything other than python, ruby or haskell
>>
>>51925310
BUILD WALL
>>
>>51925310
>Open source calculator
>saying 'open source' as if it's a feature
>not even providing source
nice work though, post source

>>51925308
>implying python isn't comfy and easy to use
I was a C tard for so long and did the same thing you did, then I learned python a few days ago and I love it for the most part. It's easymode and definitely should never be someone's first language, but it's great.
>>
>>51925310
Does it have good accuracy? If I typed 1/3 it'll give me .33333.., yes? But if I multiply that by 3 will I get 1 or .9999999...?
>>
>>51925310
Thanks but I'll stick with my graphic slider rule.
>>
File: fuggg.jpg (98 KB, 1146x1530) Image search: [Google]
fuggg.jpg
98 KB, 1146x1530
>>51925344
thx, I will post when I finish it, need to fix some bugs

>>51925352
did I dun goof? I will try to fix it though

>>51925360
>>51925329
k
>>
>>51924574

>Arch
>Normal
>>
>>51925422

checked and seconded.
>>
>>51925422
it's /g/
pretty normal

>>51925445
hi gtp
>>
File: yap07py.webm (3 MB, 720x404) Image search: [Google]
yap07py.webm
3 MB, 720x404
Ask your beloved programming literate anything.
>>
I think my favorite thing about dictionaries in Python (and other langs of course) is that they're like making a struct definition at run time. It's just the most pleasing thing.

send_time = dict(zip(['hour', 'minute'], argv[4].spit(':', 2)))

I just get really excited about that. Kinda gay.
>>
>>51925451
Ehhh.... even for /g/, I don't see too many arch users.
>>
>>51925497
It's not that cool.
You can make dictionaries in C.
>>
>>51925515
I guess since I only visit /dpt/ and /desktop/ (the latter especially) my idea of the usual is skewed.
>>
>>51925329
reminder that illegal immigration is infinitely better for the states than legal immigration
>>
>>51925484
When is it appropriate to use goto?
>>
>>51925517
>>(and other langs of course)
Stop being a fag just because I said Python
>>
>>51925517
Show me a C dictionary that can append arbitrary types at run-time.
>>
>>51925527
Not really.
Those illegal immigrants would get legitimate jobs and pay their taxes like everyone else if they weren't forced to get paid under the table.
>>
>>51925534
Error handling, usually.
Most of the times, you could probably write it better without goto.
>>
>>51925517
You can implement a dictionary in assembly or brainfuck, doesn't mean it's easy or convenient.
>>
>>51925451
>hi gtp

Howdy.
>>
File: GBzPEMQ.jpg (105 KB, 640x640) Image search: [Google]
GBzPEMQ.jpg
105 KB, 640x640
>>51925534
it's appropriate when

- You are compiling to C.
- to avoid redundant error handler/clean up code.
- Optimization.
>>
>>51925547
Unfortunately you can't categorize those types in Python ;-^)

>>51925564
Python isn't the only lang with easy dictionaries (cough JS, which is shit).

>>51925583
>- You are compiling to C.
Don't do this. LLVM was made for a reason.
>- to avoid redundant error handler/clean up code.
Error handlers are the only reason.
>- Optimization.
No.
>>
File: surround kek.gif (3 MB, 200x150) Image search: [Google]
surround kek.gif
3 MB, 200x150
>>51925555
an illegal immigrant doesn't pay taxes and doesn't receive welfare
their contribution to society is through production, which is far greater a contribution than participating in a system of shuffling around wealth

if the legal immigrant's income is lower than the average, he or she only dilutes the pool of welfare without contributing enough to offset it

by and large legal immigrants come for welfare, illegal immigrants come to work
>>
>>51925118
Some people characterize CS as an engineering discipline.
I have always said that it is more like carpentry.
It begins to get fucking real at VLSI, at which point it becomes engineering.
Take for example that OpenStack virtualization stuff, some of those devs are insane.
>>
/pol/ i said pls
>>
>>51925547

Just make a dictionary of a tagged union type. Done.
>>
>>51925658
sorry I'll go
I mean it is CURRENT_YEAR
>>
>>51925679
That's not arbitrary, types are known at compile time. Also, users would have to add their own types to the union.
>>
>>51925696
>hurr durr C doesn't have dynamic typing!!
Really bitch?
>>
File: 1437980846943.jpg (52 KB, 604x604) Image search: [Google]
1437980846943.jpg
52 KB, 604x604
>>51921302
>hope to make a game that isn't shit
>Java
>>
>>51925696
>users would have to add their own types to the union.

Oh no, how terrible.
>>
I literally have no idea what any of your replies mean. How to computer? Please teach.
>>
>>51925722
I'm not saying it's bad, I just thought that our conversation was all about how that wasn't necessary

>>51925713
>!!
>bitch?
Explain how you'd implement it, anon
>>
>>51925736
>I just thought that our conversation was all about how that wasn't necessary

Everything is necessary when you're on C.
>>
>>51925748
hence >>51925497

I come from C, started Python recently.
>>
>>51923196
What other options are there?
>>
>>51925761
>started Python recently

Enjoy your massive productivity boost.
>>
>>51925772
I have been. I spent a couple months making a very basic interpreted language in C a few months ago, I'm sure I could do it in a couple nights in Python.
Right now I'm just trying out all of this web stuff which is awesome too.
>>
What's the container's ip address?
>>
>>51925931

::1
>>
What's the most PRODUCTIVE language?
>>
>>51925966
depends on the field

(it's Python)
>>
>>51925986
writing a 2D game engine
maybe a scripting language on top of that
>>
>>51926002
C++
>>
>>51926011
>c++
>PRODUCTIVE
>c++
>useful when performance isn't nearly as important as productivity / usability
>>
>>51925120
learn Haskell. if it fits your definition of hipster
>>
Can someone help?

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <setjmp.h>

#define DECLARE
#define BEGIN
#define END
#define STACK
#define PROGRAM
#define PROCEDURE
#define JMP_BUF(x) jmp_buf x;
#define JMP(x) longjmp((x), 1);
#define SETJMP setjmp
#define INT int
#define IF if
#define GOTO_(x) goto _ ## x;
#define GOTO(line) GOTO_(line)
#define VOID void
#define RETURN return
#define MAIN main
#define _ (void)
#define INPUT getchar()
#define OUTPUT printf("%d ",
#define VECTOR(x) (sizeof((x)) / sizeof(*(x)))

INT
PROCEDURE MAIN(VOID)
{
STACK DECLARE INT C;
STACK DECLARE JMP_BUF(J)
STACK DECLARE INT P;
STACK DECLARE INT CN[5] = {0};
_100: BEGIN PROGRAM MAIN;
_110: *CN = INPUT;
_120: IF (C == EOF) GOTO (250)
_130: GOTO (140)
_131: GOTO (260)
_140: IF (C == ' ' || C == '\t' || C == '\n') { P = 1; if (!SETJMP(J)) GOTO (230) }
_150: IF (isalpha(C)) { P = 1 << 1; GOTO (190) }
_160: IF (isdigit(C)) { P = 3; GOTO (210) }
_170: _ (P = 4)[CN]++;
_180: GOTO (110)
_190: ++P[CN];
_200: GOTO (100)
_210: CN[P]++;
_220: GOTO (110)
_230: _ P[CN]++;
_240: GOTO (100)
_250: P = 0; GOTO (131)
_260: IF (*CN == VECTOR(CN)) GOTO (320)
_270: _ OUTPUT (P++)[CN]); JMP(J)
_320: RETURN 0;
_132: END PROGRAM MAIN;
}
>>
>>51926095
Are you the C+= guy? I've seen this before. Unless you just grabbed it from him for the meme.
>>
File: opening cutscenes in vlc.gif (2 MB, 260x260) Image search: [Google]
opening cutscenes in vlc.gif
2 MB, 260x260
>>51926095
>>
>>51926114
kek

gibe the original of that gif pls
>>
>>51926102
No and no, written from scratch. I guess C programmers enjoy similar things.
>>
File: 42315.jpg (39 KB, 300x309) Image search: [Google]
42315.jpg
39 KB, 300x309
>c++ data structures class
>missed the A mark by 5 points
>>
>>51926002
C#
>>
So I just finished my freshman programming course (scheme) and did really well. I want to code more and make some small games. What language would it be best to move to? I'm familiar with java as well
>>
>>51926331
>freshman programming course (scheme)
Fucking awesome.

Python is easy for small games if you like.
>>
This is the last time I'm posting about this, I promise.

Finished entirely my first python mini-project.
Takes this JSON file:
{
"sender": {
"email" : "[email protected]",
"password": "your-password"
},

"clients": [
{
"email": "[email protected]",
"query": "Client 1 Image Query",
"time" : "12:00"
},
{
"email": "[email protected]",
"query": "Client 2 Image Query",
"time" : "15:30"
}
]
}


and sends a different Google Image search result of the query to the client every day at their time.
Woo.
>>
>>51926331
java. try libgdx if you want to start with something simple. it's not that complex so you can easily grow out of it by replacing a little at a time with your own code.
>>
File: 6489.jpg (497 KB, 2560x1440) Image search: [Google]
6489.jpg
497 KB, 2560x1440
>>51925594
>No.
Yes. you need goto for state of art pre-decoding.
>>
I just sent 10 UDP packets and they all arrived so what the heck is the point of using bloated TCP? Literally a meme protocol.

Also, is this a good way to broadcast a message?

for iplast in range(1,255):
sock.sendto("blah blah".encode("utf-8"), ("192.168.1."+str(iplast), 8888))
>>
>>51926476
Enjoy your no error-checking
>>
>>51926507
UDP does error-checking faggot
>>
>>51926535
Sorry, it has error detection, but no way to resend a packet.
TCP is generally more reliable
>>
>>51926535
https://en.wikipedia.org/wiki/User_Datagram_Protocol#Reliability_and_congestion_control_solutions
>>
>>51926535
the client can never know whether or not they have received all packets, or in the correct order
nor can the server know the packets actually reached the client
>>
>spend non trivial amount of time making gvim suitable for java programming
>realize i'll literally never use it for anything but a tiny one class programme
>back to intellij
was fun tho
>>
>>51926562
>>51926579
Still does error checking
>>
Hope I can come up with some substantial project idea to complete this break tomorrow. I'd hate to waste all this free time.

night /dpt/
>>
>>51926634
sure, my point was it's a bad idea to use UDP for anything remotely important though
depending on the type of broadcast message you're sending, it would probably be a good idea to have the client respond with an acknowledgement package
>>
>>51923293
>>51923283
A very late reply, but you two idiots are wrong: it's done by the size of the thing pointed to by the variable.
>>
Anyone here worked with Swift 2.0?
I'm really conflicted about the language. I started off hating its guts, but I feel like I'm finally starting to either like it or at least hate it less.
>>
i'd tell you derps a UDP joke, but you probably wouldn't get it..
>>
>>51926819
yes. what does matter is the type of the value returned by the evaluation of the passed expression.

with int *x;

the type of value return by the expression (x) is pointer to int
the type of value return by the expression (*x) is int

thus sizeof(*x) is like sizeof(int), not sizeof(int*)

also, don't learn C, it's shit.
>>
>>51926639
Develop a mobile app based around some tiny nitpicking complaints of friends/family/roomies/whoever.
>>
>>51926879
there are no such complaints
>>
File: 1445511667448.gif (1 MB, 320x180) Image search: [Google]
1445511667448.gif
1 MB, 320x180
>>51926874
nice
>>
>>51926874
Just tell it again. We'll eventually get it, probably.
Thread replies: 255
Thread images: 32

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.