/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md
github.com/trending?l=cpp
npmjs.com/package/gitgud
coinmarketcap.com/assets/funfair/#charts
twitter.com/SFWRedditVideos

trying to get emulated games working on this orange pi

So here's the final allocator. I'm not sure where I want to go next, basically I plan to implement a scheduler in the near future but I also want
>some standard library-like containers to make it less a pain in the ass to work
>keyboard input

Rewriting the Linux kernel in JavaScript

that's great, user. hope you post the source so everyone can use it.

>java has superclasses
How can C even compete?

How's that Assembly learning going?

oop is cancer.

>Z80
Comfy.

>his language doesn't have Metaclass class
pleb

It competes by assuming the programmer has some ability to write code without babby-tier abstractions to help them along the way.

Well-written non-OOP code is actually a lot easier to follow and debug than well-written OOP-code. Java projects in particular are nightmares to trace through and make minuscule changes to, if you're not familiar with the project and its hierarchy of different classes and other abstractions afforded to the project by the language.

Hang yourself, pedo.

How hard would it be to land a Programming or IT job with felonies?

What did you do?

burglary

Wew, I was expecting an actual pedo.

I don't think anyone but felons and HR could answer that.

Some hipster startup company on the west coast would probably take you. Of course, life on the west coast sucks ass and is fit only for animals, but consider it a stepping stone.

HSA payroll deductions for my company's fintech platform...

you misspelled base and derived

>class structure isn't defined by recursively constantizing strings read from a nested YAML file on disk

got as far as to actually launch a game in mame
but, even though my controller works fine in linux and retropie and everything else, I can't get the emulator to recognize a single keypress
probably the end of the line

Rust update.

>he doesn't use higher order functional programming with homotopy maps to hard-code a car in his language of choice
Can't wait to hard-code myself a gf.

