/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

ocw.mit.edu/courses/mathematics/
youtube.com/watch?v=SlCRfTmBSGs
twitter.com/NSFWRedditImage

Minecraft clone.

Just wrote some code for moving around the currently static voxel scene. I found out that mouse movement is horribly jittery when it's raw so I'm averaging mouse input over 4 frames right now.

Why don't you write it in a real language?

rad

Finishing up a cleaning routine for Teknik Accounts.

I am though user kun.

rate this ARM code for copying a 32 byte block of mem:
INIT ADR R1, BLOCK1-4
ADR R2, BLOCK2-4
ADR R3, BLOCK1+28

LOOP LDR R0, [R1,#4]!
STR R0, [R2,#4]!
CMP R1, R3
BNE LOOP

nice, rate mine
memcpy(dest, src, 32);

are you implementing your own backface culling or something?

No I let opengl do backface culling. When non-air blocks are touching other non-air blocks, the touching sides are not visible so I'm setting a flag to not render those sides when I compile the VBOs.

>not Aarch64
disappoint

I'm shit at math. Are you guys shit at math also? I feel like I need to get better at math. How do I get better at math?

What should I start looking into for general network programming in python.
Like HTTP clients and IRC bots.
Any libraries or resources in particular?

ocw.mit.edu/courses/mathematics/

import socket

youtube.com/watch?v=SlCRfTmBSGs
but yeah im pretty terrible at it
its not that i dont understand it, its just so goddamn boring

Practice.

Study a geometry or number theory textbook and do the practice problems and you'll git gud.

Number theory is fun nigga

learn sockets, and then look at the specification docs of whatever protocol you want to implement
or start writing your own

I wrote a thread scraper. It's better than my previous one.

for irc shit

import socket
import signal
import sys
[\code]

if you want to do shit with packets

import scapy [\code]

but if youre not on a linux OS good luck installing scapy properly

Post it running i want to see your progress...

porting my cheating library to be framework agnostic (currently only works with Directx9)
i had no idea writing a graphics abstraction layer was this painful holy shit

whats a good way to parse arm assembly im looking to make a mini assembler. finite state machine?

how do i know the difference between
ldr blah blah
and

ldr:


with labels and such

Check for the colon at the end?

if its reading ldr r0, r0 and suddenly theres a : at the end it just suddenly scratches everything and goes "oh its a label now" but theres gotta be an efficient and generic way to interpret it

prematurely check for semicolons at the end

BNF.

explain

basically what I said
instead of parsing the whole thing from the beginning search for clues like a colon then break into tokens / skip

>search for @ at start to determine comment
>search for : at end to determine label
>search for . at start to determine pesudo-command
>parse token-by-token as arm command

how do i know what order each thing should be checked in

It runs at a smooth 60 fps right now I just don't know how to record high quality webm video. Because VLC and Arista are bitches, VLC producing output with glitchy 11 hour long "duration" and Arista not working at fucking all, I had to use a sketchy online converter.

This looks a lot less than what it is. The scene you see here is actually made up of 4 1-by-3-by-1 chunks that each render with their own VBO. Splitting the scene's VBO up means that modifying a bit of the scene doesn't require recompilation of the entire scene. Not useful for this but useful for larger scenes. When blocks touch, the sides that touch are culled as you can see by the scene completely disappearing when I enter the blob of blocks rather than rendering the sides of the inner blocks.

There is saving to and loading from disk: this scene saves into four files: config.ss, 1.bin, 2.bin, 3.bin, and 0.bin.

Config.ss
(finiteworld (2 1 2) (1 3 1) (4 4 4 4) ((stone . 0) (air . 1) (grass . 2)))

The 4 4's are the length of each n.bin in shorts.
$ hexdump boringwold/0.bin
0000000 0002 0000 0001 0002
0000008

Each n.bin is run encoded, so that's 2 0000 blocks and 1 0002 block.

Tomorrow I'm going to add block picking so that the block in the center of the screen gets an outline drawn around it. This will allow me to program in block placement and destruction based on user clicks (I can already modify blocks at a location and partially recompile the scene). At which point if I wanna get up to minecraft classic levels of functionality it's create menus and add more block types, and support for transparent blocks.

Looks pretty good!

you could have something like a pre-check for colons in the next few instructions in a thread while parsing the already checked instructions, the order is up to you, try different ones and watch for performance

MOJANG ON SUICIDE WATCH

>basically what I said

No.
You write a BNF that describe the langage you're parsing so it helps you defining formally the procedures needed to parse that language.

hash extension demo for class, and learning ruby

>all these buzzwords
try again and this time make sense

Don't be a lazy fuck.
Formulate a proper grammar and use a fucking parser generator.

Shit nigger thats pretty dank...
Got a github id like to watch your progress

Thank you for using lisp.

Carmack already moved to Racket

What game?

"don't look up the answer on HN edition"

void free_circularly_linked_list(struct node *head) {
struct node *tmp = head;
do {
struct node *next = tmp->next;
free(tmp);
tmp = next;
} while (tmp != head);
}

So apparently there's undefined behaviour here. I lost a fucking hour looking for it. Fuck C.

Use OBS then just download ffmpeg and put a command to convert to webm

obviously

>Fuck C
Not C's fault you don't know the language, m8!

Apparently C doesn't even know itself!

You sound like an imbecile, no surprise there.

whats undefined?

the behavior

go fuck yourself

are you dumb or just pretending?

51 posts in, and no shitposts yet.

Is this actually /dpt/, or have my fellow Americans just not woken up yet?

I've literally never needed math beyond basic algebra and a little statistical analysis.

That being said, I don't do any real-time graphics programming at all.

Maybe tmp being freed without being checdked for NULL? But I dunno C so maybe that's not even UB.

free(NULL) is defined

See

No shit posts?

>post non-trap thread early
>someone whines hard
>post trap thread early
>no one complains
gee what a surprise

kill yourself fag

dont you guys have better things to do than argue about this shit single every day?

you are not checking if head or tmp is not null thus tmp->next is undefined behavior.

the code is undefined behavior even if head is not null

why ? explain

} while (tmp != head);

i don't get it.

head is not a valid pointer anymore

I need to implement a noise filter in python2.
However, I can't use scipy, because I have no clue how to bundle it with the application.
What's the best way to filter this? I found stuff about kalman filters, but they seem to be better for 2D arrays.
And I don't seem to be able to find proper examples online

and ? head is not deference here.

it doesn't matter; just using the value is enough to trigger undefined behavior, just like reading an uninitialized variable

is uninitialized variables as big of a problem in C++ as it is in C?

not it's not, otherwise diff pointers would be illegal.

Yes

>just using the value is enough to trigger undefined behavior
what

what do you mean by "diff pointers would be illegal"?

"while (tmp != head)" reads the value of head, which is indeterminate, resulting in undefined behavior

If you call free(head), to then use if (x == head) is illegal.

sounds weird as shit
is there an explanation why?

the standard says so; if I were to speculate I imagine it's done for efficiency reasons (like all other cases of undefined behavior in C) on a hypothetical platform that has hardware validation for pointers (ie. pointer values are tagged in the actual hardware registers as being memory addresses and trigger a hardware fault if the value of a register contains an invalid address -- eg. the memory page was unmaped by the implementation of free())

Working on a Web API for an Android application at work

>diff pointers
What are those?

Lewd

anyone has a link to the spreadsheet with all the free CS courses? remember it was top down organized

How do I into Monads with using Maybe all the time?

>there are people on Sup Forums who still think C is a useful language in 2016.

>I'm shit at math. Are you guys shit at math also?
No. I'm reasonably good at math.
>I feel like I need to get better at math.
You probably don't unless you want to work for Wolfram.
>How do I get better at math?
Don't waste your time.

>I don't know C but must post something and ran out of anime images

working on the library now, but i have used it for CSGO and Overwatch so far

You're correct but this is so obscure that nobody will write a compiler that makes use of it because it would break tons of programs.

On what principles does it work?

Can you even post it here?

elaborate

why not?
cheating isn't illegal m8, its just against the EULA/TOS or whatever

>why not?
The idea is that once the source is public it's only a matter of time until it gets VACd.

Like, how does a cheating library work?

weeell i doubt VAC would sig just the library, since a lot of legit programs work the same way (fraps for example)

something like this ->
compile cheat as a shared library (.dll)
inject it into a program
cheat hooks important API calls (usually to directx), and use it to draw shit ontop of screen usign the programs own DirectX device and context

lets say i wanna make a wallhack
all i have to do is follow the above steps, and in the hooked API call i scan the memory for players health, position etc, and then use that information to draw stuff in the right location
i can tell you where to get started if you're interested

How do you spawn a process in C (Linux) without fork() (another process) and without it being attached to another current process? Something like CreateProcess() in WinAPI.

>obscure
it's on the same level of obscurity as reading an uninitialized variable: you're reading the value of a pointer after free(), a pointer to an object that doesn't exist, ie. an invalid pointer; what meaningful value do you expect?
>nobody will write a compiler that makes use of it
that's what they said about memcpy
that's what they said about integer overflow
see a pattern?

clone()
>without it being attached to another current process?
impossible

>without it being attached to another current process
EVERY process, except PID 1, has a parent.

>it's on the same level of obscurity as reading an uninitialized variable: you're reading the value of a pointer after free()
most people are treating pointers as uintptr_t with syntax sugar. And nobody expects
uintptr_t t = 1;
f(t);

(where f is not a macro) to modify the value of `t` itself.
>that's what they said about integer overflow
Maybe. But some things are so common that they eventually find their way into the standard. Such as casting via unions.

Well how does disown work then? Like when you detach a process from the terminal and close the terminal the process keeps running?

Basically I want to write a program that launches another program, overrides a section of memory of the target program, and closes but keeps the launched program running.

someone write the non-UB solution i'm too lazy right now and i don't use linked lists anyway

>and closes but keeps the launched program running.
That will work just fine without you doing anything.