/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1557563355902.png (1196x1448, 1.06M)

Other urls found in this thread:

learngitbranching.js.org/
youtube.com/watch?v=rqX8PFcOpxA
phauna.org/papers/anime/anime.pdf
fsf.org/campaigns/priority-projects/
opensecuritytraining.info/IntroX86.html
twitter.com/SFWRedditImages

Rewriting HolyC in Common Lisp.

Attached: 1557316398284.jpg (1181x1748, 154K)

senko would use javascript, because she's shit

2nd for lisp is unintuitive

I have a program which runs through instructions listed in an array kind of like a simulated computer which prompts the user to input 3 characters when it starts off. It uses read(STDIN, pointerToArray, length 3)
However, it sort of just skips the read() part and moves on to the next instruction cycle. Maybe it does invoke read() but the program keeps executing past that which is not an intended consequence. How can I make the program halt until I press enter on the read() function?

main()
main()
{
struct obj a;

load_program(&m);
while(1)
{
fetch(&a);
execute(&a);
sleep(1);
}
}

execute, only function that matters
void execute(struct obj *a)
{
char c[3];
if(a certain variable = 1)
//prompt the user to type in 3 letters. THIS IS THE PART THAT GETS SKIPPED
read(0, c, 3);
a->id=c;
else
//continue with the other statements
}

other functions if it matters to you
void load_program(struct obj *a)
{
//basically just initializes all variables of a
}


void fetch(struct obj *a)
{
//basically just points to a current part of the program
}

Attached: 1513593083331.jpg (800x1036, 124K)

Senko is as cute as C++, as useful as Haskell, and as competent as Go.

Attached: 1555099085754.gif (800x900, 1.42M)

How did /dpt/ learn git?

Attached: 1554182124527.png (715x726, 1.18M)

Attached: htdp2.png (859x1005, 698K)

Your terminal is buffering input, so your program won't even see it until you press enter.
You can set your terminal into something called "raw" mode which stops it from doing that, but that's not usually something you want to fuck around with.

>as competent as Go
what did she mean by this

but why won't the program halt when doing read()? If I recall, read is a syscall which halts the process until it has finished

Cute!

Attached: 2db0e8ae8dbabc454c3ba56d6c1970dc.png (708x1000, 723K)

>If I recall, read is a syscall which halts the process until it has finished
That not always true, but is the "default" behaviour for it most of the time.
Anyway, rereading your question, it sounds like you've forgotten to account for the fact that newline is a character in the buffer, so there are actually 4 characters you want to read.

By using magit from within emacs.

Bump for the best loli

Attached: 1557621402070.jpg (1280x720, 293K)

learngitbranching.js.org/

Attached: 6489.jpg (2560x1440, 508K)

Is there something like magit on vscode?

Attached: 1554692377703.png (1280x968, 2.09M)

Just learn emacs. I don't know of anything coming close to magit without emacs.

Attached: 1555493604806.png (1000x709, 974K)

Are there any good programming channels on Youtube besides Computerphile ? Most of the stuff I come across is either greasy self help selling six figure dreams or some web dev crap I couldn't care less about.

WHAT THE FUCK IS YOUR PROBLEM YOU DISGUSTING PEDO SCUM
WHY CAN'T YOU BE DISGUSTING SOMEWHERE ELSE
I FUCKING HATE YOU SO MUCH

conference video channels are usually good, e.g. cppcon, icfp
this

Attached: 1556480871706.jpg (1024x576, 90K)

Ok, reddit-kun. Here you go.

Attached: 72491702_p0.jpg (2185x1553, 1.45M)

my $ref={(professor=>[qw(lamp shade camphor oil bing)],
student=>[qw(lamp shirt tea)],
stacy=>[qw(phone laptop dildo chad silver)],
)};

my @res=grep
{

grep $_=~/lamp/,@{$ref->{$_}};

}keys %{$ref};

say "@res";


Does it look very ugly to you?

rararu

It's not Lisp or Forth, so it's ugly by default.

so how would I make it interrupt until 4(minus 1) characters are typed in?

