/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: whereyunobelongs.png (500x500, 110K)

Other urls found in this thread:

pastebin.com/ujGPjnX1.
twitter.com/NSFWRedditGif

the board is mocking me

Attached: wider.jpg (333x159, 16K)

good thread

Attached: DtvotQ1XQAAIxe5.jpg large.jpg (2047x912, 374K)

so, about them programs ... ...

Attached: 1551561830761.png (1324x1125, 210K)

Started working on a tree view widget for my OS. It's still very early but I can already feel that it's going to add a lot of utility to the file manager.
Maybe it would be useful in the process manager as well. I'm not sure what to think about process trees vs flat process tables.

Attached: Screenshot at 2019-03-29 14-40-34.png (1920x1080, 754K)

Daily reminder Rust in the only language to have TWO discord servers you can go to to post the eggplant emoji to the official dev team chat.

Attached: rust_discord.png (967x420, 63K)

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

Why do the tree elements have a background?
>process trees vs flat process tables.
Both have their utility desu, I'd have a table as default, but provide a tree view as well desu

The background is for debugging while I'm working on it. It shows the clickable rectangle for each item. :)

>table as default, but provide a tree view as well
Yeah that makes sense. Seems nice to have both, plus it's a nice exercise in making my view classes generic enough that they're able to visualize the same data model as both a table and a tree.

> defines 30 lines long lambda
> calls it immediately and then discards

Attached: l1icy94l82c21.jpg (594x578, 30K)

It calls itself

Attached: recursivecat.jpg (192x262, 7K)

If you had to pick ether C# or Java, which would you choose and why?

I'd rather kill myself

a bit brainlet question:
C++: how do I use a custom struct as the VALUE in an unordered_map?
I tried simply
unordered_map theMap;
and adding values by:
theMap["someKey"] = new TheStruct(78, 40); //the constructor takes two ints
and it throws some fucked up weird error saying 'Included in file' (without any name).. and a fucking operand type error

new returns a pointer to a TheStruct and not TheStruct itself

I would prefer N-ethers because O-ethers look like they crave cocks.
Seriously though, C# because of many language and class library design issues in Java.

sorry I actually call it without 'new'.. only added it on accident while rewriting the example here

Cat in cat lol

post the error

>spent 2 days not realising that (a != 1 && b != 1) evaluates to true if a = 0 and b = 1

Attached: dee dee.png (564x426, 303K)

>true
i mean false
...

Attached: cryign.png (150x112, 15K)

dumb frogposter

C#
but really kotlin is the superior one here

Are you webdev?

if it tells you something
In file included from /usr/lib/gcc/x86_64-pccygwin/7.3.0/include/c++/unordered_map:41:0, from main.cpp:1:
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++/tuple: In instantiation of 'std::pair::pair(std::tuple&, std::tuple&, std::_Index_tuple, std::_Index_tuple) [with _Args1 = {std::basic_string&&}; long unsigned int ..._Indexes1 = {0}; _Args2 = {}; long unsigned int ..._Indexes2 = {}; _T1 = const std::basic_string; _T2 = TheStruct]': //etc.. (the whole error is too long for a comment)

It might seem like there is a linker error with tuple, but it doesn't fail on simple mapping, so, idk.
also, pls no bully for >cygwin

that only tells me where the error is, not what the error is

oh shit error: no matching function for call to 'TheStruct::TheStruct()'
now that's fucking weird. the constructor itself is ok, but adding it to the map fails

now why might your compiler be looking for that constructor?

ok guys, sorry for bothering this thread. the problem is simply me not writing the default constructor

reminder that you can't call yourself a competent programmer if you haven't mastered C++

shit. I () am fucked

Attached: 44293504_570380946724984_7949093710153646080_n.jpg (540x960, 36K)

kinda. the actual problem is that maps operator[] requires a default constructor for the mapped type. if you're using C++17, you could use insert_or_assign instead

I've been programming in C++ for 16 years, 8 of them professionally, and today I learned pure abstract methods can have implementations:
> The definition of a pure virtual function may be provided (and must be provided if the pure virtual is the destructor): the member functions of the derived class are free to call the abstract base's pure virtual function using qualified function id. This definition must be provided outside of the class body (the syntax of a function declaration doesn't allow both the pure specifier = 0 and a function body).
I'm not sure how long it will take for me to finally *master* C++98, but I'm pretty sure my lifetime won't be enough for C++17.

it turns out most of the weird shit is right there in c++98, and newer additions are actually pretty sane

I tried Kotlin and it looked like C# but with the Java class library, slower compilation times, bad ffi support and more keywords.
Is there is a truly superior point that I missed checking out in Kotlin?

> he doesn't know about User-defined deduction guides
> he doesn't know about ranges
> he doesn't know about coroutines
> he doesn't know about Concepts
Rust is my only hope.

cool. do you simply know that from the back of your head?
how long have you programmed in C++?

Three of those aren't standardised yet and the fourth is super straightforward.

