/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1553517489338.jpg (1280x720, 547K)

Other urls found in this thread:

pastebin.com/R2xB6CbS
stackoverflow.com/questions/28785217/creating-instances-in-a-loop
twitter.com/NSFWRedditVideo

C# desu

>impostor syndrome
it's not impostor syndrome if you actually suck

>C++ exam
>2 hours long
>finish in 30 minutes
>get an A
>all those normalfags literally seething
It feels good being better than other people at something for a change

Attached: seyana.jpg (1280x720, 51K)

Dennis damn C++ to ERP because it loves to find ways to do something other than my intent.

>tfw I want to join a beginner C++ course so I can blow everyone out of their fucking minds with my on-and-off 15 years of messing with it

Aoi is best girl, fucking fight me.

why don't you put that knowledge to test instead of smurfing around undergrad 16yos you Vimcel

Is that a zoom wheel in the upper-right part of the screen? Did you code it or is it from a gui library?

wrong

Attached: 68065385_p0.jpg (1754x1240, 413K)

Because I'm too much of a brainlet to apply said knowledge in any meaningful way, but also brainlet enough to want to show someone that I'm good at something, even if it's just a facade they'll never know any better!

I just found out about copy constructors in c++ and I feel like a giddy kid during Christmas.
It just makes so much sense, it's *brilliant*.

It also help that i'm FINALLY FUCKING starting to understand how to use const properly.
>tfw understood pointers almost immediately, which is what most people struggle with, but I found other supposedly easier concepts far harder

Still working on this stupid problem trying to find the necessary steps to move a knight from an arbitrary start position to its home position. I feel like my code should work but it just doesn't.
if I run it, it'll go through the first loop, but doesn't recur. It doesn't finish properly either, it just I guess silently crashes, because control never leaves the function to go back to main().

Hopefully the code if self explanatory. The board is a vector of booleans, each move I mark the spot so it's no longer a valid location.
Anyway here's the function that's supposed to be recursive:
const int pmov[16] {2,1,1,2,2,-1,1,-2,-2,1,-1,2,-2,-1,-1,-2};

