/dpt/ - Daily Programming Thread

What are you ! working on?
Previous:

Attached: 1550517386800.jpg (800x534, 66K)

Other urls found in this thread:

youtube.com/watch?v=aHk42kDwesM
vmls-book.stanford.edu/
shivayl.com/portfolio-os
becominghuman.ai/building-an-image-classifier-using-deep-learning-in-python-totally-from-a-beginners-perspective-be8dbaf22dd8
linux.die.net/man/3/pipe
dl.suckless.org/slcon/2013/slcon-2013-4-nsz-the_costs_of_abstraction.webm
a.uguu.se/plvigg5sPZK0_dab99d78495610987858e2bb7484b30b1d620e10.torrent
twitter.com/SFWRedditImages

i'm working on a porn game because i don't know what else to do with my life to make a living

Manual memory management < Garbage collection < Smart pointers

I'm working on my Wayland compositor.

Attached: 1525102272864.jpg (750x1000, 125K)

I know python,r,and c. Rusty at all though.

I've been out of programming for a while. What should I review ? I need a job again. I'd rather have job security than high pay. Willing to freelance. Web dev seems like a nightmare of things to learn, being disposable , and constant need to update knowledge.

What can I shoot for?

Attached: 1547679898164.jpg (650x457, 304K)

Trying to think of a good SaaS idea to work on instead of just browsing Jow Forums all day

webdev desu

trying to remove duplicates with an a arraylist. why is my method not printing out when i call it in the main method ? If I use a system.out. in the method itself it does what i want it to.
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList list = new ArrayList();

list.addAll(Arrays.asList("be", "be", "is", "not", "or", "question", "that", "the", "to", "to"));
//System.out.println(list);
//System.out.println(removeDuplicates(list));

removeDuplicates(list);
}

public static void removeDuplicates (ArrayList list) {




String duplicate = list.get(0);
for(int i = 0; i< list.size(); i++)



if(!list.get(i).equals(duplicate))
{
duplicate =list.get(i);
}
else
{
list.remove(i);
i++;



}
System.out.println(list);
}

}

Text based adventure or...?

Why would a music file need decoding support?

this is java?

What the hell is going on with your whitespace?
If you actually formatted your shit properly, you'd see you're missing a { after the for statement.

Attached: 1550029750049.png (536x469, 378K)

RemoveDuplicates is void

>Implying java would even compile if a bracket was missing
The guy probably has a void return value

In J this is just ~.

I suppose I could use some BASIC C++ books. I might be going on to an interview, and I could be working in a mixed C/C++ code base. I'd be good on the C side, but could use some examples for C++. Nothing advanced, just some class examples, use of the standard lib, redefining methods via inheritance.

youtube.com/watch?v=aHk42kDwesM

>In J this is just ~.
and here I thought clojure's (distinct list) was short

do your own homework user

Trying to learn math so I can actually understand the algorithms books and/or meme my way into a university

Attached: unit_sillcle].png (234x378, 225K)

wish you luck!

Sounds like a a place full of boomer shitcode. I'd avoid it if I were you.
If you already know how to program, read A Tour of C++, by Barney himself.

patrickjmt leads the way

Pls halp

>put a pointer in a struct
>suddenly ints get padded to sizeof(pointer), which is 8

Attached: 1417526132601.png (732x743, 370K)

Learn the art of packing your structs properly, or realise that it doesn't really matter a lot of the time.

That book looks just like what I need, thank you.

It pays around $30/hour starting, with a 44/36 schedule. I don't have much experience so yeah, at $30/h I'd be making more than either of my parents at the beginning of a career. Even when one is the maintenance lead at his plant.

I have just one int in the struct and 2 pointers, there's nothing to pack. An additional 4 bytes matters because I need an array of structs and it adds up. I read that __attribute__((packed)) will embed memcpy for you for portability at the expense of performance - I don't see any other way to do it

Why does that matter? Newsflash, computers don't have 4 megabytes of ram anymore.

That's just the nature of alignment. You can't get around it without introducing unportable and potentially slower behaviour.
Although another way you could do it is as 3 separate arrays for each member, instead of as a single array of structs.

Struct padding wastes space in your CPU cache, which can affect performance.

What languages decouple objects from methods, like factor?

>"What's the smallest possible library for x?"
>Recommends one of the largest possible libraries for x
Sasuga

>kernel
>providing hash functions to userspace
Linux has gone too fucking far

