/dpt/ - Daily Programming Thread

What are you working on?
Previous:

Attached: latest.jpg (600x466, 134K)

Other urls found in this thread:

pastebin.com/zJfvzAXs
techempower.com/benchmarks/#section=data-r16&hw=ph&test=db
github.com/llucifer97/argon
pastebin.com/usn5E7MT
youtube.com/watch?v=LDRbO9a6XPU
twitter.com/SFWRedditImages

pedos arent welcome here

My Discord bot in JavaScript. Making a custom Gateway app, introducing Cache using Redis & making music nodes in Java and websocket.

Attached: large.png (500x281, 103K)

this

Attached: 1498866208019.png (1000x793, 717K)

static void Main() => Console.WriteLine($"{nameof(You)} {You(110, -5, -2, 0, -2, 13, -12, -5, 6, 0, 8, 5)}");
static string You(params int[] eger) => eger.Aggregate("", (c, n) => c + (char)(c.LastOrDefault() + n));

Thank you for posting a cute anime gril.

Attached: 1439648511159.jpg (469x469, 116K)

Friendly reminder that programming is a subset of anime.

Thank you for posting a programming related image.

new to cpp, just trying to study some code. what is this syntax? it looks like construction

Attached: Capture.png (477x164, 15K)

It is construction
T x (a1, a2, ... an);

so if i understand correctly, it's a shortened version of
WorldPacket data = WorldPacket(MSG_MOVE_HEARTBEAT, 31);

I own/develop a multiplayer PC Java game. Im hiring a developer to write some Java or PhP class files to my specification. The game is new and donations havent come in that much yet but I can afford to pay a minimal fee (im on a small budget - I can pay paypal bitcoin prepaids). The work should be trivial for someone who knows Java or PHP. Reply with your Discord contact if interested.

yeah
You can also use {}
It's weird. C++ sucks.

I once wrote a server using fork() on each client because that's the typical example you find on the internetz. I quickly realized my mistake and rewrote it using pthreads, although I know these are pretty expensive. I'm now reading about non-blocking IO (libev) as that's what somebody told me to use. But, although this probably doesn't concern my use-case, all of that non-blocking shit happens on one thread, right? If there are a lot of simultaneous clients, won't this become a problem?
Is there something that let's you like have nonblocking/async stuff on different threads if the workload becomes too big on the first one?

There's a subtle difference but sure, more or less.

Fuck off.

Is there anyway to start a distributed network without centralisation?

torrents trackers need a central name server to host meta information about spammers and hostile hosts, etc, right?

and in the bittorrent protocol there needs to be an original downloader who each subsequent downloader needs to have faith in that they don't upload malicious content?

Or am I way out of line there?

I want to build a little tool for myself and maybe some friends where we can use rsync to upload and download files from each other, BUT:

1. I don't want to enforce static IPs on
clients
2. I don't want to use a trusted 3rd party like no-ip to do something like dynamic dns
3. I want clients whos ips to change to be able to update a distrubuted hash table or ledger of all nodes and for that to be given to each client that joins the network without the that file having to first be uploaded somewhere like an S3 bucket.

Is this even possible or am I being a retard who doesn't understand how this shit works.

>there's a subtle difference
Not for variable intialization. Right? Correct me if I'm wrong

That can call the copy/move constructor. If a copy ctor isn't defined it will break.
It isn't until C++17 that copy elision is mandatory.

kys

Serious question is this the type of thread where people come to discuss the flavor of the month programming language that no one in the world cares about and that offers barely any job opportunities?

I wish I had an anime gf.

I kiss my sister everyday!

Why do you care about job opportunities?
Can't you just discuss stuff you like, hobbies for example?
Are you some next-level wagecuck who would cripple his own mind for an opportunity to pass a test for a potential employer?

>Are you some next-level wagecuck who would cripple his own mind for an opportunity to pass a test for a potential employer?

I am afraid that I will end up poor user...

Reading SICP, about 200 pages in, near the end of Ch. 2. It's funny how they essentially went through most of the practical bits of OO without leaving their procedure-centric nomenclature.

I think it reads a lot like a chemistry/physics book.

Attached: 1522625695757.jpg (848x960, 93K)

What do you guys do when the jargon of the area your program addresses collides with the jargon/keywords of your programming language? e.g. if you're writing a Python script about some chemical reactions and you can't use 'yield' as a variable name since it's a Python keyword.

Those bits end up with longer, more specific names that stand out like a sore thumb and give me autism fits.

The beta losers who do what they enjoy will perish and the alpha men who only care about success will rule the earth.

Currently writing a chrome extension to use the website 'traffup'...

My job entails mainly social media stuff and marketing.

The premise is:
- Like a page/post/etc.
- Get n amount of points (Usually 50)
- You post your page/post/etc.
- Costs you (n) amount of points for users to like your page/post/etc.

I do need some help. I need to figure out a method of selecting newly opened tab and inject a script.

i've used chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
// query the active tab, which will be only one tab
//and inject the script in it
chrome.tabs.executeScript(tabs[0].id, {file: "like.js"});
});

