/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1548277908801.png (1000x1500, 1.23M)

Other urls found in this thread:

bitstagram.bitdb.network
regex101.com/r/cmy2vW/3
youtube.com/watch?v=vFTeN17Z4rc
twitter.com/SFWRedditImages

Gender reveal via Rust.

Any cool lesser known programming paradigms(preferably available as libraries)? Already using constraint programming and probably will use reactive programming in the future.

Inductive programming is pretty interesting

>Inductive programming
Is this what Idris uses?

This feels like it should be a solved problem, but I don't know what to look for. (Might ask wdg, but this is back end stuf)

I have a database wrapped in c# that gets accessed by multiple people over https, and they can do CRUD shit on it. The problem is if 2 people edit the same thing,
>both request the data from maybe multiple tables
>DTO is created and sent to each
>User edits DTO
>Users send DTO back
>Server reads DTO and makes changes to database
How do I detect that the data has changed when the second user tries to save his changes? My idea right now is to have each table have a hash column, and have the database calculate a hash for each row, the hash is sent with the DTO, and checked back on the server if it's the same when edits are made. The problem then is still what happens when a DTO is made from data in multiple tables, I'll have to manually aggregate the relavent rows hashes.

Convince me to not learn Rust.

Attached: 1548725325187.jpg (1280x720, 82K)

I’m making a Python wrapper for an API that provides sound tracks. First project where I could actually make a novel, meaningful impact for a niche community of developers.

Class max = null
for(Class c : arr){
try{ c > max ? max = c : ; }
catch(NullPointerException) { max = c; }
}

The solution is to not let two people edit the same thing. Use transaction and enable row-level locking.

How do you use a transaction over http?

Mai-ia-hii

mai-ia-huu
mai-ia-haa
mai-ia-ha ha
Mai-ia-hii
mai-ia-huu
mai-ia-haa
mai-ia-ha ha
Mai-ia-hii
mai-ia-huu
mai-ia-haa
mai-ia-ha ha
Mai-ia-hii
mai-ia-huu
ma-ia-haa
ma-ia-ha ha
Hallo, salut, sunt
eu, un haiduc
si te rog, iubirea
mea, primeste
fericirea
hallo, hallo,
sunt eu picasso
ti-am dat beep, si
sunt voinic
dar sa stii nu-ti cer nimic
Vrei sa pleci dar nu
ma, nu ma iei
nu ma, nu ma iei
nu ma, nu ma, nu ma iei
chipul tau si
dragostea din tei
mi-amintesc de ochii tai
Vrei sa pleci dar nu
ma, nu ma iei
nu ma, nu ma iei
nu ma, nu ma, nu ma iei
chipul tau si
dragostea din tei
mi-amintesc de ochii tai
Te sun, sa-ti spun,
ce simt acum
hallo, iubirea
mea, sunt eu,
fericirea
hallo, hallo, sunt
iarasi eu, picasso
ti-am dat beep, si
sunt voinic
dar sa stii nu-ti cer nimic
Vrei sa pleci dar nu
ma, nu ma iei
nu ma, nu ma iei
nu ma, nu ma, nu ma iei
chipul tau si
dragostea din tei
mi-amintesc de ochii tai
Vrei sa pleci dar nu
ma, nu ma iei
nu ma, nu ma iei

nu ma, nu ma, nu ma iei

chipul tau si
dragostea din tei

Lisp is the most powerful programming language.

I gotta make an image scraper for /c/, but is there any way to automate image duplication check?

Modern C++ already solves most of the shit in C, it's more mature and has much better and more widespread tooling. There is no reason to use Rust over it.

store in a file the list of the Jow Forums md5 hashes you have already downloaded

oh yea. Arigatou

Attached: 1446148347455.gif (261x432, 143K)

Instead of a hash use timestamp/rowvertion

My literal nigger!
I also quit learning how to swim after my first experience where I thought I would drown.

Attached: 1528686814715.jpg (782x1021, 98K)

What esolang is this?

Building instagram on the blovkchain

bitstagram.bitdb.network

