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

/dpt/ - Daily Programming Thread

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

Thread replies: 392
Thread images: 42

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
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 (118KB, 1600x1200px) Image search: [Google]
Denise_Milani_Wallpaper.jpg
118KB, 1600x1200px
//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 (259KB, 366x206px) Image search: [Google]
macrovid - Copy.webm
259KB, 366x206px
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 (91KB, 736x957px) Image search: [Google]
3FA.jpg
91KB, 736x957px
>>55198692
>in C# there's such a thing as "abstract interface"
That's supposed to be a question.
>>
File: ee2117c6c5.png (10KB, 589x218px) Image search: [Google]
ee2117c6c5.png
10KB, 589x218px
>>55198724
nvm, I used an abstract class instead.
>>
>>55198284
you can if your language isn't retarded and can overload operators
>>
File: 1464643883328.jpg (67KB, 600x549px) Image search: [Google]
1464643883328.jpg
67KB, 600x549px
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 (50KB, 469x428px) Image search: [Google]
1466544462190.jpg
50KB, 469x428px
>>55198958
>>
>>55198969
What

Also, why is the thread so dead
>>
>>55198969
fuck off
>>
File: 485867.jpg (908KB, 3840x2160px) Image search: [Google]
485867.jpg
908KB, 3840x2160px
>>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 (193KB, 1280x800px) Image search: [Google]
Trying to learn.png
193KB, 1280x800px
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 (3MB, 1898x1384px) Image search: [Google]
badRandom.png
3MB, 1898x1384px
>>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 (208KB, 1440x900px) Image search: [Google]
homework.png
208KB, 1440x900px
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 (4MB, 356x200px) Image search: [Google]
1461850718176.gif
4MB, 356x200px
>>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 (90KB, 1582x808px) Image search: [Google]
HelloWorld.png
90KB, 1582x808px
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 (71KB, 780x530px) Image search: [Google]
cf.png
71KB, 780x530px
>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 (191KB, 1000x386px) Image search: [Google]
1436862127365.png
191KB, 1000x386px
>>55202137
>>
A demonstration with both Python and Ruby on what happens when you iterate over characters.
>>
File: apathy.gif (2MB, 395x313px) Image search: [Google]
apathy.gif
2MB, 395x313px
>>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 (337KB, 485x446px) Image search: [Google]
1461032696889.png
337KB, 485x446px
>>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 (132KB, 396x385px) Image search: [Google]
1465766982199.png
132KB, 396x385px
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 (43KB, 1779x1196px) Image search: [Google]
nothing.jpg
43KB, 1779x1196px
>>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 (120KB, 284x339px) Image search: [Google]
sad penguin.png
120KB, 284x339px
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 (20KB, 358x260px) Image search: [Google]
monad-id-law.png
20KB, 358x260px
>>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 (79KB, 1626x811px) Image search: [Google]
nopan.png
79KB, 1626x811px
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 (159KB, 497x274px) Image search: [Google]
math.png
159KB, 497x274px
>>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 (71KB, 599x444px) Image search: [Google]
1403989886515.jpg
71KB, 599x444px
>>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 (13KB, 235x250px) Image search: [Google]
1464680843938s.jpg
13KB, 235x250px
>>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 (27KB, 443x332px) Image search: [Google]
images.jpg
27KB, 443x332px
>>55203054
>>55203054
>>
>>55204820
Google
>>
File: 1464632537832.png (152KB, 1948x858px) Image search: [Google]
1464632537832.png
152KB, 1948x858px
>>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 (19KB, 480x352px) Image search: [Google]
1383117404001.jpg
19KB, 480x352px
>>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 (7KB, 491x208px) Image search: [Google]
anatomy-scenario.png
7KB, 491x208px
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 (159KB, 1006x921px) Image search: [Google]
intredasting-3.jpg
159KB, 1006x921px
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 (465KB, 3888x2592px) Image search: [Google]
1442246460245.jpg
465KB, 3888x2592px
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 (2KB, 125x92px) Image search: [Google]
1231231231.jpg
2KB, 125x92px
>>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 (66KB, 680x541px) Image search: [Google]
Ipg8muFg.jpg
66KB, 680x541px
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 (2MB, 1250x2029px) Image search: [Google]
1465360314662.jpg
2MB, 1250x2029px
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 (47KB, 300x339px) Image search: [Google]
938.jpg
47KB, 300x339px
>>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 (54KB, 500x500px) Image search: [Google]
24231.jpg
54KB, 500x500px
>>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
>>
>>55206187
Plus the other one better models this - you've got a constant mapping from a character to a string.
Obviously use a map (a dictionary).