I can't tell if it's ironical (as it's supposed to be) or not. In any case, it's shit.

Thanks! I solved the problem partially by adding const to the pointer to the pointer and the variable in the struct. That way I managed to access the struct member in the function and display the first string. However I was unable to access any of the other strings. Tried memcpy, but I'm getting a seg fault just trying to print the first string in there.

struct load_data {
const char **img;
size_t img_s;
}

const char *images[] = { "test.bmp", "test2.bmp", "test3.bmp", "test4.bmp", "test5.bmp", "test6.bmp", "test7.bmp" };
const char **ptr_images = images;

struct load_data data = { ptr_images, sizeof(images) };
struct load_data *data_ptr = &data;

thread = SDL_CreateThread(scene_load, "load_scene", (void*) data_ptr);

int scene_load(void *ptr)
{

struct load_data *test = (struct load_data*) ptr;

char *images = (char*) malloc(test->img_s);
memcpy(images, test->img, test->img_s);

printf("address of test: %p\n", test->img); // works
printf("size... %i\n", test->img_s); // works
//printf("test: %s\n", *((test->img)+1)); // seg fault
printf("memcpy_img: %s\n", *images); // seg fault

return 0;
}

What am I doing wrong now?

After (You).

>char *images = (char*) malloc(test->img_s);
what value are you expecting test->img_s to have at this point of execution?
because you didn't initialize it

>struct load_data data = { ptr_images, sizeof(images) };
see here
struct load_data data = { ptr_images, sizeof(images) };


It's the size_t if the original string array.

I have a uni course where I need to find and contribute to a larger sized project on a git-ish service. Might you have any suggestions?

ah I see
in that case I think the problem is that you're attempting to copy memory to an address of a variable that you've specified to be const

see if you can push same changes through to
github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md

where my trap"bros" at?

...

actually, I just ran it and it worked fine
try running this in a fresh project
#include
#include
#include
struct load_data {
const char **img;
size_t img_s;
};
int main(){
const char *images2[] = { "test.bmp", "test2.bmp", "test3.bmp", "test4.bmp", "test5.bmp", "test6.bmp", "test7.bmp" };
const char **ptr_images = images2;

struct load_data data = { ptr_images, sizeof(images2) };
struct load_data *data_ptr = &data;
void* ptr = data_ptr;
struct load_data *test = (struct load_data*) ptr;

char *images = (char*) malloc(test->img_s);
memcpy(images, test->img, test->img_s);

printf("address of test: %p\n", test->img); // works
printf("size... %i\n", (int) test->img_s); // works
printf("test: %s\n", *((test->img)+0)); // works
printf("test: %s\n", *((test->img)+1)); // works
return 0;
}

how do I git gud

Just like use search my negroe
github.com/trending?l=cpp

Sometimes devs mark issues with newcomers labels

There's an npm packet for it: npmjs.com/package/gitgud

is that a good thing or a bad thing that npm has shit like "is-negative-zero"?

EVALUATE TRUE ALSO desired-speed ALSO current-speed
WHEN lid-closed ALSO min-speed THRU max-speed ALSO LESS THAN desired-speed
PERFORM speed-up-machine
WHEN lid-closed ALSO min-speed THRU max-speed ALSO GREATER THAN desired-speed
PERFORM slow-down-machine
WHEN lid-open ALSO ANY ALSO NOT ZERO
PERFORM emergency-stop
WHEN OTHER
CONTINUE
END-EVALUATE

COBOL is cute.

How can I rename master / slave in my code to be politically correct?

I'm thinking seme and uke like in yaoi, because gay stuff can never be offensive.

>not realizing how racists you are towards japanese people

You're not attempting to print the newly allocated memory region

printf("test: %s\n", *((test->img)+0)); // works
printf("test: %s\n", *((test->img)+1)); // works


works only sometimes for me, sometimes it causes a segment fault.

Hello, I'm an asyncio babby.
Currently I'm using the websockets library, but I can't figure out how to make this piece of basic server code multithreaded (with ThreadPoolExecutor, for example):

import asyncio
import websockets

async def hello(websocket, path):
name = await websocket.recv()
print("< {}".format(name))

greeting = "Hello {}!".format(name)
await websocket.send(greeting)
print("> {}".format(greeting))

start_server = websockets.serve(hello, 'localhost', 8765)

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

Any help appreciated, async is melting my brain.

Someone told me most companies don't even do background checks. Is this true?

Most probably they are going to look at your Facebook profile.

I'm not American. I wouldn't know what the situation is like there but here I wouldn't expect them to. They look at your professional history. If you've got a work history gap that's a work history gap, which you may have to explain.

>programmer
>facebook profile
these two don't overlap very often

Ok thanks. I taught myself Java out of a textbook in prison. I didn't have a compiler but the knowledge I retained helped a lot so if I can't find a job oh well I didnt spend 60k on tuition.

...

Do you have actual experience programming? I mean non trivial projects, doesn't matter if they are not done in a professional setting. This should be enough to land an entry level programming job.

What are some projects with a decent codebase that need help? I don't mind writing C, Java or C# or learning some functional language. I want o start contributing quickly and getting famous on GitHub.

How do I switch to Python 3 as the default on a Debian system that has Python 2.7 as the default?

python3

Enhance image viewers and web browser with bpg of other image formats.

I just don't install python2 at all but removing it and symlinking should work. Just be advised some python2 scripts are not compatible.

ok I tried to run this on its own. and it worked fine. so I made it more like my program step by step. started by putting the malloc and memcpy in a function. worked fine. than I put the function in a SDL thread instead of calling it directly, not printing test->img seg faults. strangely, memcpy seems to work. that's what causes my program to seg fault...

The only experience I have is with mSL. I used to write scripts for RuneScape bots lol. I plan to spend at least a year or 2 doing internships however.

What C# program is well written and may be worth analyzing code-wise? I've started learning C# as my first programming language and want to some real programming stuff instead of FizzBuzz

Oh damn, duh. Most logic you apply to sets you can apply to multisets, so it would still be a power set.

You should definitely go for them. I get contacted quite often by recruiters and I haven't even graduated yet, probably thanks to the internships I've done.

This will break a lot of shit on a Debian system. Don't do it.

>tfw suddenly
#define private public

You forgot a few.
#define protected public
#define class struct
Also I'm pretty sure #defining keywords is undefined behavior.

#define if(x) if (rand() % 100 == 0) exit (1); else if(x)

Can we all agree Eclipse Oxygen is an excellent IDE?

Holy shit, did I just learn the kanji for 'code'?

Someone new is going to come along and take this seriously.

That's the point of every informative infographics.

Even with update-alternatives?

nvm, it works fine without threads.
I was getting 500 requests per second on localhost when I posted that. But after some time I started getting 4000 reqs/sec, which is acceptable. I didn't change any code to achieve that, so that's both a blessing and a curse.

and they'd be well-informed as a result. It's a mostly accurate chart.

I'm also hard coding if you know what I mean.

That will just rename the symlink. Many of the scripts the OS uses are python2. You can't get rid of python2 and symlink python2 to python3.

Eclipse is shit.

brilliant, thanks famalamadingdong

>tfw can't do SICP 1.13
am I a brainlet? Should I just give up?

CodeAcademy or Treehouse?

>wasting his time on SICP
>am I a barinlet?
Yeah, you're are.

Not that guy but I have an honest question. What on your FB profile could actually make a company ignore your resume?

>t. brainlet

Take a break for the day and come back later.

>barinlet
You're far worse, idiot.

What are you learning?

Do you actually make your profile public? If not, the only thing that would hold you back from some is your profile pic. But also,
>Having an online identity
The worst mistake you could ever make

>Lies, SICP is still relevant!
Even MIT doesn't teach it anymore, mostly because reading SICP only makes you good at solving SICP's exercises, something the real world has little in common with.

what the fuck
printf("test 1: %i\n", test->img_s);
char *images = (char*) malloc(test->img_s);
printf("test 2: %i\n", test->img_s);

output:
>test1: 56
>test2: 1695715840 (random garbage that changes everytime i run the program)

I don't no anymore lol

Useless /sqt/, reposting.
Google Sheets problem. I'm trying to get the 13.02% in pic related through =IMPORTXML. I can get Sheets to show the $0.033875 above it just fine by copying the XPath from inspect element, but when trying to copy the XPath for the % (and most other numbers on the webpage too) I get either two N/A errors, "Resource at url not found" and "Imported content is empty" if I try mucking around with the XPath. Been doing my head in all week, is there a way to get around this? This is the site in question: coinmarketcap.com/assets/funfair/#charts

So this works: =IMPORTXML("coinmarketcap.com/currencies/funfair/?","//*[@id='quote_price']") but if I replace the XPath here with the XPath of the % I get an N/A error.

why do people/compilers do

XOR EDI,EDI
instead of
MOV EDI,0
is it faster or something?

I'm not sure anyone uses Google Sheets here tbhwyfam

>is it faster
It can be, it's not always preferable. You can google the thing if you're genuinely interested, there are quite a few details on it in the manual.

His problem is clearly using incorrect xpath, considering he didn't even post it.

It's faster because all the modern CPUs recognize the XOR A, A pattern and have specialized circuits for it. Plus it's shorter, using MOV A, 0 means you have to pull 2/4/8 all-zero bytes after the opcode, while XOR A A is like 2/4 bytes wide in total.

run it in gdb and valgrind for max info

MySQL or mongo?

>all these OS hobbyists being proud of undergoing the task of reimplementing libc
>meanwhile I just copy/paste shit from their libs to mine

mysql
>can't implement sql standard properly
>have their own shitty functions for stuff
mongo
>loses your data left and right
literally anything else
>actually decent database

Postgres, and I'm not even meming.

final static class PrimaryKey {
final private Class clasz;
}

Isn't Java Class class a generic? Why he declared it without the angle bracklets?!

You don't have to pass type parameters.