Change the 3 to a 4.
But really, do you need to use the low-level IO functions here? I'd typically recommend you use getline() for interactive or otherwise line-based programs.

>But really, do you need to use the low-level IO functions here?
yes. The tutor required us to use syscall(2) so I lied that I used read() :))))))
Just to make it simpler to understand. I mean syscall(0, 0, c, 4) is basically the same but it's more flexible

why the fuck are so many programmers autistic anime pedophiles
please fuck off

You can get away with not hard-coding all of these random numbers by calling it like
syscall(SYS_read, STDIN_FILENO, ...)
But anyway, increase your buffer size so it's 4 instead of 3, and discard the newline.

no u!
we were programming first

There's for "people" like you. Just stick to that instead of shitting up a pedophile website.

Attached: 1553932585862.jpg (1949x2048, 260K)

You keep coming back for more, don't you?

Attached: 1557054974928.png (1208x1203, 1.06M)

Competent at making even retards productive.

why do you come to an imageboard for autistic anime programmers? you secretly like it

man git

No, nobody likes you and you willd die alone.

Why aren't you? Please kindly do the fucking off.

Attached: 141bb1f31e35d8c7fafc38d3fd72e31d00030636.jpg (500x571, 282K)

youtube.com/watch?v=rqX8PFcOpxA

phauna.org/papers/anime/anime.pdf

Attached: 0c883fd8d259f56922f5cfe9c8dc7f25.jpg (810x810, 209K)

>unironically uses the term 'cyberlibertarian' when discussing ecchi
0/10 into the trash

Attached: 1549577835390.jpg (800x600, 80K)

woman git

shitlord

...

This:

this
so tired of these misogynists

Hoe about demuxing it with ffmpeg? Its C libraries (libavformat, libavcodec etc) are quite easy to use.

Not him but I'm pretty sure he's being ironic.

I'm pretty sure I still want him gone.

Well I can't fault you there.

Give me ideas for a project that is not necessarily web related at it's core, but for which a web based interface would make sense for demonstration purposes.

>something you could actually use in your everyday life
>anything else you can think of that might be cool

my interests include
>engineering
>math
>physics
>EE stuff
>typical memes like neural networks, but I probably won't have the required datasets for that


I guess I just don't want to make another game that noone will play.

still just instantly skips the read syscall. I have even tried to fork it and have the parent wait for the child, which does the syscall and then exits, with mild success but it still immediately(although now with a slight delay) proceeds to the next part of the program
fooken frustrating

Attached: 1440768367797.jpg (232x197, 16K)

fsf.org/campaigns/priority-projects/

what's the data you get out of it?
what's the return value?

read just makes the user type in 3 chars to give the struct an ID, say ABC or something so it doesn't return anything. Just directly accesses the variable in memory

oh shit, maybe the syscall is skipped because I haven't assigned its return value to any variable. I will try that

it returns how many characters it read, or -1 if an error happened

is it really skipped? try running your program under strace to see if it is genuinely skipped or just didn't do what you expected it to do

nope, didn't do anything

>if (variable = 1)
>variable = 1
>=
shiggydiggy thats just you being lazy, not your actual code