If you feel the need to do this nonsense

if a then agoiah.aihjfi.asfiajos(string1)
elif b then agoiah.aihjfi.asfiajos(string2)
elif c then agoiah.aihjfi.asfiajos(string3)
elif d then agoiah.aihjfi.asfiajos(string4)
elif e then agoiah.aihjfi.asfiajos(string5)
>>
>>55206180
O(n) vs O(log n)

>>55206193
It's a good feature for certain cases, such as a series of nonsimilar sequential comparisons.
>>
>>55206187
>Repeating yourself is INHERENTLY bad
Not if it means not binding oneself to a more limiting structure.
>>
>>55206218
pattern matching
>>
>>55206218
>It's a good feature for certain cases
Hell no
>>
>>55206218
>arguing performance in Python
Also, your hash table's O(1) (not O(log n)) is much more expensive than one of the elements of an if ... elif's O(n), so if it's performance you want, you'd need a lot more elifs before a hash table is cheaper.
>>
>>55206221
What the fuck are you even saying?
>>
>>55206218
>It's a good feature for certain cases, such as a series of nonsimilar sequential comparisons.
Not him, but I think he meant "elif" versus "else if".
>>
>>55206251
I'm saying that your example implies sys.stdout.write(dictionary[c]), which is less capable than an elif clause. In return, you have to special-case the [ and ], adding more structure to the program.
>>
>>55202875
parallel for will manage threads for you so you dont need that outer loop.
use reduction if you are summing into a shared variable, it can optimize better that way.
and initialize private variables inside the forloop.

int main ()
{
uint64_t cnt = 0;
#pragma omp parallel for reduction (+:cnt)
for (uint64_t i = 0; i < N_ITERATIONS; ++i)
{
double x = ( double ) rand () / ( double ) RAND_MAX;
double y = ( double ) rand () / ( double ) RAND_MAX;
if ( x * x + y * y <= 1.0 )
cnt++;
}
printf ( "%f\n", 4.0 * ( double ) cnt / ( double ) N_ITERATIONS );
}
>>
>>55206263
>adding more structure
No, you've already got different circumstances for the other two cases. And it's the same stuff you'd do in the example I'm giving you. Literally all you have to do is cut all the "system.stdout.write" crap, put it in a dictionary, then keep the '[' and the ']' but remove all the rest and change them into an "else write(dictionary[key])"
>>
>>55206281
>No, you've already got different circumstances for the other two cases
Yes, but they're both handled by the same dispatch structure. Adding another one on top of it is ugly.
>>
import requests
say_this = []
count=0
while True:
count+=1
p1 = str(input("Name, Line{0}:".format(count)))
p2 = str(input("Message, Line{0}:".format(count)))
temp = [p2+":", p1]
stop = input("stop, y/n")
if stop == "y":
break
else:
say_this.append(temp)
say_this = str(say_this).replace("'", '"')
data ={"log": say_this,
"randid": "THEGAMEE",
"topics": """["SENPAI", "NOTICE", "ME"]""",
"identdigests": "lol,fake,request",
"host": 1}
print(say_this)
r = requests.post('http://logs.omegle.com/generate', data)
#print(r.content)
split = str(r.content)
split = split.split('"')
try:
print(split[23],split[31])
except IndexError:
print(r.content)
>>
>>55201794
It hands out a segfault though
>>
/dpt/ I am modeling a Shop database and wanted some help.
I basically want to keep track of the shop's inventory and item purchases. Whenever a purchase is registered I wanted to register each item bought (example: 2 oranges, 1 banana and 3 apples) for each purchase. Picture related I what I came up for this scenario.
Now I wanted to add the Inventory table but I have no idea on how to do it. I am pretty sure I will need a relationship between the Item and Inventory table, maybe a 1:M is that correct? Which fields will my inventory table need? Can someone with more experience in database modeling help me?
>>
>>55206246
>hash table's O(1) (not O(log n))
Huh, always assumed Python's dict used a tree like std::map. Trees are better for smaller mappings, don't know why they chose that. Guess you're right about the performance then.