which works on button click but the action opens a new tab, this is the tab I want to inject into.

Please help :)

pastebin.com/zJfvzAXs

Attached: PRETTYPICTURESOYOUHELPME.jpg (9421x2837, 3.56M)

use golang, unironically

Use a language like C where you have to try to collide with the few keywords

Otherwise, either a more specific name or an abbreviation of the keyword.

(programming => anime) (anime => programming)

yield_ =

Some languages have a special modifier to names which lets you use reserved words, I know it's @yield in C#, for example, or r#yield in rust.

use vrt.x unironically. It does nonblocking IO like libev, but you can do it multithreaded. Each thread being 1 non blocking async IO thread, each thread being able to talk to the other threads over an eventbus. It is also crazy fast
techempower.com/benchmarks/#section=data-r16&hw=ph&test=db

yield_
yield'
yield_x
x_yield
myield

send source code pls
[email protected]

>JVM

someone post it

>eclipse

>jvm
>bad

What's the difference between returning a structure and a reference to that structure?
//Example 1:
std::vector myFunction()

//Example 2:
std::vector& myFunction()


If you have a really large vector, does the second one avoid a relatively expensive copying operation?

Is there a category of programming languages that could be called "standalone preprocessor languages"?
So something like an extension to the C/C++ preprocessor, but a language working on it's own, so you could embed its code in some language X, put it through a preprocessor and get a modified file with just the code in X language?
I guess PHP would be something like that. Are there any other languages like that?

The JVM itself isn't that bad, but it does mean you have to use a JVM language.

Yes.
However, if the vector is a local variable inside that function then it will be deleted when you return and the reference will be invalid.

It is literally the shittiest VM there is.
There is nothing good about it.

you dont know what youre talking about and your opinion is worthless

the exact opposite is true, retard

My coworker is an actual mouthbreather who tries to take credit for my work and I'm about to go postal, but my boss is nice to him because he's a veteran

What do, Jow Forums

The instruction set is shit. The VM itself is old garbage that lacks any modern or simple features.
Fucking delusional javeesh

real men solve those kind of problems with fists

I-it runs everywhere

and yet its still faster than anything else

I get bored of programming if I don't have a project or work to do. Is that normal?

Any suggestions for easy, medium level project?

anything else?

low effort post

>There is nothing good about it.
More cross platform than your micropenis VM

>inferiority complex
It can't run on consoles or even smart TVs. It doesn't even come by default with any OS (other than maybe solaris lol) because it is so fucking bloated that oracle might sue you for the overall bloat.

>it runs on the street
but user, it is still shit

So I think I figured out what I want to do for my spatial grid test.

I've got my struct
struct spatial_s
{
float x, y;
float w, h;
size_t size;
entity_t **obj;
};