Me odiaba mi primo
Por celos a mi carrera
Lo arrestaron y dijo
Que terrorista yo era

Guantanamero, onions preso guantanamero
Guantanamero, onions preso guantanamero

Ha decidido el imperio
Tenerme por siempre preso
Y la cuestión es hacerlo
Con o sin falso proceso

Guantanamero, onions preso guantanamero
Guantanamero, onions preso guantanamero

Cuando me hieren el cuerpo
Dicen que no me torturan
Causan heridas profundas
De esas que nunca se curan

Guantanamero, onions preso guantanamero
Guantanamero, onions preso guantanamero

No me permiten que duerma:
Mi fin no es un misterio
Voy a salir cuando muera
O caiga el gran imperio

Guantanamero, onions preso guantanamero
Guantanamero, onions preso guantanamero

I think they're song lyrics

I'm trying to figure out how this recursive code should work but so far no dice.

Basically I'm trying to simulate a "game" where players take turns moving around a board (essentially a graph), where each time a player moves the path they used is removed from the game. Once a player is not able to move to another node, the other player wins. I want to devise an algorithm that will determine whether starting at a certain spot will guarantee a win for player 1. Anyone have any pointers?

No, an example of inductive programming is synthesizing programs from test cases. For instance, you might be able to define the Fibonacci series simply by giving the first few Fibonacci numbers. It's usually driven by machine learning.

Induction in logic or dependently typed functional programming is different. To make things more confusing, inductive programming is usually declarative so you have "inductive logic programming" and "inductive functional programming" which still have nothing to do with mathematical induction.

Hey /dpt/, C brainlet here. I have function overloading setup in one of my libraries (actually inside the header), but I made the function symbols hidden. Is there anyway I can indirectly reference the function I need?

Here's how I have it setup:
bool __attribute__ ((visibility("hidden"))) check_base_str(const char *);
bool __attribute__ ((visibility("hidden"))) check_base_int(const int);

#define check_base(param) \
_Generic((param), \
int: check_base_int, \
char *: check_base_str)(param); \

Attached: 1549392664325.jpg (564x564, 59K)

Meh.
There is only one liquid to swim in, but hundreds of technical thingies worth learning. If it feels that a thing that promised to save time does the opposite, probably it indeed does.

But fine, I'll give it another try.

Attached: ac9a5e0827a0309329b9958461bc74c41418317847_full.jpg (640x360, 72K)

god that's just vomit inducing

It's not enough, I still want to learn it. I'm being lured in by the promise of being able to do systems programming in a functional style.

Attached: 1520718405922.jpg (1280x720, 229K)

Cniles will defend this.

>functional
There's no saving you

Doesn't LARPing get tiring for you guys? Do something other than scratching your balls and shitposting.

If functional programming is wrong, I don't want to be right.

Attached: 1550680576785.jpg (1280x720, 40K)

Ahaha
No
Except that you can have global pointer which you will initialize in library source file
But then you may as well unhide it instead

f(x) = (lookup 1, 1, 2, 3, 5 on OEIS)

Literally thought of that, but can't I make the func pointer a const?

We've gained nothing from programming besides another rod for our back. The time has come to destroy computing once and for all.

Attached: anime sunset.jpg (2880x1800, 423K)

Attached: maxresdefault.jpg (1280x720, 103K)

Okay, you can have this box of donuts now,

Attached: Shirobako-Header-001-20150319.jpg (680x400, 55K)

Attached: 1550532525713.jpg (883x960, 55K)

trying to learn assembly as my first real attempt at a programming language. ive dabbled in python but it feels so weak, and c looks mostly the same except you run it as .exe

i dont know what half the shit is but im gonna learn, Fuck

C question here! Trying to write to shared memory location but the output gets wonky at the end, it has "^@^@^@^@" over and over again. I get that it's what the shared memory is instantiated to or something but I can't seem to fix it, any help would be appreciated


fd=shm_open(name, O_CREAT | O_RDWR, 0666);
ftruncate(fd,SIZE);
printf("Enter the name of the file you would like the share: ");
scanf("%s",&in);