>>55206255
Technically yeah, but the scope assumptions are different. In C-likes, you can chain "else if", but in Python and similar languages with stronger scoping syntax it becomes unwieldy. "elseif" / "elif" chains several comparisons within the same scope.
>>
>>55206285
>by the same dispatch structure
It's not a fucking regular structure, and it's not "adding another one on top", and it's not fucking ugly.

YOUR CODE IS UGLY.

YOU ARE LITERALLY DEFENDING THIS:if a then agoiah.aihjfi.asfiajos(string1)
elif b then agoiah.aihjfi.asfiajos(string2)
elif c then agoiah.aihjfi.asfiajos(string3)
elif d then agoiah.aihjfi.asfiajos(string4)
elif e then agoiah.aihjfi.asfiajos(string5)
>>
>>55206304
>Trees are better for smaller mappings
Perhaps for mappings that are smaller than 2 elements, but after that there's no reason to not use a hash table.
>>
>>55206300
do your own homework
>>
>>55206304
>>55206323

It's mapping a char, so it could just use an array
>>
>>55206308
And I'll defend it again before adding some ugly dual dispatch. Especially for something with 8 cases.
>>
>fopen is unsafe. consider fopen_s
>fopen_s does not take 2 arguments
Why is everything so hard to use.
>>
>>55206347
>fopen is unsafe
What?
>>
>>55206300
One thing, why does ItemPurchase need an aditional id? Id_Purchase in combination with id_item should be unique as well.

Secondly, If you do not have the possibility to purchase different items in one purchase with different payment types, the payment type can go to purchase.

Third, why do you need totalPricec in itemPurchase? A teacher of me said, everything which can be calculated easily, shouldn't be stored in the database.


I am not sure about the Inventory table, because my changes change that much.
>>
>>55205487
>>55205641
>>55206016
THIS is how MEN do it
$stdout.write <<HD
.lcomm d, 65536
.text
.globl _start
.type _start, @function
_start:
mov $d, %rbx
HD
s, n = [], 0

$stdin.each_char do |c|
$stdout.write case c
when '>'
<<HD
add $1, %rbx
HD
when '<'
<<HD
sub $1, %rbx
HD
when '+'
<<HD
addb $1, (%rbx)
HD
when '-'
<<HD
subb $1, (%rbx)
HD
when '.'
<<HD
mov $0, %rax
mov $0, %rdi
mov %rbx, %rsi
mov $1, %rdx
syscall
HD
when ','
<<HD
mov $0, %rax
mov $0, %rdi
mov %rbx, %rsi
mov $1, %rdx
syscall
HD
when '['
s << n
n+=1
<<HD
cmpb $0, (%rbx)
je c#{n}
o#{n}:
HD
when ']'
r = s.pop
raise "'[' without a matching ']'" unless r
<<HD
cmpb $0, (%rbx)
jne o#{r}
c#{r}:
HD
else ""
end
end
>>
>>55206347
You felt into the microsoft trap.
There is nothing unsafe with fopen and do not listen to the warnings from VS, they are shit.

In fact you should not use VS for programming C. (Not to mention that you should not use windows at all)
>>
>>55206323
Depends on how fast your hashing function is. Anyways debating it is pointless since without running tests it's premature optimization.
>>
>>55206361
>dat inconsistent indentation
This is why here-documents suck.
>>
>>55206308
Your problem is that you'r not using an expression-based language, which, as the name implies, is just more expressive without a doubt. See >>55206361
I would probably have been better off making it in Scheme because I'm less familiar with Ruby and its docs are unnavigable.
>>
>>55206374
Of course, but you'd have to have a pretty slow hash function for it to be substantially slower than strcmp().
>>
>>55206361
God that's disgusting.
>>
>>55202875
>>55206269

oh also
https://computing.llnl.gov/tutorials/openMP/
>>
>>55206386
No, it's still fucking terrible
It's got nothing to do with it not being expression based, it's the fact that you're using this many fucking nested ifs
>>
>>55206379
Yep, but with a worthy-of-its-name editor you could fold the file in order to see and parse for coloration only the Ruby part or only the asm part.

>>55206399
Meet betterness
>>
>>55206361
But that's not GAS.
>>
>>55206405
I'm not the guy with the Python version, and how the fuck are my ifs nested? There aren't even any???
>>
>>55206343
I don't understand how you can fucking think like this. Are you at uni or something? I don't understand how you could just by yourself come to believe this nonsense.

This is what you fucking do:

string += dictionary[x];
if x = '[' then
extra stuff
elif x = ']' then
extra stuff