void knight(int h, int v, Board& board, vector moves) {
if (!board.valid(h,v))
return;
if (board.success(h,v)) {
cout

Is it time to write some more JavaScript?
Because I am ready!

Attached: 47f2833bdff82fc201e53294ba2d712c.jpg (1294x2048, 258K)

...

What was your problem with const? Seems pretty obvious to me desu senpai.

I didn't understand why you could specify it twice and what it affected in what ways.
I was also confused by "just read it from left to right" until I learned that
const int* a const
is the same thing as
int const* a const

Whoops, meant
const int* const a
and
int const* const a

And from right to left*

Well fuck I just realized for one thing I mark the new position before calling the function on said position thereby invalidating it lmao.

RIGHT TO LEFT CONFIRMED!

Ok makes sense. That might be a bit confusing if you just learnt about pointers.

That "fixed" it but now there's another issue coming up, the shortest path isn't necessarily the first one to reach success lol fuck. Never really planned for that when I was thinking up how to solve it. Guess I was imagining it running like perfectly parallel or something so the least steps would necessarily be the first done.

Even worse, since all the branches share the same board, shorter solutions can be blocked from working out. So pretty much any position that requires more than 1 moves ends up taking like 40-50 moves.

RIGHT ALL LIFE!

This is the best way to reduce mallocs and memory usage for trivial operations, right?
pastebin.com/R2xB6CbS
It uses ~2GB on my machine which is what I expected.

Also funny how the compiler smartly no-op's out the std::move'd class' deconstructor's delete so it doesn't go commando on the access violation.

dont use owning raw pointers

dont use smart pointers

And now I realize that's because a delete on a nullptr is automatically nope'd out.
Was a great learning exercise.

this is very bad advice

I like my pointers smart enough to know they don't have to manage themselves because otherwise I might as well go learn c# or some other shit.

this is very bad advice

yes... u want ur pointers smart.. cuz u cant think for urself...

managing the lifetime of objects is a lot easier than managing raw pointers

not as easy as managing ur mom... and her lifetime >:)

hy fella, i can think for mself quit well, thankz

Been learning how to use ASP.NET, literally all the local employers use it.

Is routing much like how NodeJS's Express works?

Any of you good at SQL?

Attached: 1524019588710.jpg (580x580, 196K)

question probably more fit for sqt,but...
Is there a fairly whole "manual" or textbook i can use when learning common lisp and don't understand or know something?

Define 'good'.

wageslave detected

I can't even write a basic select query without looking it up.
It's literally something I've never had to use, and I am employed.

can an employer receed their job offer because you ask for a slightly better salary?

Is it possible to to make a loop for creating new class instances in Python? I want to make a while loop where the user enters the attributes for the object that is then appended to a list until they enter a sentinel value, but without making a bunch of empty ones and a messy if elif else block of items.

What is your best guess of how many regular posters /dpt/ has?

Attached: 4 - kh4Yljc.png (112x112, 13K)

>employed
not as a programmer for sure

I'm employed as a C programmer doing some shit on GNU/Linux.
We never have to use databases for anything. In fact, we don't really need to store any state.

>I'm employed as a C programmer doing some shit on GNU/Linux.
benchmarks? testing the linux kernel? fault tolerance?

There is some driver stuff in the kernel, some userspace drivers using those kernel drivers, some more userspace stuff using those userspace drivers. I'm mainly involved in that last bit.
I'm not going to be any more specific than that, as it may make it too easy to guess who my employer is as they're only 1 of a few companies in this niche, and I'm not going to do that on Jow Forums.

I have three tables
Items, Scores, Users
Users can make a score for any item and item can have multiple scores from different users.

I have some inner joins to get out the items etc and I'd like to filter on scores but per item only use the score assigned by the highest rank user for that item. Where rank is just an int in the user table.

I've seen some examples on single tables using group by and left join with itself but not sure how to do this with multiple tables.

I just spent 3 hours getting my struct with a variable sized array to allocate correctly.
I learned more today than I've learned over whole classes fighting this shit out.

calm down bud

you're not that special

I am calling another application from my console C program. Execution in console pauses until the call returns, as expected.
However, there may accumulate a lot of input, multiple newlines, in the meantime and it all gets passed to my program at once, producing all kinds of undesired behaviour.
How do I best go about discarding all this trash input? I have tried fflush(stdin) to no avail.

post the ER diagram

I write a lot of this style in ruby, maybe it is translatable to sneklang
things = []
loop {
print "?: " # wut u want
s = gets # read input
break if s.nil? or s[0] == 'q' # if EOF or "q" then bye bitch
next if s.chomp!.empty? # if empty then retry
things

I know. It's just common sense to not blurt out a shitload of personal information, but they did ask.

What kind of crappy program can't handle a large amount of data sent to it as opposed to only a small amount of data? It's all buffered.
The only portable way to get rid of input is to just read it and then do nothing with it.

Learning the Blender API so I can export my models to WebGL.

Threads seem to get 70-110 unique IPs each, unless a few people are arguing over 150 posts. Not all IPs are regulars but not all regulars post in every thread. My guess is about 150 people.

In Unity you can just hit the button "Export game to WebGL"

Back to your containment thread.

are there really people into technology who pretend they dont play video games

Please suck my cock. Please.

Using some garbage gayme engine is not /dpt/. This has already been discussed many times in the past; you're not welcome here and specifically have a containment thread for that filth.
WebGL user is bordering on /wdg/, but at least WebGL is more interesting than the shit typical webdev fags do.

I think this is what you mean.
Example query and output is
SELECT data.data_id, data.data, labels.labels, users.username FROM data
INNER JOIN labels ON
data.data_id = labels.data AND
labels.labels->"$.score" > 0
INNER JOIN users ON
labels.creator = users.user_id;

Which gives
+---------+----------------+-----------------+----------+
| data_id | data | labels | username |
+---------+----------------+-----------------+----------+
| 100 | {"x": "y"} | {"score": 50.9} | alice |
| 100 | {"x": "y"} | {"score": 90.1} | bob |
| 101 | {"foo": "bar"} | {"score": 70} | alice |
| 102 | {} | {"score": 100} | alice |
| 102 | {} | {"score": 20} | bob |
+---------+----------------+-----------------+----------+

My goal is to be able to filter the data on score/label but using the score assigned to that data by the highest tier user. Say Alice rank 1 and bob rank 5.
Then if I filter score > 50 it should return 100 and 101 but not 102 because bob is higher rank and scored it

Attached: Screen Shot 2019-05-14 at 4.12.30 PM.png (1042x936, 193K)

The program uses an endless loop to read a single input character with getch(), then looks if it fits one of switch conditions.
Passing a bunch of random data to this loop makes it do unpredictable stuff.
So between returning from the external call and passing control back to this loop, I have to make sure there is no input waiting.
>just read it and then do nothing with it
The thing here is, which character do I check for? Can't be '\n', there may be many of those waiting.

Forgot to add tier to example
+---------+----------------+-----------------+----------+------+
| data_id | data | labels | username | tier |
+---------+----------------+-----------------+----------+------+
| 100 | {"x": "y"} | {"score": 50.9} | alice | 1 |
| 100 | {"x": "y"} | {"score": 90.1} | bob | 5 |
| 101 | {"foo": "bar"} | {"score": 70} | alice | 1 |
| 102 | {} | {"score": 100} | alice | 1 |
| 102 | {} | {"score": 20} | bob | 5 |
+---------+----------------+-----------------+----------+------+

And then desired output for filtering on score > 50 is
+---------+----------------+-----------------+----------+------+
| data_id | data | labels | username | tier |
+---------+----------------+-----------------+----------+------+
| 100 | {"x": "y"} | {"score": 90.1} | bob | 5 |
| 101 | {"foo": "bar"} | {"score": 70} | alice | 1 |
+---------+----------------+-----------------+----------+------+

you can use multiple select's like so
SELECT
FROM (
SELECT
FROM
WHERE
AND
)
WHERE


try using that

>Passing a bunch of random data to this loop makes it do unpredictable stuff.
There is fundamentally no difference from supplying the input very slowly or very quickly. You're still reading one character at a time.
>getch
I don't know windows shit. If this was a unix-like system, I'd tell you to use poll().

Thanks user. Found this while searching it up and it was exactly what I was looking for. stackoverflow.com/questions/28785217/creating-instances-in-a-loop

Attached: dasitmane.png (525x70, 3K)

Whereas are these from?
I know the first one from the seyana akane can YouTube video but can't find any deeper

They're just dumb edits from the anime Yuru camp
The girl in op's pic is also from this show

Attached: [HorribleSubs] Yuru Camp - 12 [1080p].mkv_snapshot_00.06.51_[2018.03.22_21.23.38]65.jpg (390x540, 48K)

game and webdev have their own respective threads and are very very slightly related to programming but design is definitely not.

Okay I think it's working
SELECT sub1.* FROM (
SELECT data.data_id, data.data, labels.labels, users.username,users.tier FROM data
INNER JOIN labels ON
data.data_id = labels.data
INNER JOIN users ON
labels.creator = users.user_id
)sub1
LEFT JOIN (
SELECT data.data_id, data.data, labels.labels, users.username,users.tier FROM data
INNER JOIN labels ON
data.data_id = labels.data
INNER JOIN users ON
labels.creator = users.user_id
)sub2
ON sub1.data_id = sub2.data_id AND
sub1.tier < sub2.tier
WHERE sub2.data_id is NULL AND
sub1.labels -> "$.score" > 50;

gives me
+---------+----------------+-----------------+----------+------+
| data_id | data | labels | username | tier |
+---------+----------------+-----------------+----------+------+
| 100 | {"x": "y"} | {"score": 90.1} | bob | 5 |
| 101 | {"foo": "bar"} | {"score": 70} | alice | 1 |
+---------+----------------+-----------------+----------+------+


My two sub expression are identical and all I'm doing left join with itself. Is there a better way to do this or will it be smart enough to not compute it twice or something? Using MySQL and InnoDB.

Attached: IMG_1015_2.jpg (300x296, 22K)

Oh, I see. I thought they were original characters given how popular the video got. I recall there were line stamps for it.
Thanks for the source mate

I don’t know but who is your favorite regular poster? Mine is the guy trying to shuffle a deck of cards since christmas

>There is fundamentally no difference from supplying the input very slowly or very quickly. You're still reading one character at a time.
Ok, let's say 'd' is a command for deleting a file, upon pressing it, user is prompted with a y/n confirmation.
Now if the user rolls his face over the keyboard while the call is being processed and the sequence "dy\n" just so happens to occur,
random file gets deleted when the call returns.
>windows shit
getch() is also a part of curses and does virtually the same thing on both platforms.

Hello
What is the CMake equivalent in the C# world? I want a cross-platform and universally recognized build system for .NET core projects before jumping into C#.

Attached: 1553001631894.png (1822x3024, 302K)

Cake

Do you even kirby, retard?

Studying for multivariable calc exam. I am annoyed that it takes away time for programming, but hopefully I can pass it and then I'll have all summer to code.

Attached: squirtwoman.jpg (500x709, 94K)

nippons always have good memes with actually quality OC

Attached: IMG_20190514_163721_617.jpg (1055x589, 120K)

How infested is the FP community with onionboys and trannies?

#pragma once
#include
namespace d1tw_calclock {
template std::size_t arb_obj_djb2x(const T& t) {
auto p = reinterpret_cast(&t);
std::size_t h = 5381;
for (std::size_t i = 0; i < sizeof(T); ++i) {
h = ((h

Attached: PessimisticAfraidBrownbutterfly-small.gif (435x250, 1.06M)

I think this might be a hair faster:

[/code]
SELECT data.data_id, data.data, labels.labels, users.username, users.tier
FROM data
INNER JOIN labels ON data.data_id = labels.data
INNER JOIN users ON labels.creator = users.user_id
INNER JOIN (
SELECT data.data_id, MAX(users.tier) AS top_tier
FROM data
INNER JOIN labels ON data.data_id = labels.data
INNER JOIN users ON labels.creator = users.user_id
GROUP BY data.data_id
) sub ON data.data_id = sub.data_id
AND users.tier = sub.top_tier
WHERE sub1.labels -> "$.score" > 50;
[/code]

oops
SELECT data.data_id, data.data, labels.labels, users.username, users.tier
FROM data
INNER JOIN labels ON data.data_id = labels.data
INNER JOIN users ON labels.creator = users.user_id
INNER JOIN (
SELECT data.data_id, MAX(users.tier) AS top_tier
FROM data
INNER JOIN labels ON data.data_id = labels.data
INNER JOIN users ON labels.creator = users.user_id
GROUP BY data.data_id
) sub ON data.data_id = sub.data_id
AND users.tier = sub..top_tier
WHERE sub1.labels -> "$.score" > 50;

goddammit more typos but you get the idea

About on par with the rest of the programming "community".

Could you code the move coordinates as a vec2 or similar, or if using a 1-d array put 2-wide border and use offsets representation, or at least have two sets of displacements... Anything but counting weird!

It might be segfaulting for using too much stack... You can test that theory with a global/static depth variable. Increment apon entering and decriment before exiting.

Deep recursion may happen by re-trying old positions forming search loops. If the board structure passed as an arguement is abnormally large that could be an issue also... But it's probably recusing too deep.

Leaving breadcrumbs on a squared visited (as part of the move stack and valid moves check) would prevent search from going into loops.

Consider making the success printout its own function, and make it print an ASCII board but with numbers as footsteps. That might look nicer.

Your program would have printed multiple solutions if they exist BTW.

Creepy! creepy! creepy!

How do i draw lines of varying lengths with characters? Please no boarder hacks.

EX:
###
#
#
#

####

Welcome to 4channel.org, please tr -s "\n" or be ridiculed.

for (int i = 0; i < n: ++i)
puchar('#');[/cpde]
Come on user, it's not hard.
Although you do need to actually put some thought into how everything gets printed when doing vertical lines, because ideally you don't want to do any sort of backtracking terminal nonsense to get everything you want drawn.

Completely. It’s over for fp.

I was wandering if there was a built-in way of doing it, that didn't require extra lines of code for me to write.

it's 2019 and clang is still a massive pain to use on windows

Literally everything is a massive pain to use on Windows, and who's fault do you think that is?

minwg-w64 and tdm-gcc work though

clang has hardcoded paths to mingw binaries. there is no excuse for this.