here's a really good one for linear algebra, also doubles as a basic machine learning textbook.
vmls-book.stanford.edu/

>Linux has gone too fucking far
I think it was a case of the kernel needing a bunch of crypto-related shit for networking, and that they may as well let userspace use it too.

You made a mistake in your post. Here, let me fix it for you:
Garbage collection < Manual memory management < Smart pointers

SCP ( dnd rpg ) diceroll chat

shivayl.com/portfolio-os

depends on use case

Have you read your SICP today?

Attached: 1 k5v65hJ2AxMM3gaZ8rxvEQ.jpg (800x800, 150K)

I just need a guide or some thing that can explain this.

reminder that SICP and deprecated and you should read HtDP instead

Do share

What do you mean decoding support? How can you play it if it is not decoded?
Learn about file formats.

Dumbest question seen all week

Yet u can't answer it

maybe SICP is actually an SCP

*sip*
now SICP... that was a good book

Attached: 1549655959572.png (596x720, 436K)

How do people draw out their designs? People always talk about UML, but that's great for showing how a system actually looks, it doesn't show how anyone would arrive at that conclusion, etc.

experience, philosophy, and dumb methodology/paradigm memes

Thank you very much Anons!

d-do you want to read it with me?

Attached: sicp.png (1111x1600, 631K)

>experience
Seems to be what the rest of my colleagues (10+ years experience) have, as we're agile, hence no fucking documentation, so when I interact with them they just seem to pull design completely out of thin air and are right 90% of the time.

it would be even slower without it

use haskell

Attached: received_1690681964284346.png (1023x71, 2K)

Sure, in this case.
But in the more general case of doing something silly like:
struct {
char a;
long b;
char c;
long d;
char e;
};
Internal padding is something you can try to remove.

Yes.

Attached: 1548483331059.png (603x702, 494K)

in that case, packing is trivial

>Internal padding is something you can try to remove.
The world ins't just x86, most other architectures can only do aligned loads/stores.

I'm 'working' on this: becominghuman.ai/building-an-image-classifier-using-deep-learning-in-python-totally-from-a-beginners-perspective-be8dbaf22dd8
but really i'm trying to figure out why pycharm is creating folders in my c:/users/myname directory, and in a pycharm directory within that. is this normal, am i just meant to have folders named after each project all over the place?

Yes I know. You remove internal padding by reordering members.

Anyone good in C and system design? I am not fully sure on how a file descriptor works but I think I am getting the hang of it.
But why do people sometimes make an array called "fd" or "p" with length 2? I mean I get that 0 represents STDIN and 1 represents STDOUT but does C recognize those arrays as file descriptors, that position 0 is a Read file descriptor and 1 is a Write file descriptor?
please help a brainlet

Attached: 1527190147023.jpg (550x547, 46K)

Text based thing. Think HHS crossed with CoC and various slave management games.

yEt YoU CanT aNSWer iT

example code
int p[2];
6 pipe(p);
7 if( ! fork() ) {
8 close(1);
9 dup(p[1]);
10 close(p[0]); close(p[1]);
11 execlp( argv[1], argv[1], NULL);
12 }
13 else {
14 dup2(p[0],0);
15 close(p[0]); close(p[1]);
16 execlp( argv[2], argv[2], NULL);
17 }