This is the CLEAN solution.
>>
>>55206290
senpai will never notice me
>>
>>55206410
>not gay as shit
agreed. But what IS it?
>>
>>55206361
There is a slight issue: use n = -1 because I flipped the [ code around in order for its returned value to be the HD. Scheme has a fucking begin0 form, why can't Ruby ffs?
>>
Does c++ support covariance of some sort or I'm doing something wrong?

#include <vector>

class Base
{
public:
int stuff;
};

class Derived : public Base
{
public:
int morestuff;
};

int main()
{
std::vector<Derived* > data;
std::vector<Base* > *test = &data;
delete test;
return 0;
}
>>
>>55206417
>Are you at uni or something?
Odd, I was thinking the same thing about you. I can't see how you could otherwise break up a regular structure into some hybrid mess that requires more global structure just because switch() is theoretically nicer than elif.

Heck, with your dictionary nonsense, you're even splitting the dispatched characters into two different locations. If this were a larger program, that would be the beginnings of a maintenance nightmare.
>>
>>55206455
No, C++ doesn't support covariance or contravariance.
>>
>>55198613
Not bad but overcomplicated. Just have a damn Textbox where you can enter the combo and a list view where you can view the already entered combos.
>>
File: Gazo.png (2MB, 1600x900px) Image search: [Google]
Gazo.png
2MB, 1600x900px
Working on my image manager/viewer. Only started working on it the other day so it doesnt do much right now
>>
>>55206455
>delete test;

Forgot to remove this line.

>>55206472

Thank you.
>>
>>55206481
Are all these traps?
Post source, I really like it.
>>
>>55200104
can you forkbomb that terminal?
>>
>>55206468
>hybrid mess
>maintenance nightmare

Holy fucking shit.
LOOK AT YOUR FUCKING CODE.

Do this for me: Change it so it writes to a file that is not stdout. How many places do you change?

Change the characters. How far apart are the characters you change?

The reason you should have two """"dispatch structures""" (where apparently if elif elif elif elif counts as "one dispatch structure" and not as 5 like it fucking should) is because two cases are exceptional. The rest are all the same.

You are a BAD programmer.
Your code is LESS maintainable.
Your code is MORE redundant.
Your code requires MORE changes.
Your code is LESS readable.
Your code is LESS CONVENIENT to debug
Your code MIXES UP different operations

Oh, and your code's fucking ugly too
>>
>>55206503
Any sane sysadmin would just set appropriate ulimits per user on a public system so the worst that can happen is you will just get your program SIGKILL'd before you can exhaust any resources.
>>
>>55206360
Thanks for replying.

1) You're right, the additional ID isn't necessary

2) What if the person, who bought two items, pays one with money and other with credit card?

3) It's just to ease the display of data to the user since someone can buy 1000 items and making a sum of each items' price can really fuck up the performance.
>>
File: text.png (30KB, 511x508px) Image search: [Google]
text.png
30KB, 511x508px
Finally gotten round to making a new text loader since my last one was effectively just reconstructing the entire buffer from scratch and running all offset calculations within a single function every cycle.

This one is just going to extend the buffer memory every time a string increases in size and leave the XY coordinates already in there alone while picking and inserting the UV coordinates from the image only when they change. I'm also going to store all the UV coordinates for the texture in a const array this time. IT's 14~KB to store them all but who gives a shit. It's only memory.
>>
>>55206517
>Do this for me: Change it so it writes to a file that is not stdout. How many places do you change?
The program was not designed for that, and keeping the design goals down is a nice thing in itself, so that you don't end up with a OutputRedirectionPolicyFactorySingleton, Pajeet.
>>
>>55206392
I suppose, guess I was thinking of that tree algorithm that uses partial string matching; something like Jane Trees developed at IBM or something, can't remember.
>>
>>55206517
>Change it so it writes to a file that is not stdout.
./bfc.py >anotherfile.s

That's how hard that was.
>>
>>55206541
>the program was not designed for that
No shit, it wasn't designed at all.
It's just the process of some retard guessing his way through code.

Oh, but of course I must be a Java programmer to point out this fucking retardation and suggest, maybe using a map instead? But no. That violates your "muh dispatch structures" OOP teaching, doesn't it?