I don't use C++ a lot, but I sometimes watch CPPcon talks, and iirc the map thing came up in one of them

First time touching NASM. Need a bit of help here.
section .bss
name resb 16


gives me 0.asm:13: warning: attempt to initialize memory in BSS section `.bss': ignored [-w+other]
when I try to compile.

Attached: 1549500597975.jpg (1157x861, 206K)

bss is only for things that are initialized to 0

Yeah but can't I initialize something called name that takes up 16 bytes in .bss?

my homework

2+2 = ?

5

> let 2 + 2 = 5 in 2 + 2
5

God I love Haskell.

yeah should be possible
did you try
name: resb 16
?

delet this

i mean, depends on the group upon witch you are counting

Yup. Same error

could you post some more code? I can't replicate your error

here pastebin.com/ujGPjnX1. Thanks for helping m8.

look at your warning again
notice the line number
check what's on that line, and which section it's in

Starts on line 13 to line 50 (printing error on every line). Compiling with nasm -f elf64 0.asm

now why might these lines give you errors relating to the .bss section?

All of that is in the .bss section mate.

Fuck that's pretty dumb of me. Managed to solve it by moving .text below.
How is it commonly done though? Is there some kind of convention I should follow in NASM?

>How is it commonly done though?
what do you mean? you just wrote the code in the wrong section by mistake, that's all there's to it

Hey guys novice coder here and I don't understand what my professor is doing in his hints with the start and stop variable stuff but I just did it my own way and it fulfills all the requirements listed at the top.

Do you think eh will be mad if I ignore the hint section? I think he was making things more complicated than he needed to?

Attached: file.png (2560x1440, 398K)

even cancer doesn't want to associate with you

Attached: 807c0198.jpg (680x383, 26K)

>trip
>pass

Attached: ralph_h_groce.jpg (360x360, 34K)

I think I understand what he was saying now and I think it's just gay I'ma turn in my work as is

I'm not reading all that shit

the results of baby's first project youtube.com/watch?v=tHPvzOgszXA

thanks it's ok

Good on you for seeing it through! Now on to the next project :)

Thanks :) It was a really dumb idea but I actually learned a fair few things in the process

the first hint and the substring methods might be unnecessary but the rest i think is good practice, the way you're currently doing it seems to query for the $('#num') element every iteration of the loop and it also gets and sets the value of the password field on every iteration, that seems very inefficient
i would try to reduce dom operations to as few as needed

I agree, thanks

stop using a tripcode, retard

Stop making offtopic posts about it, you're the problem not him

there you go, much better

damn, your pretty good

is there any way to convert image to box2d shape?

Hmm. I need to generate a "correctness rate". I have three values: total (the target), correct, and wrong. Except that correct+wrong don't have to add up to total, so I can't just use the trivial solution of rate = correct / total.

What's a good way to calculate this?

also, i'm not a javascript dev but a quick check of the documentation suggests you're not using isNaN correctly

Yes.

epic

thanks!

oh good thanks I need to parse an int first because I didn't do it right

>only 1 (You)

Attached: 1550139214828.jpg (260x298, 20K)

and it's an function lol im gay

Isn't the rate just correct/(correct + wrong)

Good thought. I think I'm gonna use correct/(total + wrong) instead, to give more weight to samples which have more correct answers despite also having more wrong answers. (E.g. if correct = wrong, in your case rate=0.5 for all cases, but with mine rate=0.5 only if you've got all the correct answers, otherwise rate < 0.5 since not only were half your answers wrong but you didn't find all the correct ones either).

if I'm defining the member functions of a class (declared in a header file) that uses a template, what is the syntax to define those templated member functions in a cpp file?

i.e how do I do this with templates:

class AClass {
return_type some_Function(arg1 a, arg2 b);
// declaration but no definition
}

// definition (usually in a cpp file)
return_type AClass::some_Function(arg1 a, arg2 b) {
}

#define ASD "a.h"

#include ASD

#include

int main(void)
{
printf("%c\n", A);
return 0;
}

Holy fucking shit, I didn't know you could do this. Is this standards-compliant?

templates have to go in the header

why would you want to do that?

Is there a programming language that's harder to write than read?

>Is this standards-compliant
don't think so, you should't use %c with pointers

Sepples

the preprocessor will just replace all instances of of symbolic constants with the value of the directive.So as long whatever you're including ultimately evaluates to a valid header file, you're good to go. I probably would avoid this though, it's adds an extra step for whoever is reading your code.

yes, but what about when I'm specifying the templated return value, what does that look like?

you probably don't want to do that
you probably want to put it all in the header unless you know ahead of time what instantiations the template will have

what is A here?

the same as usual? wdym

>Function

What?

I understand C++. What the fuck is this

a closure taking a const reference to a GModelIndex as a parameter and returning nothing

Some kind of closure type analogous to std::function that takes a const GModelIndex& as an argument and returns void. duh.

Alright so I've graduated to the point of knowing what this is

I'm still lost on why in the seven hells you would ever want to do this