/dpt/ - Daily Programming Thread

op.image.isAnime() == true edition

What are you working on, Sup Forums?

Previous:

Other urls found in this thread:

hillaryclinton.com/api/selfie/validate_text
hillaryclinton.com
hillaryclinton.com/inhonorof/honoree/
twitter.com/addyosmani/status/793197147713773568
en.wikipedia.org/wiki/Murder_of_Seth_Rich
linux.die.net/man/2/time
stackoverflow.com/questions/1674126/how-to-get-a-random-letter-in-java
twitter.com/SFWRedditImages

>no anime image
>xkcd
Bye Sup Forums.

>autism triggered

ok so i can code now (finished buckeys C++) now what?

I'm fucking tired of having to use Windows just to play one fucking game

I hate developing on Windows, I hate everything about this shitty operating system

>Don't play that shitty game
Fixed.

...

Dual boot, you retard.

Some guy in the dorms only uses facebook to text, I don't use facebook, so I'm making a messaging application. Currently writing a thing to guarantee every recipients gets all the messages, even if they weren't online when the message was sent.


Writing it all in java

>bucky teaching anything worth a shit
(You)

what game?

not even meming i did 72 tutorials now idk what to do

osu!

does anyone have the extended xkcd comic or its copycat where you have different excuses for different branches of jobs like 3d modeller saying it's rendering

nethack

i wasn't questioning that you finished his tutorials, i was questioning that you actually can program as a result

Yes, I want to know two

So I'm learning python and want to make a script to crack common codes and ciphers here's what I plan on having binary, hex, decimal, ceaser shift, base64
I know binary, hex, decimal and base64 aren't codes or ciphers but I see them being used on /r/ciphers a fair amount so I decided to add them

anything else I should add, just looking for ones commonly used and crackable

Make a thing

...

I use UpperCamelCase for types and lowerCamelCase for not-types. Fight me.

...

well i dont see why not, i mean hes basically a spoken version of an intro to code book. he just teaches in an odd order.

yes but what thing.

Dual booting is inconvenient

he basically just lists features of the language and uses them in contrived examples without actually explaining anything

make a program that inverts a binary search tree (left becomes right & v.v.)

This. Dual boot is like living in two homes at the same time.

>solving the problem the guy had two threads ago
nice try guy from two threads ago

Is there actually any use for Hungarian notation

or it's like having a home and a workplace, or a home and a studio. you may just be using it wrong if it's potential positives are negatives for you

> object Object; //:^)

I don't use that kind of language.

i never said i could do that sort of programming.

i doubt he actuallly understands it himself, or all of the other languages he teaches. i sort of subbed it with other learning but now idk what to do.

invert(BST myTree){
BST newTree;
newTree.left = invert(myTree.right);
newTree.right = invert(myTree.left);
newTree.value = myTree.value;
}

> struct object *Object; //:^)

Nope. Fuck everyone that use abbreviations. There are completely useless if you aren't an old cuck that type more than 2 words.h^-1

could be useful for writing auto documented code in a dynamically typed language.

>He works on open source software.

kek

ITT: Cancer

well, you know that more and more proprietary softwares are now open source, right?

>pic related
hillary's website has a server side word list that bans certain names. let's have some fun with their api :)

POST hillaryclinton.com/api/selfie/validate_text