>>55206553
>IS NOT STDOUT
>>
>>55206550
Judy tree/array, and it was implemented by HP https://en.wikipedia.org/wiki/Judy_array
>>
>>55206573
>No shit, it wasn't designed at all.
It's 34 lines in total. It's really not large enough that maintainability is an issue at all.
>>
File: 2000px-Opengl-logo.svg[1].png (234KB, 2000x867px) Image search: [Google]
2000px-Opengl-logo.svg[1].png
234KB, 2000x867px
Best resource to learn pic related?
>>
>>55206595
Photoshop
>>
>>55206538
2. Maybe two purchases instead?

3) I guess, that's personal preference.
>>
>>55206573
>No shit, it wasn't designed at all.
If you want to use a dictionary, you'd at least make sure to fit all the possible cases into it, otherwise it's a mess.
>>
>>55206595
This is what I used.
https://open.gl/

I mainly use C++ and C. Also just ignore all the shit on stencil buffers and geometry shaders. You will never, ever use them.
>>
>>55206595
redblue book.
>>
>>55206593
One of the most basic principles of programming is that you are to avoid repeating yourself unnecessarily. Performance considerations could be considered a necessity, for instance.

You are performing the same task multiple times. You are mapping a key to a string.
This is why it's called a map.
This is what maps are made for.

Simply avoiding repeating yourself, which should be an innate concern to any programmer, is enough to avoid this kind of problem.

>>55206617
The cases are exceptional, that's the point.
It is extremely simple however to do both.
All you do is add this:

if x = '[' then push...
elif x - ']' then pop...
endif

system.stdout.write(dict[x]) ...

As you can see, you have clearly separated and dealt with the unique behaviour of those special cases, but still deal with the shared behaviour in a uniform manner.
This a more proper way to do this.
All you have to do to change the output is change 1 location. All you have to do to duplicate the output is add 1 line.
>>
>>55206623
Oh, also for the context creation shit I went with GLFW. It hasn't failed me yet.
>>
ν ϑrεαẟ when;
>>
>>55206675
>Simply avoiding repeating yourself, which should be an innate concern to any programmer
Of course it is, but promoting regularity is another one.
>The cases are exceptional, that's the point.
The elif dispatch structure doesn't need to treat them exceptionally, however.
>>
>>55206675
(not him) except the [ and ] strings get formatted with content from the n and s variables, so this thing should be global. Again, go for a fucking case expression in an actual programming language and stop being such two idiots.
>>
excel vba to modify a formula to
depend on header rows and variables but it's not working. I don't know what's wrong coz i don't even know how visual basic
Option Compare Text
Function DATAFILL(ID_number, source_headerRow) As Variant
ID_header_name = Cells.Item(1, ID_number.column).Value
Dim wb As String, ws As String
Dim ID_src As Range
'check if source_headerRow is an external workbook
If source_headerRow Like "'" Then
src = Split(source.address(External:=True), "!")(0)
wb = Replace(Split(src, "]")(0),"[","")
ws = Split(src, "]")(1)
id_col = Application.WorksheetFunction.Match(ID_header_name, source, 0)
Set ID_src = Workbooks(wb).Worksheets(ws).Range(Cells(1, id_col))
Else
Set ID_src = Range(Cells(1, Application.WorksheetFunction.Match(ID_header_name, source_headerRow, 0)))
End If

headername = "Shift" 'placeholder
Set addr = Workbooks(wb).Range("A:Z")
DATAFILL = Application.WorksheetFunction.Index(addr, Application.WorksheetFunction.Match(ID_number, ID_src), Application.WorksheetFunction.Match(headername, source_headerRow, 0))

End Function
>>
>>55206706
>>55206675
While I agree with >>55206675 , as I said here >>55206095 it might not be worth it in the case in discussion as it has a limited, pre-defined number of options to select from.
>>
>>55206706
My version does promote regularity.

>the elif dispatch structure doesn't treat them exceptionally
It's not even one dispatch structure!
if _ else (if _ else (if _ else ( ... ) ) )

if (the sky is green) then doSideEffects()
else if (input is 3) then pureReturnString()
else if (database contains Steve) then pureReturnInt()
>it's one regular, uniform dispatch structure

>>55206721
I said earlier use pattern matching, don't know if Python has it, what I said is a map/dictionary is a much better solution
>>
>>55206675
>Simply avoiding repeating yourself, which should be an innate concern to any programmer
You're repeating yourself either way; in your dictionary approach, you're still repeating syntactical elements like colons, commas, citation marks, newlines, &c., so it's not like it's "free of repetition".
It's just a question of a certain level of repetition, not a question of qualitatively different structures.
>>
>>55205487
I'm no expert at snek meme, but rate my version:
from sys import stdin