I've got it defined as spatial_t *GRID; and I have a function to create it, and free it, every tick that I check for collision on. I am not sure if I am doing it right somewhere, because I see the memory usage greatly increase when I run those two functions. This is the function to make it:
void GRID_make ( spatial_t *g )
{
if ( !g ) return;

grid_w = level_width;
grid_h = level_height;
grid_s = grid_w*grid_h;

g = (spatial_t*) malloc ( grid_s*sizeof(spatial_t) );
memset ( g, 0, grid_s*sizeof(spatial_t) );
if ( !g )
endgame ( "Problem allocating spatial grid! Failed to allocate to memory!\n" );

int x, y;
for ( x=0; x

>Java doesn't run android TVs
>muh default install
LMAO microcuckolds are pathetic

Been working on this github.com/llucifer97/argon

There is M4 and even awk depending on your needs.
Most probably you want to keep your sanity and use the C preprocessor.

>p-pathetic

Attached: 1530583381742.jpg (306x231, 18K)

>suddenly sucking micropenis and eating pooinloo nadella's feces is okay

Know your place, NEET cuck

Attached: 1525776753265.png (767x747, 121K)

>professional underpaid codemonkey

>professional unpaid burger flipper

Both are poo, poobrain

Thinking of a strategy of disconnecting a node in a disjoint set
std::thinking

mod disjointsets
{
pub enum DisconnectTypes
{
Recursive,
Isolated
}

pub struct Pool
{
ids: Vec,
heights: Vec
}

impl Pool
{
fn with_nodes(max: usize) -> Pool
{
Pool {
ids: (0usize ..= max).collect(),
heights: vec!(1usize; max + 1)
}
}

fn root(&self, id: usize) -> usize
{
let mut result = id;
while self.ids[result] != result
{
result = self.ids[result]
}
result
}

fn is_connected(&self, id1: usize, id2: usize) -> bool
{
self.root(id1) == self.root(id2)
}

fn connect(&mut self, id1: usize, id2: usize)
{
if self.heights[id1] > self.heights[id2]
{
self.ids[2] = self.root(id1);
self.heights[id1] += self.heights[id2];
} else
{
self.ids[1] = self.root(id2);
self.heights[id2] += self.heights[id1];
}
}

fn make_root(&mut self, id: usize)
{
self.ids[id] = id;
self.heights[id] = 1;
}

fn add_node(&mut self)
{
self.ids.push(match self.ids.last() {
n => n + 1,
None => 0
});
}

fn disconnect(&mut self, id: usize, disconnect_type: DisconnectTypes)
{
match disconnect_type {
DisconnectTypes::Isolated => {

}
DisconnectTypes::Recursive => {

}
}
}
}
}
u
fn main()
{
println!("Successful Runtime");
}

Attached: astolfo_fanart_2_by_gao_lukchup-dbogbui.jpg (600x848, 95K)

>Legacy code
L M A O

Go take your startup trash to plebbit, NEET cuck

Mami a cute, CUTE!

no u

Do electronic musicians use simulink to create music?
Seems like a perfect tool them. And they most definitely are competent enough to use it.

last night I made a little image scraper in python that I'll be using to download /c/ ryuko threads from here on out

Also just starting on making an arduino due use PIC24 MCUs as coprocessors/IO expanders.

Attached: 71E874748B_preview.png (640x640, 474K)

Here is pic of it now. Planning on doing some kind of parallel bus between the two chips.

Attached: 0705181907.jpg (4656x2620, 3.97M)

What is this? Where is the dust?

I'd love it too~

>does the second one avoid a relatively expensive copying operation?
yes, though that reference had better be to a vector with lifetime of a greater scope than that of the body of myFunction(). if you try to return a reference to an object local to a function, that reference will be invalidated when the object is destroyed as soon as the function ends. but do you know what else avoids a copy operation in this case? returning by value. as long as a type implements (if applicable) move semantics (STL containers certainly do), returning a function-local object of that type by value simply moves the returned object into the object at the call site being initialized / assigned to. if RVO or NRVO applies, then there won't even be a move operation, let alone a copy

>parallel bus between the two chips.
>/IO expanders.
will there be enough IOs left on the PIC for it to even work as an expander if you put a parallel bus in there?
also, you know you can do that with shift registers or a dedicated expander?
what's the coprocessor for?

>Setting up WiFi p2p for Linux
>work with wpa_supplicant
>Turns out Desktop Linux is moving from wpa_supplicant to intel something something
>whole project is DOA in an instant
LMAOing @ my life

Attached: 36229581.jpg (582x988, 105K)

>whole project is DOA
must've been fun

How do I become a sql wizard?
What are some good resources?

pastebin.com/usn5E7MT

Made little program to convert units, any thoughts?

Attached: 1523204731491.jpg (480x602, 66K)

To be clear: there's nothing even vaguely practical about this, so long as it's using a 16MHz PIC as a coprocessor for an 84MHz Cortex M3 lol

This is just for fun, and as proof of concept. Hypothetically, if this works, the same thing could be done with, say, a 200MHz Cortex M7 and a 120MHz PIC32, and the end result could be extremely powerful, assuming a wide enough data bus to be running at ~100Mbit speeds.

I'm gonna make my own basic parallel interface since neither chip has a hardware-level parallel driver. To test it, I think I'm gonna have the PIC continuously performing FFTs and store that data in a buffer which can be accessed by the Arduino. FFTs (especially low-frequency ones) inherently take a long ass time to do and they require a lot of calculations, so it's actually a sensible thing to assign to a coprocessor.

The greenish-blue board is an Arduino Due. It has an 84MHz ARM Cortex -M3 microcontroller and an on-board programmer (meaning I can upload code to it over USB without any extra shit)

The chip in the blue board on top is a PIC24 microcontroller. It runs at 16 MHz. Since it's just a chip all on its own, I have to use an external programmer, which is the little red board in the background.

Why would there be dust, by the way?

Attached: 594D0FE801_preview.png (640x640, 381K)

>#define NO_ERR 0;
>#define NO_ARGS 1;
>#define WRG_ARG 2;
Learn about std::variant

this shit made my day thanks

Thx user, will do any soon. I was thinking about necessarity of 3 first structs, since all they do is hold values for std::map. I understand it is import to have all constant grouped but I really wanna avoid redundancy in my code.

your naming conventions hurt me
Cursed_case

was it that bad?

WHAT the fuck is wrong with his hands? Eww white people
youtube.com/watch?v=LDRbO9a6XPU

Oh yeah, my bad, I used to convention when classes start with capital letter but on the other hand i want to stick to c_like_names

those are called freckles. We used to bully people for their skin having freckles before niggers were invented

Thanks!!

Just finished a scanline algorithm! I made it such that you can tweak how wide and how dark the lines are.

Looking for suggestions for improvements!

Shoot!
Forgot the image!

Attached: Screen Shot 2018-07-05 at 6.19.33 PM.png (441x500, 507K)

nvm
I just imagined this code with haskell typeclasses and then realized how shitty oop is

It's procedural programming, I don't use classes, the whole point of structs were to hold constants

So does anyone actually enjoy dynamic typing?

brainlets do.

brainlet* typing