here, dup(p[1]) at first sight should just copy an empty array position to the next available file descriptor ID, close(p[0/1] should just close an undefined file descriptor and so on, eh?

linux.die.net/man/3/pipe
They're probably using this.

I see
Should a fd array only have 2 indexes when doing pipe?

pipe() will fill both of the elements of p with a file descriptor. As you seem to already understand, p[0] is thre read end and p[1] is the write end.

fork() will "split" your process in two, meaning you now have two separate processes running this code.
The parent will return the pid of the child, and the child will get 0, so the if statement around fork will split the behaviour for the parent and child.

When a process is forked, all open file descriptors (there are exceptions to this, but not important here) and duplicated. So if the child writes into p[1], the parent can read it out of p[0].

Child:
>close(1);
>dup(p[1]);
Ehh, this can be represented better by
dup2(p[1], STDOUT_FILENO);
Basically, it's replacing stdout with the write end of the pipe.
>close(p[0]); close(p[1]);
These aren't needed anymore, so they're closed.
>execlp( argv[1], argv[1], NULL);
And it now replaces itself with a new program.

>dup2(p[0],0);
They're using dup2 here, but not above. That's odd.
Anyway, replaces stdin with the read end of the pipe.
>close(p[0]); close(p[1]);
Aren't needed any more.
>execlp( argv[2], argv[2], NULL);
And executes a new program.

That code is doing basically the equivalent of
prog1 | prog2
as a shell command.

Yes.

I usually draw boxes and state machines. Fuck UML and class diagrams though, if you need those your design is already fucked imo.

Reminder that C is the only serious programming language.
dl.suckless.org/slcon/2013/slcon-2013-4-nsz-the_costs_of_abstraction.webm

Attached: 1545660074981.png (659x937, 161K)

You mean forth

Khm
Fuck UML and Fuck OOPsies

Thank you

I made a vanity torrent hash generator.

a.uguu.se/plvigg5sPZK0_dab99d78495610987858e2bb7484b30b1d620e10.torrent

Attached: .jpg (1920x1080, 248K)

why do you keep linking that talk? it's not only weak but unbearable and has barely any engagement.
get some better shilling material

based anime autist dabbing on everyone

serious at producing live endangering bugs.

>SICP
More like spic, amirite?

Emulating vax functions in c.
setting and clearing bits has never been easier.

>suckless
What about not sucking at all? Can you do that with C?

Adding support for hard links to my OS and adding a simple /bin/ln binary.

Attached: Screenshot at 2019-02-21 13-17-29.png (1920x1080, 862K)

I read SICP and my little schemer back when i was in uni. While it is an intro book and pretty elementary I still feel deep affection for scheme thanks to it. I remember being stupid cs first year trying to solve exercises and finaly succeeding and discovering beauty of scheme while being fed c++ at uni. Good days

How's that going? What kinda features are you implementing?

C programmers don't know anything about abstractions, compilers, or cost.

I'm doing a shitload of internal restructuring, so that more features can be added in the future.
Explicit synchronisation is a new extension that has come about recently, and it requires changing almost all of our state tracking. God damn, is it going to be a lot of work.

How do I define 3 custom colors (in hex format) for my pie charts

I have two pie charts, one with two values the other with three

I have this line that controls the choice of colors used

dataSet3.setColors(ColorTemplate.MATERIAL_COLORS);

I use MPAndroidChart but their documentation sucks, since 80% of the commands are not even listed there or just so sporadic a pleb like me just can't figure it out ;_;

I want both my charts to use to use three possible colors I defined myself

Attached: 1549624310610.jpg (1200x1200, 179K)

Sounds like a hassle user. Hang in there :)

I brought it upon myself.
I don't HAVE to implement the extension, but it provides some nice advantages.

> calling it btn instead of button
Things like this REALLY annoy me, I don't know why I feel such hatred for variables where whoever wrote them thought that shortening the variable somehow helps.
In some cases, if it appears often in a formula, it can be okay for brevity, but most of the time it's honestly just... ridiculous.

Nobody wants to type button over and over and over again

std::btn

Even Windows exposes their hashes through certutil as much as it is a pain to use do these kind of things in batch

Do you unironically write
for (signed int thisIsALoopCounter = 0; thisIsALoopCounter < theLargestLoopValuePlusOne; thisIsALoopCounter++) {
// ...
}
?

nobody does that
>bu[TAB]

If you're complaining about the sort of naming schemes programming teachers tell you when they're not asking you to write UML inheritance diagrams then i can sympathise

nice, I want to fucking cum now

Autocomplete

No, if you're just looping through a list then I think i is common enough that it doesn't annoy me. Also, it is just a letter. It doesn't hurt my brain to read "i" in the same way it does to read "btn", so if there is no important information lost (which in this case there maybe isn't), I'm fine with it.

On a side note though, there are usually shorter/easier/faster/better ways to loop through the entire list just start to finish (in any sensible language). The times you need to do something less trivial, which requires the index, a more appropriate name for the loop variable can often be found.
Not always, of course.

I'm trying to deal with some WebAudio Javascript application that uses the microphone.
I can't buffer the results for each given number of samples to implement a demodulator with them or concatenate the results each 64 samples to send it to a server.
All either use bloat Javascript libraries or use strange tricks and I want to be as close to native Javascript as possible.
[/rant]

Yeah but that's expected of Windows. No ones surprised there.

>tfw afraid to compile because I know it probably won't work

Attached: okay retard.jpg (746x754, 35K)

Working on getting an MMO working again based on a packet dump, debug symbols, and a client.