def loop_begin(stack):
n = stack[0]
stack.append(n)
stack[0] += 1
return n

def loop_end(stack):
return stack.pop()

def pure(stack):
return ""

lut = {
'>': {
"str": ["\tadd $1, %rbxadd $1, %rbx"],
"fn": pure
},
'<': {
"str": ["\tsub $1, %rbx"],
"fn": pure
},
'+': {
"str": ["\taddb $1, (%rbx)"],
"fn": pure
},
'-': {
"str": ["\tsubb $1, (%rbx)"],
"fn": pure
},
'.': {
"str": ["\tmov $1, %rax",
"\tmov $1, %rdi",
"\ttmov %rbx, %rsi",
"\ttmov $1, %rdx",
"\tsyscall"],
"fn": pure
},
',': {
"str": ["\tmov $0, %rax",
"\tmov $0, %rdi",
"\ttmov %rbx, %rsi",
"\ttmov $1, %rdx",
"\tsyscall"],
"fn": pure
},
'[': {
"str": ["\ttcmpb $0, (%%rbx)",
"\tje c{}",
"o{}:"],
"fn": loop_begin
},
']': {
"str": ["\tcmpb $0, (%%rbx)",
"jne o{}",
"\tc{}:"],
"fn": loop_end
},
}

start = [".lcomm d, 65536",
".text",
".globl _start"]

end = ["\ttmov $60, %rax",
"\ttmov $0, %rdi",
"\tsyscall"]

def output(lst):
print("\n".join(lst))

def emit(c, stack):
inst = lut.get(c)
if not inst:
return

f = inst["fn"](stack)
output([s.format(f, f) for s in inst["str"]])

def main():
output(start)

stack = [0]
for c in stdin.read():
emit(c, stack)

output(end)

if __name__ == "__main__":
main()
>>
>>55206721
>>55206675
>>55206706

Wait I'll rephrase:
Except the [ and ] strings vary depending on content from the n and s variables. Furthermore, if the _THING abomination were to be a global constant hash of lambdas, it wouldn't know what n and s to use. Why can't you two go for a fucking case expression in an actual programming language, which solves every single problem you've brought up, and stop being such two pydiots?
>>
>>55206744
>It's not even one dispatch structure!
>if _ else (if _ else (if _ else ( ... ) ) )
That's still one structure. Also, elif is not the same is else (if).
>>
>>55206753
What are you talking about?
It is much freer of repetition.


>>55206759
1) You have at no point listened to me at all
2) I'm not saying use lambdas, that was the other guy's idea, I was just saying how he could use a map to avoid lambda: 'ing himself
3) Map of chars to strings

>>55206766
No it's not! And it's not regular!
>>
New thread:
>>55206771
>>55206771
>>55206771
>>
>>55206756
More complicated for no gain.
>>
/!\ A L E R T /!\

new thread

>>55206779
>>55206779
>>55206779

/!\ A L E R T /!\
>>
>>55206778
>It is much freer of repetition.
"Freer" being a comparative form, indeed. As I said, it's just a quantitative difference in repetition, not a qualitative difference.
>>
>>55206756
Lookin good.
>>
>>55206778
>And it's not regular!
Every case determinator follows the same form, so it is. The "repetition" you so detest is proof that there is regularity.
>>
>>55206782
>>55206788
Congrats, you both blew it
>>
>>55206801
Yes there is a qualitative difference. There are much more details which are fixed in a if-write program like yours than in creating a dictionnary containing lambdas or whatever. There is only one way to create the dict, but here you copy paste the exact manner in which you are going to use the string, dummy.
>>
>>55206860
But on the other hand, each case is free to do whatever it wants. Case in point, the [ and ] cases can add logic of their own.
>>
>>55206871
>each case is free to do whatever it wants
that's pretty irregular
>>
>>55206886
The very point is that the content of the cases can be precisely as regular or irregular as they want to. The dispatch structure itself is still regular.
>>
>>55206900
You are literally crazy
>>
>>55206927
The very same to you, Anon.
>>
>>55206934
No, I'm not. I'm literally thinking stuff through.
In fact, in this case, I don't even need to apply thought to do this kind of thing. It is obvious to anyone who has programmed for more than a week that

if char1 then write(str1)
elif char2 then write(str2)
elif char3 then write(str3)

Is no better than