> request headers
Cookie:uwotm8
Host:www.hillaryclinton.com
Connection:keep-alive
Content-Length:20
Origin:hillaryclinton.com
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1
Content-Type:application/json
Accept:*/*
Referer:hillaryclinton.com/inhonorof/honoree/
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8

> request body
> raw (application/json)
{"text":"Seth Rich"}

related Sup Forums thread:
pic related is an example

pointers, are we for or against them and why

daily reminder that webdevs are the trashmen of computer science.

twitter.com/addyosmani/status/793197147713773568

Made this little thingy.
How would you improve it?

char* IntToStr(int number)
{
static char result[32] = "";
char digits[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
bool negative = 0;

// Clear (static) result array
for(int i = 0; i < 32; i++)
result[i] = 0;

// Edge-case for 0
if(number == 0)
{
result[0] = '0';
return result;
}

for(int i = 0; i < 32; i++)
{
if(number < 0)
{
negative = 1;
result[0] = '-';
continue;
}
if(number == 0)
break;

result[i] = digits[negative + number % 10];

number /= 10;
}

//reverse(result, result + strlen(result));

return result;
}

What's the point? Are you trying to build a list of banned words?

I don't get it.

pointers are just another kind of comonad

the banned list of names will be telling

e.g., Seth Rich is probably the guy who is behind the DNC Leaks; he died under very suspicious circumstances:

en.wikipedia.org/wiki/Murder_of_Seth_Rich

Could I write a geometry shader in OpenGL that takes in number of sides as a vertex attribute and then makes a regular polygon around it?

Also is the correct place to transform/scale/rotate a shape in the vertex or geometry stage

known banned words so far:

Seth Rich
Vince Foster
Monica Lewinsky
Gennifer Flowers
Paula Jones
Julian Assange
Anthony Weiner
Chris Stevens
Juanita Broaddrick
Sean Smith
Benghazi
Tyrone Woods
Glen Doherty
Embassy Cat
Super Predator
Bill Clinton's Cigar

Holy shit.. Also I don't think we need more proof that Hillary is a cunt.

Let's say I want to download 10 files simultaneously and have their completion percentage display in the terminal in realtime.
like so:
file 1 -- completed 65324 bytes of 135220 total (47%)
file 2 -- completed 1276 bytes of 109220 total (1%)
...

How would I do that with pthreads in C?

I don't really understand how you could get all the files to display in the correct order upon every carriage return when dealing with threads.

Yes. Normally, you'd do that in the vertex shader but if you're generating geometry in the geometry shader you often have to put some or all of the transformations after that.

char *IntToStr(int number)
{
char str[15];
sprintf(str, "%d", number);
return str;
}

I wanted to use my own implementation, obviously.

Your own implementation sucks and is not optimized for the compiler

What about it sucks?

>Bill Clinton's Cigar
lolwhat

That it isn't optimized for the compiler.

Via locks. All threads have to report in an array how many bytes are received, and how many are expected (if you are talking about HTTP that cannot really be done unless Content-Length is available as an header). Then the main thread has to constantly go through the list (locking it for reading) and display the status of all threads.

Since printing takes a long time, I'd considering just creating a copy of the list in the main thread's stack and then releasing the list immediately. That way all threads that want to report their current status don't wait too long on the output of the main thread.

What's the semantic difference between a class and a struct?

In c++ the only technical difference, afaik, is the default access level to members. My autistic friend insists that structs should not have methods, but that just means i have to write any functions that operate on the data in the struct as taking one extra argument. To me this seems conceptually exactly the same as a method, only with slightly more annoying syntax.

>Your own implementation sucks and is not optimized for the compiler
>sucks and is not optimized
>sucks AND is not optimized
>AND
>implying there are reasons behind why it sucks, in addition to it not being optimized for the compiler
Sick reasoning, bro. I'm guessing English isn't your first language AND you're retarded.

Also why the fuck would it matter if that code was compiler optimized or not? It's obviously not meant to be used at a low enough level for it to matter. You're trying too hard.

whats a better way of doing this

//checks if the current time is unix time

systime = time
x = 0

fetch systime

for (x

I like to use struct for something that is POD (i.e. C struct semantics) and class otherwise. POD means no private/protected members, no virtual methods, and default destructor/copy/move constructors/operators. However, a struct can have methods as long as they aren't virtual and remain POD just fine.

>linux.die.net/man/2/time
>time() returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
>Conforming to SVr4, 4.3BSD, C89, C99, POSIX.1-2001

You can be sure that time() always returns the UNIX time.

>14 million lines of code
>entire project compiles in you will never be a programmer in the 80s when you did daily builds because it took all night to compile

This makes sense to me.

I've been gone for a while, this pajeet meme is pretty lame

this is why you dont just compile an executable, you have smaller easily replaceable files

no, today you wait the whole week for eclipse to start.

Pajeet here.
It's not a problem. I know a lot of people who last used C++ 10-15 years ago and nobody died, they are good specialists, but if they have to use it they would learn it quickly again. C++ itself as a language won't give you shit, besides shitty memory management practices.
Now we need to know technologies, APIs, frameworks, 3rd-party software, you need to be more a devops/build engineer/admin/troubleshooter than actually a software developer. You need to represent several professions in your skills. You use your smartphone, but I don't think you have full grasp how it works inside, you can develop programs in java or swift without having full understanding about smartphone guts, even 11 y.o. can. You just need to have some basic understanding about low-level programming, but everything is already done for you by other people, you just need to know how to properly use it. Every language gives you a set of abstractions. Every product if it has at least a little bit of self-respect offers api clients for many languages. Now we can do mobile development using C# with Xamarin, it would be impossible even 10 years ago.
Nowadays it's highly recommended to be a quick learner. The matter is not in a language. You should be really smart to be a good developer. On my personal opinion you can be a programmer only if you were top of your class at high school, you have to have a good memory, because in the real world you will investigate issues not having anything, by indirect sings you need to understand the reason of some failure, you need to be a really smart guy otherwise your job will turn into torture for you. You can't learn it - you need to have a talent.
Think twice. If you are Pajeet like me and was born in a shithole than go ahead and be a programmer, because we have no other choice, but if you are from a country like germany, usa, canada, italy with set of available professions and you have other choice I would think twice if I were you.

How many LoC is Qt? I've heard it's a monster to compile.

The game engine we worked with at school took a couple of hours to compile.

...

If you want to make sure your struct really is POD, you can include and put static_assert(std::is_pod::value); somewhere.

>omitting the part where he turns and calls his wife's name

Weak.

The problem with all C++ projects is not that those are monsters. I mean, they are, but that's not the problem.

The problem is that compiling C++ code takes unbelievably long because of optimizer shit.

Qt takes forever because of generics and template hell. Once it is compiled though, you should create a precompiled header for your project to avoid recompiling qt everytime you change a header file.

Oh, i thought was complaining that everything compiles too quickly today.

disable optimizer then


also where does this monster stereotype come from? as opposed to what??

Currently working at a company 30 years old, still using BCPL, still using a reaally old hardware architecture that they custom build virtual emulators for because there is no where in the world that supports it as of 10 year sago. Still takes 8~ hours to compile and build all of the codebase to distribute to test machines.

I am not him. I wish projects like thunderbird or firefox - or generally all C++ stuff - wouldn't take so fucking long. C compiles so damn fast and C++ so damn slow that if I had hair left I'd tear it out.

Why would i not know if my struct is POD? Am i an idiot?
Well, i mean, yes i am, but i'm not THAT stupid, am i?

It's not my wallet

>its all going to end soon

>disable optimizer then

If you disable optimizers your code literally becomes shit covered in shit-stained rags begging to be tossed in shit. The reason why people program in higher languages is because of the fucking optimizer which is supposed to produce better code than what normal people can do with assembly.

Fuck you with "disabling optimizers".

I forgot to mention that all the fields also need to be POD. So you could make a change to the type of one of the fields that makes it non-POD, and you might not realize that you've now made everything that contains it also non-POD.

Wat?

In any case, i learned about a new thing in the stl. Thanks for that.

UGH I hate how my code compiles quickly

you were born too late

Why do i get that symbole?

you forgot to add the offset for ascii in the second for loop

How do i add it(im beginner)

Could it be you actually meant 'a','z' instead of 1,26?

Are you retarded? it's the other fucking way around you dipshit

same way you did it in the first loop

Retard:
>stackoverflow.com/questions/1674126/how-to-get-a-random-letter-in-java

I hope you pajeet die soon enough.

r/ciphers is a fucking joke. Also, hex is not encryption ffs. Neither is decimal you fucking pleb. But seriously, some of the posts on r/ciphers are ridiculous.

It sucks that it lags with playonlinux.

If you play visual novels and stuff you can still use loonix

read my post
>I know binary, hex, decimal and base64 aren't codes or ciphers
is there a better place to learn about codes and ciphers, maybe r/codes or something? or will I just have to stick to books?