>tfw when to shy to contribute to cool project while fairly sure i can do it (`._.)

did strace -e read ls -l
none of the read syscalls used STDIN so I guess it got skipped

It's OK. You can have goals and work towards them. Who knows, some day you might wake up and see an opportunity to make a commit and feel willing to do so!

You can do it, user, all in your own time.

Write a shared_ptr on a whiteboard and you're hired!

Attached: 1557637066770.jpg (1440x2128, 835K)

why are you running ls?

If you can't do that you should just fucking stop writing in C++ immediately and go back to Python.

how hard is it learning assembly compared to learning a high level programming language?

nvm about that, I forgot how strace worked.

Most operators are very basic. Add, move, shift, etc. Then there are some opcodes that are wizard level. I'd say go for it if you are interested, just don't expect to be making rollercoaster tycoon in a week.

I like this resource for x86 opensecuritytraining.info/IntroX86.html

>What are you working on, Jow Forums?
Learning some things about Kotlin. I am getting closer to getting my raw h264 frames over tcp.

Attached: bordel.png (1920x1040, 124K)

Thank you

because I have only used strace once in my life and that was a few months ago. Please excuse me for my retardedness.

Would
strace -e read ./compiledprogram.out
give me the desired results?

>tfw too retarded to get into computer vision
i... i only made it through trig...

look mom, I memorized it all

I am going to put up an .io web game that is Jow Forums related, give me some ideas.

>memorized
Don't call us we'll call you.

You need a logo and a good domain name first.

Attached: 1493874432843.png (377x330, 8K)

this, also makes it anime related

Why should one learn Assembly?

There's no actual reason to use assembly outside of kernel development.

I've already put up a few, they are not hard, literally just switching out graphics, but instead of bullets/instant projectiles like most .io clones I'm going to make it less violent, characters will throw items that have hang time.

I thought first of a 5v5-10v10 border crossing game where 10 trumps on top of the wall throw projectiles to knock out the jumping mexicans (other team) who are trying to jump over the border, if enough mexicans jump over the border then the defending team loses that round, there will be leaderboard and win/loss stats for profiles.

Anyone worked on sqlite in C(or C++) and saved an array to a BLOB?
Would this be the correct syntax assuming you have prepared the INSERT query already?
rc = sqlite3_bind_blob(stmt, index_of_query, array, sizeof(array), NULL);
if (rc != SQLITE_OK) {
printf("ERROR: %s\n", sqlite3_errstr(rc));
sqlite3_close(db);
return;
}


and to retrieve it, would this be the correct syntax assuming you have prepared the SELECT query already?
if (sqlite3_step(stmt) == SQLITE_ROW)
{
unsigned int *temp = (unsigned int*)sqlite3_column_blob(stmt, 0);
memcpy(array, temp, sizeof(temp));

Attached: 1503637236855.png (1280x913, 1.19M)

What about for like reverse engineering stuff? Isn't that how they make emulators or port games to linux and stuff? by knowing assembly?

I don't use it a lot either, but that looks good to me

>Anime: From Akira to Princess Mononoke
kek

Thank you, user.

>What are you working on, Jow Forums?
Test coverage and docs. Pretty much done until I want to work on the standalone server.

Attached: Screenshot_20190512_162058.png (892x885, 184K)

cracking, hyperoptimized stuff, reverse engineering, gaining a slightly better understanding of the underlying electronics hardware

Writing compilers.

Does anyone know why I keep getting the compile time error "undefined reference to `foo()'"? Both g++ ad clang++ give me the same error.

foo is a non-member function of class1.

declaration of foo on class1.h
bool foo();

definition of foo on class1.cpp
#include "class1.h"

bool foo()
{
std::cout

probably because class1.cpp and class1.h wont compile

Also probably forgot to add class1.cpp to compiler command

It's not a compile time error but a linker error.
How are you compiling your project?

Github documentation and Atlassian tutorials, then practice of course. Before blindly using a flag, look it up first. Flags are usually used to combine more than one simple operation. Eventually you will understand how it works, how the operations work on it, and you will finally grok it.

If O(nm+n)=O(nm), is O(nm+k)=O(nm)? Or do you have to keep that linear factor in this case?

Memorizing the standard does not mean you can write good code.

what are n m and k? if m and k are constants then O(nm+k) = O(n)

It's not a problem of memorisation, brainlet.

>clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
Apparently you're right, user.
I'm using VS Code and from the looks of it I didn't configure the tasks.json file properly. I thought this kind of stuff would work out of the box. Well, shit! I will look into it.

Why would they be constants?

Say the O(nm+n) algorithm is iterating over a n*m 2D array and then a single row of size n for whatever reason. Clearly this is just O(nm).

Say the O(nm+k) algorithm is iterating over a n*m 2D array and then a different 1D array of size k. Can I say it's O(nm) or is it O(nm+k)?

Post them!

Attached: Screenshot_20190512_164727.png (763x196, 14K)