if (arr[0]) if (arr[1]) if (arr[2]) if (arr[3]) if (arr[4]) { do stuff }
>>
>>55206964
But those are completely different things.

If there were completely different things to do for the cases of arr[0], arr[1], &c., and not all of them fit into the same simpler structure, then this would still be the right thing to do.
>>
>>55206964
>if (arr[0]) if (arr[1]) if (arr[2]) if (arr[3]) if (arr[4]) { do stuff }
I did use that on a platform with no short-circuiting in &&. I wrote it like
if(x) if(y) if(z) {
do_w();
}

Am I a monster?
>>
>>55207033
I mean, just in case it wasn't clear, if the [ and ] cases actually fit into your dictionary solution, then I'd be all for it. But they don't.
>>
>>55207033
if (arr[0]) if (arr[1]) if (arr[2]) if (arr[3]) if (arr[4]) if (arr[0] > 3) { do stuff }

foldl (&&) (arr[0] > 3) arr
>>
>>55207056
They do. The dictionary is just for the char/string mappings.

When it comes to the side effects that the [ and ] do, you check for [ or ]. They are EXCEPTIONAL, and the alternative to dispatching specially for them is to pointlessly add to the structure what isn't shared for most of them. The other alternative is the utter trash you wrote, repeating so much so many times.
>>
>>55206778
>Furthermore if
Ikr. There have been version of the snippet using dict of lambdas, as well as dict of strings. I was makeing a point by case-elimination: if there is strings, then they can't have interpolation, if there are lambdas, they can't either. I should have made my case tho: then the abomination should be a local map of lambdas. Now surely someone will be nitpicking at how inefficient that is, and it's still unfathomable to me, so use a case ffs.
>>
>>55207077
>They are EXCEPTIONAL
For the third time, however, the elif structure does not need to handle them exceptionally, and is thus less structurally complex than adding a second dispatch structure.
>>
>>55207168
The elif doesn't need to handle them differently because it's fucking irregular and throws away any acknowledgement of the symmetry shared between all of the cases purely because there's an extra difference in two cases that could be uniquely dispatched upon but >muh """dispatch structures""" >muh if elif elif elif elif with wildly varying conditions would still be one "dispatch structure"
>>
>>55207056
Then it has to be a local dictionnary of lambdas:
n, s = -1, []
def _doStuffForOBracket():
n+=1
s.append(n)
return "whateva" % n
def _doStuffForCBracket():
r = s.pop() # or something
return "whateva" % r
_THINGS = {
'>': lambda: "\tadd $1, %rbx\n",
'<': lambda: "\tsub $1, %rbx\n",
'+': lambda: "\taddb $1, (%rbx)\n",
'-': lambda: "\tsubb $1, (%rbx)\n",
'.': lambda: "\tmov $1, %rax\n\tmov $1, %rdi\n\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n",
',': lambda: "\tmov $0, %rax\n\tmov $0, %rdi\n\tmov %rbx, %rsi\n\tmov $1, %rdx\n\tsyscall\n",
'[': _doStuffForOBracket,
']': _doStuffForCBracket
}
...
sys.stdout.write(_THINGS[ c ]())

It shows without the shadow of a doubt how inelegant and cumbersome Python's choice for lambda is. lambda being basically the constructor and essence functions, ANY given function should be representable as lambda the ULTIMATE. That's all I need to know.
>>
>>55207196
>because it's fucking irregular
It's not. Textually, there is a single line of all dispatched characters locally close to each other. Where as with a separate dictionary, you have to look in two disparate places to find a particular dispatch.
>>
>>55207215
That doesn't handle the potentiality of cases that don't want to print anything.
>Just return the empty string
Ugly.
>>
>>55207219
Not because this construction is worse than the if-elif one, it's because your both of you's lang is SHIT
>>
>>55206347
reply you fag
>>
>>55207234
No. Usage of the _THING means "determine what to print". It's self contained and it works.
>>
>>55207236
If you're arguing for a switch() statement, then the other Anon would still complain that "case" needs to be repeated.
>>
>>55207246
>Usage of the _THING means "determine what to print".
Indeed, my point being that it's ugly to force printing for cases that don't need to print anything.

Also, if the other Anon is to be consistent, he should still complain that "lambda" needs to be repeated in each case.
>>
>>55207253
Pattern matching is far better than switch, plus the syntax for most pattern matching is like this:

match (c) with
| 'x' -> ...
| 'y' -> ...

