[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: 42
File: daily programming thread2.webm (2 MB, 600x338) Image search: [Google]
daily programming thread2.webm
2 MB, 600x338
old thread: >>55188975

What are you working on, /g/?
>>
>>55198250
>Posted before the bump limit
>Literal faggotry
Report this thread.
Do not post in this thread.
>>
Apparently I shouldn't compare strings with "==".

What should I use?
>>
>>55198284
AbstractComparitorFactoryBeanSingleton
>>
>>55198284
strcmp()
>>
>>55198284
gentoo
>>
>>55198297
fuck off pahjeet
>>55198300
this
>>55198302
meme
>>
>>55198282
You're in every dpt thread, first post. Fuck off you autistic retard.
>>
File: Denise_Milani_Wallpaper.jpg (118 KB, 1600x1200) Image search: [Google]
Denise_Milani_Wallpaper.jpg
118 KB, 1600x1200
//flags for the compilers
export CPFLAGS=$(python-config --cflags)
export LDPFLAGS=$(python-config --ldflags)
export CYFLAGS="$CPFLAGS $LDPFLAGS"

//test.pyx
//generate test.c and test_api.h with "cython -3 test.pyx"
cdef api void printHello():
print("Hello!")

//driver.c
//compile executable with "gcc $CYFLAGS -o driver driver.c" (optionally link with test.c if you wish, won't make a difference either way)
#include "test_api.h"

int main(int argc, char *argv[])
{
import_test();
printHello();

return 0;
}


Getting my info from here
http://docs.cython.org/src/userguide/external_C_code.html#using-cython-declarations-from-c
>>
>>55198389
*For anon that was asking for the code last thread
>>
>>55198250
10th for Go is best language
>>
Does /g/ like C#?
>>
>>55198473
yes
>>
>>55198473
No.
>>
>>55198473

I think it's pretty damned good.
>>
>>55198473
Yes
>>
>>55198473
yeah it's great for people who don't want to admit that they like java
>>
>>55198473
can you repeat the question?
>>
I have 3 python versions installed in linux mint bit I can't install pip for the last one I installed 3.5.1 and the package I need isn't working with the 3.4 version anyone knows how to solve this?
>>
File: macrovid - Copy.webm (259 KB, 366x206) Image search: [Google]
macrovid - Copy.webm
259 KB, 366x206
Is this pajeet tier?
>>
>>55198613
Your fields aren't even labelled
I know that the text field is for time but what's it measured in? Milliseconds? What if I want to do two things at the same time, like walking and clicking?
>>
>>55198591
IIRC, you can install pip from python itself.
as usual... google it
>>
Arch fucking died after updating packages, totally fucked itself.
Now installing Slackware, then going to work on anime Usenet shit.
>>
>>55198250
Continuing to work on my rtorrent import script; currently working on interactive mode. Pic related is the options set so far
>>
>>55198613
Yes.
>>
>>55198665
m8, this was your opportunity to switch to Gentoo
>>
>>55198473
I don't like some small autistic things, like ints can't be used for if statements, some expressions of Linq. But overall is pretty comfy.
>>55198250
Btw, in C# there's such a thing as "abstract interface", with that meaning that the interface can't be extended. (I need it just to wrap several interfaces).
>>
>>55198638

It's milliseconds, it actually says that the first time you run the program. I just already inputted a time and overwrote the initial text for the video.
>>
>>55198591didn't know that ktnx mate
>>
File: 3FA.jpg (91 KB, 736x957) Image search: [Google]
3FA.jpg
91 KB, 736x957
>>55198692
>in C# there's such a thing as "abstract interface"
That's supposed to be a question.
>>
File: ee2117c6c5.png (10 KB, 589x218) Image search: [Google]
ee2117c6c5.png
10 KB, 589x218
>>55198724
nvm, I used an abstract class instead.
>>
>>55198284
you can if your language isn't retarded and can overload operators
>>
File: 1464643883328.jpg (67 KB, 600x549) Image search: [Google]
1464643883328.jpg
67 KB, 600x549
Is there a good way to generate randomness in a ShaderLab shader?

All that I can find is

float2 noise = (frac(sin(dot(xy * _Time ,float2(12.9898,78.233)*2.0)) * 43758.5453));
return abs(noise.x + noise.y) * _staticBlend;

which seems WAY too computationally expensive, because you're having to a dot, sin, and frac function on every single pixel every single frame
>>
File: 1466544462190.jpg (50 KB, 469x428) Image search: [Google]
1466544462190.jpg
50 KB, 469x428
>>55198958
>>
>>55198969
What

Also, why is the thread so dead
>>
>>55198969
fuck off
>>
File: 485867.jpg (908 KB, 3840x2160) Image search: [Google]
485867.jpg
908 KB, 3840x2160
>>55198250
Is this the right way to do error handling in OpenSSL?

int ssl_shutdown(SSL *ssl_connection)
{
int rv, err;
ERR_clear_error();
rv = SSL_shutdown(ssl_connection);

if (rv == 0)
SSL_shutdown(ssl_connection);

if (rv < 0)
{
err = SSL_get_error(ssl_connection, rv);

if (err == SSL_ERROR_SSL)
fprintf(stderr, "%s\n", ERR_error_string(ERR_get_error(), NULL));

fprintf(stderr, "%s\n", SSL_state_string(ssl_connection));

return 1;
}

SSL_free(ssl_connection);
return 0;
}


The docs are really confusing.
What is the difference between
SSL_get_error
and
ERR_get_error
?
>>
>>55198958
dot() isn't expensive, though. I'm not sure about frac(), but I'd guess it too is cheap.
>>
>>55199327
What does dot do?
>>
>>55199338
Dot product
>>
>>55198924
And the funny thing, java strings already has overloaded operators. just not for ==

although in that case it would need another function to compare pointers.
>>
>>55198958
everyone uses that function for randomness. I doubt it gets any better than that for shaders.

>because you're having to a dot, sin, and frac function on every single pixel every single frame
well, it is good thing that the gpus are good at this thing then
>>
best free books/tutorials to read for a complete beginner to learn Java? Besides learn Java the hard way. I honestly don't have the like $25 for the book.
>>
File: Trying to learn.png (193 KB, 1280x800) Image search: [Google]
Trying to learn.png
193 KB, 1280x800
I'm trying to learn python.
>>
>>55199479
Rails is not Ruby, try /wdg/
>>
>>55199575
Thank you for the advice! Will do.
>>
>>55199524
Why Python 2, instead of 3?
>>
>>55198250
Why are weebs so autistic? Can't you like cartoons and not fucking go full retard???
>>
File: badRandom.png (3 MB, 1898x1384) Image search: [Google]
badRandom.png
3 MB, 1898x1384
>>55199417
But it's also not actually random
You get all these awful repeating patterns
>>
>>55199602
Don't most machines still mostly use python 2? I'm sure it's not a huge leap from 2 to 3 anyway. It's more of a hobby anyway. Maybe it'll turn into a side job one day.
>>
>>55199524
script, from_file, to_file = argv
Is that supposed to work? It doesn't for me. Also:

indata = open(from_file).read()
>>
>>55199633
that looks pretty good to me anon. those patters won't be noticable in actual programs.

you can always generate a random texture on cpu for each frame
>>
>>55199695
Nvm, it does. I don't like it, though. No error checking.
>>
>>55199701
Nah dude, the only reason that I mentioned the patterns is because they fade in and out and go diagonal one way and then the other and then horizontal and it's actually extremely nauseating, especially because I'm trying to do a barely-there static effect and I don't want to draw attention to it
>>
>>55199695
>>55199711

I'm not sure about most of this stuff. It usually takes me 20 minutes to fully understand each exercise. It's fun so far though. I can see why people enjoy it so much.
>>
>>55199724
instead of time, use a random float that comes from CPU maybe?
>>
>>55199771
RdRand isn't portable.
>>
>>55199771
noone is talking about RdRand
>>
One of the interns at my job has a stallman avatar on slack and posted a gimp pepper in the chat a couple days ago.
>>
Opinions on golang as a general purpose language?
>>
>>55199845
good if you are working in a large team
>>
>>55199845
If you can leverage goroutines in normal work go for it.
>>
>>55198250
Thank you for using an anime image


>>55197821
This isn't correct
and in future please use
⇔ for iff
⇒ for if
>>
File: homework.png (208 KB, 1440x900) Image search: [Google]
homework.png
208 KB, 1440x900
pls rate my homework.
>>
>>55200104
>"You had spend"
your English is a bit rusty

if you look at some of your code
int n;
printf..
n = GetInt();
return n;

You don't do anything with n until you assign it to GetInt(), and then you just return it.
Instead of this, you could just have
printf...
return GetInt();


A similar thing in main
int bottles = conversion(user_minutes());
>>
>>55200149
sure, but I don't want to seem like an advanced hacker.

I already have some time of experience with java and I'm taking the MIT challenge to learn CS in one year.
>>
[spoiler]Cygwin or MinGW?[/spoiler]
>>
>>55200104
What language is this?
>>
File: 1461850718176.gif (4 MB, 356x200) Image search: [Google]
1461850718176.gif
4 MB, 356x200
>>55200171
>advanced hacker
>>
>>55200104
>not gentoo
>magic numbers
>relying on compiler optimizations
>not gentoo
>inconsistent formatting
>arguably nondescript function names
>declaring n before first use and not merging that with the return
>bad english
>newline before input
>not gentoo
>browser IDE
>weird clutter in workspace
>not Emacs
>not gentoo

It's a start.

>>55200171
>experience with Java
unlearn Java before continuing, thanks.
>>
>>55200183
look at the tabs, anon
>>
>>55200183
>>55200192
It's C and It's the first week of CS50 in Edx.
>>
>>55198958
>>55199633
yeah, and it fixes the lines, too
http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
>>
>>55200180
the GCC on GNU+Linux
>>
how do I make a triforce in C?

by that I mean, how do I make a string made of spaces?
>>
>>55198250
Parse an online forum to an app. Essentially a more compatible, more slick skin for a forum.
>>
>>55201000
"                                                                                             "
>>
>>55198284
.equals(Object)
or
.equalsIgnoreCase(Object)

Java masterrace
>>
>>55201051
... frob? is that you?
>>
I have a webpage that includes multiple JSP files. In one of those files, I have a JS function that I want to run after the entire page one of the JSP files is contained within loads. If I use $(document).ready, the code runs when the individual JSP loads and not the whole page. Any ideas on how to work around it?
>>
>>55201051
It has to be dynamically generated by a for loop.

They asked me to make a mario stair using ascii.
>>
>>55201159
Ok, so use the for loop and print the required number of spaces/stairs, then a newline when needed.

I don't understand the holdup
>>
>>55198389
niiiiiiiiiiice
>>
>>55199213
Use libressl
>>
>>55198284

Assume LHS named foo, compare to RHS string named bar

>Java
foo.equals(bar)

>C#
foo.Equals(bar)

>C
!strcmp(foo, bar)

>C++ (LHS is char*)
!strcmp(foo, bar)

>C++ (LHS is std::string)
foo == bar
>>
>>55201999
F#
foo = bar
>>
File: HelloWorld.png (90 KB, 1582x808) Image search: [Google]
HelloWorld.png
90 KB, 1582x808
1536 bytes HelloWorld.exe program.
Is there any room for improvement ?
>>
>>55202032
change "Hello World !" to "Hello World!"
>>
I don't know javascript but I've been messing with this:
https://ghostbin.com/paste/a5kxj
How do I set this off manually?
      sendICECandidates: function (a) {
for (var b = 'id=' + encodeURIComponent(this.clientID), c = 0; c < a.length; c++) b += '&candidate=' + encodeURIComponent(JSON.stringify(a[c]));
this.sendPOST('/icecandidate', b)
},

How do I see the values of
WEB_RTC_CONFIG = Object { iceServers: Array[1] }

Thanks.
>>
>>55202032

Yes, but you're going to need to get a little dirtier than simply writing assembly. Here is some literature on the matter:

http://webserver2.tecgraf.puc-rio.br/~ismael/Cursos/YC++/apostilas/win32_xcoff_pe/tyne-example/Tiny%20PE.htm
http://hugi.scene.org/online/hugi21/cosmalpe.htm
>>
File: cf.png (71 KB, 780x530) Image search: [Google]
cf.png
71 KB, 780x530
>exceptions for control flow are more efficient in Python
jesus fuck
>>
>>55202137
>snekfags will defend this
>>
>>55202161
I am triggered more by the people calling exceptions more pythonic
>>
>>55202161
nope
big fan of python here
that's fucking shit if true and I still wont use try/except even if it is true
>>
>>55202202
try { defendPython(); } catch (indefensibleException) { damageControl(); }
>>
>>55202137

Python doesn't have a character type. When you do a for loop over strings, you're effectively allocating a new string object for each character in the string, and then calling a function on that. By comparison, using is_ascii will likely call a C function on the string buffer, making no new objects. The exceptions will bear a slight cost, but at least you're doing as much work as possible in C.

Ruby should be similar in this regard.
>>
File: 1436862127365.png (191 KB, 1000x386) Image search: [Google]
1436862127365.png
191 KB, 1000x386
>>55202137
>>
A demonstration with both Python and Ruby on what happens when you iterate over characters.
>>
File: apathy.gif (2 MB, 395x313) Image search: [Google]
apathy.gif
2 MB, 395x313
>>55202278
I didn't come to 4chan to experience these feels
>>
>>55202292
>>>>>green on black
Do you hate your eyes?

>most likely nobuntu
are you a turd?
>>
>>55202294
I really like it how it falls down like semen after that.
>>
File: 1461032696889.png (337 KB, 485x446) Image search: [Google]
1461032696889.png
337 KB, 485x446
>>55202319
>cum bubble
>>
>>55202120
>smallest exe
>97 bytes

Kek, the autism.
Even the keygen from the scene is around 40 KB.
I'm sure they use packer or something to obfuscate the code though.
>>
>>55202292

On close inspection, Python has a slight optimization in being able to cache each individual character as a string, likely because strings in Python, str is an immutable type, while in Ruby, strings are default mutable. Nonetheless, you are still operating on different objects compared to individual bytes.

>>55202308

Green is the easiest color for the human eye to see. Black is the easiest backdrop to see on. Green on black is easiest for me to work with.

>nobuntu
It's comfy, and I'm lazy. Fuck off.
>>
>>55202357

Smallest ELF is 45 bytes, less than half of that of the smallest PE file.

http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html

I would say I'd like to see what the smallest MACH-O file is, but I'm not sure if there is anyone with that degree of Autism that owns a Mac.
>>
>>55202417
This is wrong as it does not fulfil the ELF specification. It uses non-standard shit.
>>
>>55202445
i keep getting memed by gcc
>>
File: 1465766982199.png (132 KB, 396x385) Image search: [Google]
1465766982199.png
132 KB, 396x385
What meme is worth getting into: Plan9 or Common Lisp?
>>
Would a compiler for a proof language with refinement types become sentient as it compiled an AI program?
>>
>>55202445

Still runs. So it's the smallest legal Linux executable I guess. BSD users can blow it out their ass.

Anyways, seems Mac OS X can run a 165 byte executable, although it doesn't conform properly to the standard.

http://osxbook.com/blog/2009/03/15/crafting-a-tiny-mach-o-executable/

At 248 bytes, it satisfies the needs of pedantic little shits.
>>
>>55202562
>Still runs
Doesn't matter.
>>
>>55202577

The only thing that matters is if it runs without errors.
>>
>>55202595
no
>>
>>55202601

I respect your opinion, but it is incorrect.
>>
int main(void) { return 0; }

>mfw even this isn't portable
>>
>>55202629
I do not respect your opinion and it is incorrect.
>>
>>55202632
How so?
>>
File: nothing.jpg (43 KB, 1779x1196) Image search: [Google]
nothing.jpg
43 KB, 1779x1196
>>55202632
NOTHING IS UNPORTABLE
>>
>>55202032
there was a blog post for that, some dude trying to write smallest hello world elf file. starts with C and then writes pretty much in binary. google it, it was pretty cool
>>
>>55202789
nevermind, already posted in the thread.
>>
Why doesn't this work?
#define N_THREADS    64
#define N_ITERATIONS 1000000
#include <stdio.h>
#include <stdlib.h>

int main ()
{
uint64_t i,j, cnt = 0;
double x, y;
#pragma omp parallel for private(i,j,x,y) shared(cnt)
for ( i = 0; i < N_THREADS; ++i )
{
for ( j = 0; j < N_ITERATIONS; ++j )
{
x = ( double ) rand () / ( double ) RAND_MAX;
y = ( double ) rand () / ( double ) RAND_MAX;
if ( x * x + y * y <= 1.0 )
#pragma omp atomic
cnt++;
}
}
printf ( "%f\n", 4.0 * ( double ) cnt / ( double ) N_THREADS
/ ( double ) N_ITERATIONS );
}
>>
>>55202875

I'm not sure what your bug is, but it might have something to do with the fact that you didn't call srand()
>>
>>55202875
rand() is not thread safe, not sure if there are other problems.

what does it do
>>
>>55199213
Hail Köln
>>
>>55202973
The bug is that it doesn't work in parallel. Without openmp it prints 3.141279 like it should. With openmp it prints different values, but usually smaller at around 3.12, which shows that it is forgetting about a few counts. I'm not sure what I need to tell openmp to make this work.

>>55202977
That might be the problem, thanks.

It calculates the area of a circle via that retarded MC method. It's not actually what I'm doing, but the thing I'm working on has the same problem.
>>
>>55202875
shit, is this how hacky it is to get parallelism in c++? just kek.
>>
>>55203054
I really like this bait, you did really good
>>
Hey there /g/, I have a little challenge for ya.
So there's this thing called an Ackermann's function, that takes 2 arguments, and basically goes:
ack(a,b):
if a == 0: return b+1
else if b == 0: return ack(m-1, 1)
else: return ack(m-1, ack(m, n-1))

Can /g/ calculate every value from ack(0,0) to ack(5,5)?
>>
>>55203074
I'm not baiting tho
>>
>>55202537
Plan9.

If you want a lisp, go for Racket. It does everything CL does, just more elegantly, flexibly, and consistently.
>>
>>55203083
no
>>
>>55203083
>(0,0) to (5,5)
Exclusive or inclusive? In what order do you enumerate over tuples of ints? Be precise ffs this ain't /lit/
>>
I've been trying to come up with a way to parse multiple PDFs all of which have different formatting. Anyone have good ideas where I can start? PDF to HTML and pypdf + other pdf libraries have proved unhelpful. Friends tell me its a lost cause
>>
>>55203101
And Plan9 is nice and refreshing, even though some details are annoying.
>>
>>55203083
>>55203125
Inclusive, going through every combination.
Going from (0,1) to (0,5), then (1,0) to (1,5) until (5,5).
>>
>>55203083
>>55203125
Also m and n are undefined it seems. Are they supposed to be a and b maybe?
>>
>>55198250
I still regret the typo, even years after having released this.

*hog memory
>>
>>55203054
>>55203092

1. That is C, not C++
2. That is OpenMP. It's an API for doing parallel shit in C, C++, and Fortran using compiler pragmas. It's not the only way to do parallelism, but it has its advantages (it can kick the shit out of some pthreads-based solutions because of thread pooling), and it's one of the more commonly used tools in large computing clusters.
>>
>>55203162
...Yup... Please ignore that...
>>
>>55203163
If you made this, you're pretty fucked up
get help
>>
>>55203152
Thanks bookfag. Muh feelz!
>>
>>55198284
Why would it get overloaded if it has an utility as it stands (comparing pointers)?
>>
Can't post ack(4,2) even, as it's 19729 characters long. Sorry.
>>
>>55203195
Pastebin's a thing you know
>>
This >>55203190 is for you honey >>55198924 actually...
>>
Where can I find the documentary Softwaring Hard?
>>
>>55203256
>Softwaring Hard
Deez a thing?
>>
>>55203190
>>55203222

In Java, it doesn't really make much sense to overload ==, because everything is a pointer, and you don't want to get rid of the ability to, for example, compare pointer to null.

In C++, you're not comparing pointers to objects with ==, you are comparing objects, so it makes perfect sense that the string class overloads ==.
>>
>>55203203
I doubt you can even pastebin future values
>>
>>55203342
Yeah, fair enough.
>>
>>55203294
Agreed
>>
File: sad penguin.png (120 KB, 284x339) Image search: [Google]
sad penguin.png
120 KB, 284x339
12 hours before my technical interview
Going over:
permutations
DP
graphs
trees

Wish me luck.
>>
>>55203342
>>55203388
Guys! Let's make an XML DTD schwma for a fileformat that unambiguously defibes an URL for the reslut of a cloud compuration!

Guys?...
>>
File: monad-id-law.png (20 KB, 358x260) Image search: [Google]
monad-id-law.png
20 KB, 358x260
>>55203412
>DP
What did he mean by this?
>>
>>55203431
means if I get asked a systems question i'm gonna become a NEET
>>
>>55203431
Dynamic Programming.

Also why forall?
>>
>>>/wsg/1146796
>>
>>55203412

Just review your lecture notes from your previous university classes.
>>
>>55203464
>>>/g/wsg/1146796
FTFY. Also this number is roughly fifty times closer to the beginning of 4chan than to the present day. Just sayin'
>>
>>55203483
Oops, It wasn't a general, I just embarassed myself. Luckily, they don't know I'm Batman...
>>
>>55203256
This
G
U
Y
S
>>
>>55203477
I feel like it's not enough. There are just some problems out there that I feel like exposure is the only way.
>>
File: nopan.png (79 KB, 1626x811) Image search: [Google]
nopan.png
79 KB, 1626x811
What's the most elegant way to disable ShellExecute from opening URL ?

1. Place a jump instruction in 0x401000 to jump straight to 0x401033 (ExitCode)
2. NOP everything from 0x401000 - 0x4040102D (all ShellExecute instruction)
3. Change 'open' to '0pan'

I know I can elegantly disable MessageBox by changing the Handle from 0 to 1, but it doesn't work with ShellExecute.
The only downside of the third method is that if I do that in Olly, I'll see garbage command like "OUTS DX, DWORD PTR DS:[ESI]", because it'll think I'm assembling instruction, not data.
But, the program will work as expected.
I won't have any problem if I change the ascii string in Hex Editor.

Maybe I should move on from Olly to IDA.
>>
>>55203890
I like the jump
>>
>>55203256
How did you even find out about this film?
I can't find a torrent anywhere
you bastard
>>
>>55203890
jump - less instructions to process
>>
>>55203890
replace the instructions starting at 0x401000 with push 0, call exitprocess
>>
In SDL, how do I cast a ray?

What does that even mean?

How do you keep a line going outwards until it hits something?

I'm confused.
>>
>>55204116
SDL has nothing to do with this.
>>
File: math.png (159 KB, 497x274) Image search: [Google]
math.png
159 KB, 497x274
>>55204116
>How do you keep a line going outwards until it hits something?
>>
>>55204130
>reddit.png
>>
>>55204136
seemed apropos
>>
>>55203951
>>55204040
>>55204078
Thanks for your input.

>>55204040
>jump - less instructions to process
That makes sense, although I read reversers show off their skills by changing the smallest code instruction as possible.

It seems I can fix 0pan ascii fuckup by selecting "Analyze code", fucking OllyDbg.
>>
File: 1403989886515.jpg (71 KB, 599x444) Image search: [Google]
1403989886515.jpg
71 KB, 599x444
>>55203412

>get second interview with developer at small time
>panic study shit on BSTs
>day comes
>interviewer changes from phone interview to video interview 10 minutes before call
>tfw gf leaves weed and shit out
>she's naked in the shower
>have to close doors and clean like a motherfucker before the call
>haven't shaved and wearing an old shirt
>interview comes
>dude is laid back as fuck and just asks questions about my work experience and justifications for what I did
>full hour talking about their work and showing me their code and databases
>>
>>55204222
>gf
>NAKED IN THE SHOWER
>weed
>probably skype videocall
normieeee
>>
File: 1464680843938s.jpg (13 KB, 235x250) Image search: [Google]
1464680843938s.jpg
13 KB, 235x250
>>55204308

it was a google hangouts call.

>tfw this is the first job prospect to seemingly go anywhere

being fresh out of college with barely any tech work experience is fucking awful senpai
>>
>>55204222
>changes from phone interview to video interview 10 minutes before call
>don't have a webcam and don't have a microphone
>would need 5 hours to prepare for that even if I did
fuck that guy
>>
Should I wrap every SQL query I make in my dumb python application in a try/except?
>>
>>55204387

wrap the connection commands in a try catch. is the python app using a local database or online? if it's local to the database there's no point if it's network then yes.
>>
>>55204387
try/catch/throw is an anti-pattern
never use it
>>
>>55204483
patterns are anti patterns
never use them
>>
>>55204458
>>55204483
Thanks, good to know I don't need to do it so much.
>>
>>55203184
Gee, fuck you, too.
>>
>tfw first professional repository
{ "NIGGA", new string[]{ NIH, IHH, GIH, UHH, "", }
>>
best free books/tutorials to read for a complete beginner to learn Java? Besides learn Java the hard way. I honestly don't have the like $25 for the book.
>>
>>55199695
>>55199711
First you suggest doing open & read in a chain without error checking then you bitch about lack of error checking in multiple assignment, lol.
>>
>>55198250
the kernel doesn't sizeof anything nor does it pack structs whoever made this should feel bad.
>>
>>55203054
That's C, not C++. In C++ you can use std::thread, std::async, std::future/std::promise, and std::atomic.
>>
>>55204483
my program has known exception states. i dont see an alternative
>>
>>55198473
mate i can write scripts for the space engineers programmable block in this. 10/10 would learn language ingame again.
>>
>>55204628
exception monad
>>
>>55204610

>nor does it pack structs
Erm... packed structs do have their uses in kernel code, actually. If you are reading in an executable image, it is particularly important that the various fields of the file be fit at exact memory offsets, rather than whatever is convenient for alignment. Most documentation I've seen for parsing ELF headers tends to use packed structs in C as part of the example code.
>>
Opinion on Derek Banas?
I have just found him and he is a great teacher. Currently watching his OOP design series.
>>
>>55204701
Why would you learn OOP?
>>
Im learning android development. How can I send push notification when a YouTube channel uploads a video. I can't find any documentation about this
>>
>>55204803
Why wouldn't I?
>>
File: images.jpg (27 KB, 443x332) Image search: [Google]
images.jpg
27 KB, 443x332
>>55203054
>>55203054
>>
>>55204820
Google
>>
File: 1464632537832.png (152 KB, 1948x858) Image search: [Google]
1464632537832.png
152 KB, 1948x858
>>55204831
It's trash
>>
>>55204803
>he will never build any big frameworks
>will probably end up boilerplating string classes because muh bare metal
>hell lose variables in his maze of methods
you need jesus
>>
File: 1383117404001.jpg (19 KB, 480x352) Image search: [Google]
1383117404001.jpg
19 KB, 480x352
>>55204863
>>
Why did python3 get rid of the "comma means same line" technique?

This
>end = " "
shit is stupid.
>>
>>55204845
Thank you cocksucker
>>
>>55204610
Yes it does, unless you don't like having an IDT
>>
>>55199524
0/10, fonts not blurry enough.
>>
File: anatomy-scenario.png (7 KB, 491x208) Image search: [Google]
anatomy-scenario.png
7 KB, 491x208
What would be a good graphics style for a geometry/physics based game? Fucking all of them look like Tron and just use flat colors, but I really can't think of alternatives myself.
>>
>>55205236
anime
>>
>>55205289
Of course, how did I overlook that option
>>
>>55205236
>physics based game
damn, just remembered this http://dan-ball.jp/en/javagame/dust/
>>
>>55205236
Just think about what you like and what seems appropriate for your game. You don't choose artwork style by how "good" they are (whatever that means really).

There are a lot of options, just look at other games and be inspired.
>>
>>55205317
Oh shit I remember this, definitely bookmarking for my next acid trip
>>
File: intredasting-3.jpg (159 KB, 1006x921) Image search: [Google]
intredasting-3.jpg
159 KB, 1006x921
BF compiler in Python:
#!/usr/bin/python3

import sys

sys.stdout.write("\t.lcomm d, 65536\n\t.text\n\t.globl _start\n"
"\t.type _start, @function\n_start:\n\tmov $d, %rbx\n")
s, n = [], 0
while True:
c = sys.stdin.read(1)
if c == "":
break
elif c == '>':
sys.stdout.write("\tadd $1, %rbx\n")
elif c == '<':
sys.stdout.write("\tsub $1, %rbx\n")
elif c == '+':
sys.stdout.write("\taddb $1, (%rbx)\n")
elif c == '-':
sys.stdout.write("\tsubb $1, (%rbx)\n")
elif c == '.':
sys.stdout.write("\tmov $1, %rax\n\tmov $1, %rdi\n"
"\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n")
elif c == ',':
sys.stdout.write("\tmov $0, %rax\n\tmov $0, %rdi\n"
"\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n")
elif c == '[':
sys.stdout.write("\tcmpb $0, (%%rbx)\n\tje c%i\no%i:\n" % (n, n))
s.append(n)
n += 1
elif c == ']':
r = s.pop()
sys.stdout.write("\tcmpb $0, (%%rbx)\n\tjne o%i\nc%i:\n" % (r, r))
sys.stdout.write("\tmov $60, %rax\n\tmov $0, %rdi\n\tsyscall\n")
>>
File: 1442246460245.jpg (465 KB, 3888x2592) Image search: [Google]
1442246460245.jpg
465 KB, 3888x2592
any books dealing with how to structure and design large ass projects?
especially one that deals with different layers and what not
>>
>>55205487
>Not optimising
>>
>>55205487
RENAME ALL THOSE DOG SHIT VARIABLES RIGHT NOW
>>
File: 1231231231.jpg (2 KB, 125x92) Image search: [Google]
1231231231.jpg
2 KB, 125x92
>>55205487
>if elif elif elif elif elif elif

>syst.stdout.write
>syst.stdout.write
>syst.stdout.write
>>
I'm still painfully new to a large amount of coding, so it's simple PHP crap for me. The course I'm in is sparse when it comes to explaining a large amount of the concepts, so I've mostly been dissecting earlier assignments and figuring out how each piece works.
>>
>>55205487
>AT&T
I hate you
>>
File: Ipg8muFg.jpg (66 KB, 680x541) Image search: [Google]
Ipg8muFg.jpg
66 KB, 680x541
Do many programmers have autism/aspergers?
I recently started hanging in some programming related IRC channels and the people there really are a little different.
>>
File: 1465360314662.jpg (2 MB, 1250x2029) Image search: [Google]
1465360314662.jpg
2 MB, 1250x2029
What would be the best book to speedrun my way thru java?
>>
>>55205562
Everyone on 4chan has autism
>>
>>55205535
>>55205487
>inb4 but you can't do switch statements in Python
_THINGS = {
'>': lambda : sys.stdout.write("\tadd $1, %rbx\n"),
'<': lambda : sys.stdout.write("\tsub $1, %rbx\n"),
'+': lambda : sys.stdout.write("\taddb $1, (%rbx)\n"),
'-': lambda : sys.stdout.write("\tsubb $1, (%rbx)\n"),
'.': lambda : sys.stdout.write("\tmov $1, %rax\n\tmov $1, %rdi\n\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n"),
',': lambda : sys.stdout.write("\tmov $0, %rax\n\tmov $0, %rdi\n\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n")
}

while True:
c = sys.stdin.read(1)

if c == "":
break
elif c in _THINGS:
_THINGS[ c ]()
if c == '[':
sys.stdout.write("\tcmpb $0, (%%rbx)\n\tje c%i\no%i:\n" % (n, n))
s.append(n)
n += 1
elif c == ']':
r = s.pop()
sys.stdout.write("\tcmpb $0, (%%rbx)\n\tjne o%i\nc%i:\n" % (r, r))

sys.stdout.write("\tmov $60, %rax\n\tmov $0, %rdi\n\tsyscall\n")
>>
>>55202032
>1.5kb helloworld
Bloated shit.
>>
>>55205641
this is still terrible

what you want to do is this
_THINGS = {
'>' : "\tadd $1, %rbx\n",
etc
}

(don't know the python syntax for this)

[ (key, \_ -> sys.stdout.write(str)) | (key, str) <- _THINGS ]


basically map the strings to a lambda printing them
>>
>>55205677
because lazy, copy+paste is easier than thinking
>>
>>55205761
>needing to think about such a basic manner of avoiding repetition
>>
My company's higher-ups are coming to the office today, don't embarrass me lads
>>
programmers fall into two groups.
on the one, you get normies desperate for a job and decide "fuck im gonna push my brain through the meat grinder if it rewards me." sometime along the way they realise they could become the architect of their dream projects and start picking up speed.

then you get the high functioning mental problem kids whos dads sculpted there baby brains into vulcan tier before they could read. these tend to never leave programming chat rooms and game forums
>>
>>55205761
Code is primarly a way of communicating an idea between two people. Only as a side effect should it be able to be executed by a machine. So yeah, insert some thought in how you structure your stuff, it's just better.

btw Python is just so annoying by not being strictly expression based and not having the slightest hint of a macro!
>>
>>55205812
>>55205562
forgot the reply
>>
>>55205548
>AT&T
i'm sorry, noob here, but what's AT &T?
>>
"I love stateless systems"
"Don't they have drawbacks?"
"Don't what have drawbacks?"
>>
>>55205764
>>55205820
I'm not the original poster of it, I just copied >>55205487 and did a multi-line select on similar, copy, paste.
_THINGS = {
'>': "\tadd $1, %rbx\n",
'<': "\tsub $1, %rbx\n",
'+': "\taddb $1, (%rbx)\n",
'-': "\tsubb $1, (%rbx)\n",
'.': "\tmov $1, %rax\n\tmov $1, %rdi\n\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n",
',': "\tmov $0, %rax\n\tmov $0, %rdi\n\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n"
}
...
sys.stdout.write(_THINGS[ c ]())

Is that better?
>>
>>55205891
yes
>>
>>55205856
He's referring to the AT&T-style x86 assembler syntax, as opposed to the Intel style, which he for some reason prefers.
>>
>>55198354
you don't have a clue what the fuck you're talking about
>>
>>55205894
Sorry I was just still in dict-of-callables mode because that's what I'm using for this >>55198667 to map commands to their functionality.
>>
>>55205677
Python can't express side-effects, like the stack manipulation, in lambdas though.
>>
PHP files are just executed server side and they output html, why not use something else like python?
>>
>>55205979
he's not me btw, I'm the guy that said
#define == !=

Dunno if it just works differently in C++
>>
>>55205998
see >>55205641
but with the modification

you just make [ and ] special cases
>>
File: 938.jpg (47 KB, 300x339) Image search: [Google]
938.jpg
47 KB, 300x339
>>55205812
>mental problem kids whos dads sculpted there baby brains into vulcan tier before they could read
I have no idea what you're talking about.
>>
>>55206016
Just how is that an improvement, though? That program has more structure and is more complex, for no gain.
>>
File: 24231.jpg (54 KB, 500x500) Image search: [Google]
24231.jpg
54 KB, 500x500
>>55206036
Probably because he's talking about people who can program
>>
>>55206044
No it isn't.
Literally just get rid of all the "system.stdout.write" and use >>55205891

Do an
'if [ then .. elif ] then .. else <dictionary>'
>>
>>55206002
it doesn't work in anything, because == is not a valid identifier
>>
>>55206061
But it now uses two different mechanisms for dispatch instead of one. Regularity is more important.
>>
>>55206064
Oh, well in some implementations including VC++ it does
>>
>>55206044
>no gain.
Adding a new mapping takes a single line, and you can programatically do more cool stuff since it's not embedded in code. In your case the gain may be marginal, but take this for example:
def interactive_actions_help( record ):
"""Print available actions & descriptions"""
for action, handler in _ACTIONS.items():
print "%-4s %s" % ( action, handler.__doc__ )

# ... snip ...

_ACTIONS = {
"h" : interactive_actions_help,
"c" : interactive_add_custom,
"d" : interactive_download_loc,
"t" : interactive_torrent_loc,
"s" : interactive_toggle_start
}

while action != "":
sys.stdout.write(
"Enter action ('h' for help) or hit enter to confirm: "
)
action = sys.stdin.readline()[ : -1 ]

if action == "":
continue
elif action in _ACTIONS:
_ACTIONS[ action ]( record )
else:
print "Unrecognized action"
>>
>>55206082
[ and ] are different to the others, they shouldn't be the same, and in yours they aren't regular either

plus if you think that example is a good case to use
if
elif
elif
elif
elif

and repeat significant code 5 times, then you are wrong
>>
Trying to learn how to use opengl and Im stuck in a tutorial.
>http://www.learnopengl.com/#!Getting-started/Hello-Triangle
I get all the way to shader programming but then I get
>'vertexShaderSource': undeclared identifier
Im not really sure whats going on here so I dont know how to even start to fix it.
>>
>>55206083
the standard:
                 # define identifier replacement-list new-line
# define identifier lparen identifier-listopt )
replacement-list new-line
# define identifier lparen ... ) replacement-list new-line
# define identifier lparen identifier-list , ... )
replacement-list new-line
# undef identifier new-line

the VC++ documentation:
Syntax

#define identifier token-stringopt

#define identifier( identifieropt, ... , identifieropt ) token-stringopt

so no, it doesn't work
Compiler Error C2007
No identifier appears after a #define. To resolve the error, use an identifier.
>>
>>55206102
Just how is if ... elif ... elif ... elif intrinsically any worse than {key: ..., key: ..., key: ...}? It's the exact same thing expressed in marginally different ways.

Not that there's no difference that could be significant in certain situations, but I don't see this being one of those.
>>
>>55206169
it's worked at some point

>>55206180
Because of all the fucking repetition?
Repeating yourself is INHERENTLY bad
>>
Any language that has elif, elsif or elseif should just die.
>>
>>55206187
>worked at some point
just fuck off
Thread replies: 255
Thread images: 42

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.