shm_ptr=(char*) mmap(0, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

file=fopen(in,"r");
if (file==NULL){
fprintf(stderr,"Could not open file\n");
exit(1);
}

char *buffer=malloc(sizeof(char)*512);
while (1){
fgets(buffer,512,file);
if (feof(file))
break;
strcpy(shm_ptr,buffer);
shm_ptr+=strlen(buffer);
}
fclose(file);


Thanks!!!

You don't have cast mmap, and you're probably fucking up when you read from the "in" file.

Python is interpreted, meaning there's an executable that takes in a python file and computes the result. C is compiled, meaning an executable called the compiler turns the C file into an executable. Learning C is a lot easier than learning Assembly starting out. Here's a hello world example for 64-bit Linux using the netwide assembler I like to throw out. Good luck.

; hello.asm Linux x86_64
; nasm -f elf64 hello.asm -o hello.o
; ld hello.o -o hello
SECTION .data ; Static data loaded when program starts, labels act as pointers to data
hello: DB "Hello world", `\n` ; Hello world string with carriage return
helloLen: EQU $-hello ; Length of string. '$' is current byte location in file
SECTION .bss ; Uninitialized data reserved at start of program goes here
SECTION .text ; Data after here contains instructions to be run
GLOBAL _start

_start: ; entry point for all programs by default, you can specify an alternative when linking
mov rax, 1 ; The system call for x86_64 write (sys_write)
mov rdi, 1 ; File descriptor 1 - standard output
mov rsi, hello ; Put the offset of hello in register rsi, specified in syscall table
mov rdx, helloLen ; Length of string. helloLen is a constant, so we don't need to say
; mov edx,[helloLen] to get it's actual value
syscall ; Call the kernel

mov rax, 60 ; The system call for exit (sys_exit)
xor rdi, rdi ; Exit with return code of 0 (no error)
syscall

Programming in asm is retarded. You need to learn a high level language first. Learn how the stack works, and then go back fucking around with asm.

Yep

If you're going to use static types then the syntax MUST be lightweight if you want to take full advantage of them, otherwise you will give up in a mess of noise.

Bad:
Cofree


Good:
Cofree [] (a -> b)

>output gets wonky at the end
Yeah, that's to be expected.
Consider:
fgets(buffer,512,file);

if (feof(file))
break;

What happens toward the end of the file if there is less than 512 bytes left? fgets() reads the remaining bytes into buffer and the eof flag is set. What do you do with these bytes? You check for eof and break, exiting the loop immediately before the parts can be copied. That almost certainly isn't your only bug, because that should just cause premature termination of the contents. I'm also worried about your scanf not having a width specifier, but that's another issue.

It's Malbolge

Nothing and it makes me want to kill myself
My uni cucked me last semester so i couldnt take my programming course and now i cant take this semesters cause i dont have last semesters so i have no coding assignments which were what I lived for

I agree on functions (but this assumes you have 1 function type) and on application (but you can dispute this), but i diasgree on lists

Why is a git repo of visual studio project so ginormous? around 400Mb or so. It wasn't possible to upload to my github account because of this reason. This is a new project with under 1k loc. What did I do wrong?

Attached: 1549821769937.jpg (650x433, 40K)

you probably uploaded the binaries, debug symbols and other garbage which you should put on your .gitignore list

I don't think there is any other way than actually simulate all possibilities, maybe with some backtracking. Looks like NP. As for doing this recursively you should have no problems, have a function like move(board, p1node, p2node) and for every adjacent node of p1node and every adjacent node of p2 call itself.

Can anyone help me with this regex I need for the Jow Forums X extension I'm using. I want to hide all threads on /gif/ where the OP's comment includes the word "gay". If the comment says "no gay", which means that the word "gay" is preceded by "no " then there should be no match though.

I found an example that comes close but I have trouble translating it. \b(?!girl)\w*friend\b which matches all occurrences of friend except girlfriend. Pls halp.

regex101.com/r/cmy2vW/3

You may either need to learn some library (to realize that you can do anything if you find the right library), or learn how the OS works (to realize that you can do anything if you ask nicely to the kernel without any third party library), or you need to learn about computer architecture and ASM (to realize that you can do anything even without a kernel if you know your hardware and have unrestricted access to everything). Ideally, you should know all 6 (I forgot to mention networking, compiling/linking/etc and functional/recursion/other paradigms and patterns).

In short, when learning to code the code itself is the last of your problems.

part of the reason i'm learning asm is to understand computer architecture better'

ask me anything about Haskell

what's the use

same as most other langs except that it's nice to program in

Rust is not functional at all. If you want to do systems programming in a functional programming language, then you should use AST or something. In any case, functional programming and systems programming are incompatible concepts because functional programming puts emphasis on side effects free programming, which is at odds with systems programming.

y r u gay?

Ok. I had to do it myself. The solution was (?

^(?!.*no gay.*).*gay.*$

Blodwen hype?

Ok. I will use this instead. I trust you more than myself. Thank you.

I'm not

The problem you have is the prefix. If you check word by word (that is what \b does) matches the string "bla bla bla no gay bla bla" when you check the word "gay" alone. Without the space it would probably work. So to solve this you have to check line by line instead.

the fuck

Is there a way to tell if you're a talented programmer before you spend a thousand+ hours grinding until you get to the point where you can perhaps begin to profit off your investment?

Depends. How are your math skills?

>Is there a way to tell if you're a talented programmer
the answer is no, nobody here is a talented programmer, especially me

Attached: 1548277643973.jpg (500x700, 133K)

those thousands of hours is what makes you a good programmer

Explain Arrows, Lenses, and Zippers.

not that programmers are any better elsewhere, they're probably worse

Attached: 1548013678658.jpg (1280x720, 500K)

Buzzwords.

There is no such thing as talented programmers. There are famous programmers, rich programmers, programmers that have accomplished something, but there are no talented programmers. Programming is a science not an art and there is no such thing as talent in science. In particular, following a style guide doesn't make you talented.

Ah okay. I should really learn regex in more depths. I find myself again and again in situations where I need to match patterns. Thanks again kind stranger.

Why am I getting a connection error when I try and post code?

Attached: 65253239_p0.jpg (1000x826, 144K)

>Programming is a science not an art
yikes

>There is no such thing as talented programmers
oh no no
>Programming is a science
no no no no

Attached: 1550167876323.png (480x336, 301K)

youtube.com/watch?v=vFTeN17Z4rc

I just masturbated and now I feel stupid. Time to coooocde in C.

Attached: 1547923778123.jpg (750x422, 30K)

why don't you masturbate in C

programming is just monkeytyping.

If you're trying to post it in quick reply, use the reply box at the top of the page instead. It's cloudflare, it will ask you to solve an additional captcha.

Why would you use overloading in a language that doesn't even support types properly?

>mfw everyone ITT is an Anime girl

Attached: 1508867032437.jpg (795x946, 322K)

You're a silly monkey.

Don't learn regex, learn computing theory, that is, set theory, language theory, automatas, regular expresions, etc, and once you know what is a regular expression in theory learn the specific syntax used by regex.

Also, if you often find yourself parsing text learn to do it properly, that is, the first 2 or 3 chapters of the dragon book (at last that's my material). Either that or find a good parsing library and stick to that, but learning to do it yourself never hurts.

>mfw it's true

Attached: Dz6527bU8AEABu3.jpg (606x900, 74K)

I only have experience with Javascript, Html, Css, and Jquery.

Could someone give me the name of the program I need to import and use a database within Javascript.

I am making a game of Scrabble and need a dictionary to check if a word is valid.

Bookmark a regex tutorial on Github and that's enough.

do anyone have pdf copy of ISO/IEC 9899:2018?

ah yes, ISO/IEC 9899:2018...

Attached: 1548822019636.png (805x720, 553K)

Yes.

Attached: 1550755926229.png (1200x1600, 1.38M)

4th edition? gimme pls :-)

Unite, my Animites, under the monotheistic goddess Satania we shall drive out the amigdylets and shitty C and sepples code for good.

Attached: 1549681368134.jpg (712x719, 102K)