Syntax is not inherently repetition.
What you did was fucking repetition.
The fact that you do not consider it to be repetition is a stain on your intelligence.
>>
>>55207253
Yes, and you know what? He's FUCKING STUPID for saying that. I already explained why.

>>55207268
>Indeed, my point being that it's ugly to force printing for cases that don't need to print anything.
Fair point, maybe. It's so hypothetical tho... The benefits outweight the losses I'd say.
>Also, if the other Anon is to be consistent, he should still complain that "lambda" needs to be repeated in each case.
No, I already explained why.
>>
>>55207215
>needs explicit symbols to handle [ and ]
Horrible, senpai.
>>
>>55207270
>Syntax is not inherently repetition.
Why not? Why is syntax exempt from the rules?
>>
>>55207288
Because it's not repetition?
Are you dumb?
>>
>>55207278
Python is, indeed, quite ugly and unflexible. Makes my sigh at the idea that i'll be working with it in internship.
>>
>>55207296
By that logic, if the code in question were Python 2 and used "print" (which is a reserved keyword and syntactical rule in Python 2) instead of "sys.stdout.write", then it would be perfectly OK?
>>
>>55207306
No, it wouldn't.

"My grandmother's furious dad"
"My grandmother's furious, dad"
>>
>>55207314
Whatever is that example supposed to illustrate, pertinent to the discussion?
>>
>>55207306
No.
>>55207288
You are repeating fucking COMMAS every day. My argument (don't know for thirdanon) is that it's about the semantics: >>55206860
>>
>>55207326
They mean different things.
It's not repetition.

You are repeating the same structure:
if (x) then system.stdout.write(string)
...
>>
>>55207359
>>55207326

Otherwise you'd be fucking arguing "but you said repetition is bad so clearly the only valid code is 0123456789abcdefghijklmnopqrstuvwxyz.!"£$%^&*()(+-/.,*\t\n"
>>
>>55207359
You are repeating the same structure:
| ... -> ...
| ... -> ...
>>
>>55207386
No, you aren't.
| delimits the patterns
fist ... is the pattern
second ... is the result
There isn't a single pattern (at this level) that describes both of them
>>
>>55207375
Point is, you are indeed being repetitive either way; that's why I'm saying it's only a quantitative matter over just how repetitive your are, rather than a qualitative one. You just have to choose your poison. I prefer the slightly more repetitive but also more regular poison.

>>55207437
That's still repetition. See above.
>>
>>55207449
No you aren't. Stop being silly.

rev [] = []
rev (x:xs) = (rev xs) ++ [x]
>>
>>55207458
That's a different example. You are repeating the syntax when you have multiple patterns to match.
>>
>>55207469
No you aren't.
What I just said is the equivalent of this

rev | [] -> []
| x:xs -> (rev xs) ++ [x]
>>
>>55207485
No, what you said was this:
| ... -> ...
| ... -> ...
>>
>>55207499
Look at what I just said.
rev | [] -> []
| x:xs -> (rev xs) ++ [x]


rev | ... -> ...
| ... -> ...
>>
>>55207511
If Python had a macro processor, I could define | to be "elif c == " and -> to be ":".
>>
>>55207499
Retard
>>
>>55206497
>Are these all traps?
Yeah, I use my trap folder for testing right now

>Post source
https://github.com/DrabWeb/Gazo
>>
>>55207526
Patterns bind identifiers and are expression based, for instance a static map could also be done as follows

let stringify = function
| 'a' -> "somestring1"
| 'b' -> "someotherstring"
| _ -> ""
(this example doesn't show identifier binding, but does show expression based)

This is MEANT to be used with multiple cases, while if/elif is not. A lot of languages with pattern matches also have if and else for simple boolean cases.

If/else is just a specific kind of pattern match

| true -> ...
| false -> ...
>>
>>55207562
>Patterns bind identifiers and are expression based, for instance a static map could also be done as follows
Sure, but that's a different discussion. It doesn't change that in the particular case of the BF compiler, the syntax in >>55207270 is homologous to if ... elif.
>>
>>55207557
>Check the license file, gpl
>check the individual files
>Copyright © 2016 DrabWeb. All rights reserved.
>>
>>55207588
Xcode does that automatically, kind of annoying. I should probably go through and remove those
>>
>>55207662
I thought osx had emacs preinstalled :^)
>>
>>55207679
There, removed all the file copyrights. It seems you cant disable it in Xcode for whatever reason
Thread posts: 392
Thread images: 42


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

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


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