/dpt/ - Daily Programming Thread

Old: What are you working on?

Attached: 1538226647113.jpg (280x210, 15K)

Other urls found in this thread:

github.com/junegunn/vim-plug
twitter.com/SFWRedditGifs

nth for Nim!

Have you taken your amphetamine today user?

Attached: Erdos_budapest_fall_1992_(cropped).jpg (324x430, 45K)

What text editor do I use for Python on Windows?
Something fast, easy to use and FOSS

Vim?
It's pretty easy to get started - an hour or two in vimtutor and off you go

user! That's not how you do this in JavaScript!
Worry not, tho. I'm here to show you the proper way.

Attached: ca107ef1f80a9b5586c1b91ee1c24e53.jpg (1049x1049, 108K)

I thought it was hard to use is it really an hour or two to learn the basics? Always wanted to give it a shot

>I thought it was hard to use is it really an hour or two to learn the basics? Always wanted to give it a shot
The general public acts like things that take more than 30 seconds to understand are hard.
Getting to a point where it's more comfortable to use Vim than anything else isn't hard and you can do it *right now*. Go, do it. I believe in you.

>is it really an hour or two to learn the basics?
It's atleast an afternoon of setting up your keybinds for things like new buffers, splitting buffers vertically or horizontally, deciding on your leader and all its keybinds, refining, and then whatever extensions you install and their keybinds.
install neovim and use github.com/junegunn/vim-plug

>It's atleast an afternoon of setting up your keybinds for things like new buffers, splitting buffers vertically or horizontally, deciding on your leader and all its keybinds, refining, and then whatever extensions you install and their keybinds.
None of these things are what you should focus on first thing when you install Vim. They come later.

That's ricing, retard.

They are though.
When you want to edit a config file, your first instinct is to open it with the most convenient text editor of choice. If you're clunky with vim and still aren't comfortable navigating, you're going to open mousepad or whatever else you use. And that's a bad habit because why the fuck do you want two text editors for the same job?
People just starting out in Vim are going to be googling just to navigate between two different files/buffers.
It's better to git gud and set keybinds you like first.
keybinds aren't rice you absolute retard.

lol

Yo tryna organize some shit in SQL.

/dpt/, If I want to query the top products sold from my salesperson that does not include the products from my top 3 salesperson, is that possible?

Like if john, zack, and maria are top 3 sales people, my query should not bring them up

Best I got was through hard code

SELECT TOP 10 * FROM (SELECT * FROM Products INNER JOIN Salesperson ON Products.id = Salesperson.id ORDER BY AmountSold DESC) WHERE NOT (SalesPersonName = 'Zack' OR SalesPersonName = 'John' OR SalesPersonName = 'Maria')

There's NO way this can be done without at least 2 queries right? 1 to know the top 3 sales people, the second to get what you need filtering them out?

nigger

lmao gottem

I'll take that as a no

thanks

bro wtf r u doing, this is one sql statement.

literally remove the inner select

in elixir this is just
People
|> Ecto.Query.order_by(desc: :sales)
|> Enum.drop(3)

I modified what I had in mind I forgot to change that

still though there's no way to filter the top 3 of a query (top 3 sales) on the top 10 of the main query right?

I just don't want to keep hardcoding this shit for all departments...

Why don’t you just order it by amount sold and then do OFFSET 3.

Like the fact that you need to filter out the top 3 by name is retarded....

Yes there is. OFFSET

Autistically implemented a reasonably efficient (I think) solution for the problem in

Attached: autismo.png (680x1963, 234K)

After taking a discrete math course, I understand why he was hopped up on amphetamondz.

amphetamines don't work for me, I just end up going on a Jow Forums shitposting spree.

Yeah I had thought of that. Although a sales person may be in the top 3, it doesn't imply a the top 3 product's "amount sold" was sold by them.

So I could have a sales guy who sold several products in the bottom of the top 10, but he could be number 2 in the ranking. And number 1 sold several of the upper top 10 most sold products.

I'll just hardcode this shit I guess

what language is that?

haskell

Without giving it too much thought so I could be wrong, this code looks *super* long for something like that.
Are you sure you're not overthinking it?
Feels like it could be done in 1 function for parsing and then 1 function for logic

Should be bannable.

What theme and font do I use on my vs code

I'm no expert so that could be the case, but to keep a minimal state and do it in one pass, this is what I came up with. I'd like to be enlightened if there's a lot of redundancy there.

I keep the best and last block as the state as I read through the string. Each block consists of its start end end position, a set of the zeros flipped, and the number of further zeros that can be tolerated. I can't think of a slimmer state. Setting this up covers lines 22-34.

Translating '0's and '1's into the Position type and the associated utility functions could be done away with perhaps, but this is probably cleaner.

HOLY SHIT GUYS, I just realized C is proof of free will. Undefined behavior is non-deterministic and outside the realm of causality. Since humans are just superior machines we also have undefined behavior which is free will. I am a motherfucking genius.

Attached: DBB23EA0-D944-4942-8AC2-32F36AA442F7.png (604x613, 209K)

boning up on some Linux/CLI

Kill yourself, your retarded UUID frogposter.

dumb frogposter

dumb frogposter

retarded frogposter

eloquent frogposter

Select person.*, numproductssold toppeople from (
SELECT sum(products.amount_sold) as numproductssold, person.primary_key FROM products left join person on products.person_id = person.primary_key group by products.person_id ) toppeople
Left join person on toppeople.person_primarykey = person.person_primarykey
Offset 3

I meant “Toppeople.numproductssold” in the first select

Let me just rewrite it:

Select person.*, Toppeople.numproductssold from (
SELECT sum(products.amount_sold) as numproductssold, person.primary_key FROM products left join person on products.person_id = person.primary_key group by products.person_id ) toppeople
Left join person on toppeople.person_primarykey = person.person_primarykey
Order by toppeople.numproductssold
Limit 10
Offset 3

Besides a couple STL containers for lazy people, what reasons are there to choose C++ over C?

There is absolutely no reason to use C++ over any language, let alone C.

C++ actually has features
unlike C which is just a minimalist stripped down algol 68 we're stuck with because of bell labs

Lambdas are nice to work with. Some parts of standard library are sane enough for daily use (threads are great, so are multithreading facilities like mutexes or atomics, chrono is meh bit works, filesystem is ok from what little I've done with it), lambdas are nice

destructors allow you to guarantee freeing a resource or closing a file etc without having to manually do it at every separate exit point from a function

How do chinese programmers compare to pajeets?

>it's lazy to not want to implement an associative array on your own

C++ is strongly typed if you use it correctly. std algorithms are pretty good.

From the few I've seen, they're very unremarkable most of the time. Extremely quiet, stick to their own chinese clique, simply does what they're told, never produces anything remarkable, just what's barely passable.

An apt description of yourself

Is there anyone on earth who actually uses VS code and .NET core? How the fuck am I supposed to organize my code? And how do I include 3rd party dependency like Avalonia UI?

Yeah, but I don't have slanty eyes.

why doesn't this work?

char test = mvwgetch(screen, 3, 2); // there is a '%' at this location
if ( test == '%' ) {
wattron(screen, COLOR_PAIR(RoB_PAIR) | A_BLINK);
mvwaddch(screen, 3, 2, '!'); // replace the '%' with an '!'
wattroff(screen, COLOR_PAIR(RoB_PAIR) | A_BLINK);
wrefresh(screen);
}

I'm at the stage of learning basic javascript and using git from one of those free online coding classes, the classes I currently take will cover various materials up to basic javasript/front end/backend development. Any recommendations for paths/stuffs I can learn outside of those which will make me decent money or have relatively big demand from the market?

I'm interested in programming purely to make money to be honest, I've some background in analog electronics and mechanical stuffs but the competition for those jobs are tight in my shithole country and I rather have extra salable skills to make money or combine it with my current skills

I heard of Avalon Studio but I never used it. You can use the wpf template and add the avalonia nuget package and just compile if you want to use VS. Organize your code however you like but it would be better to use mvvm and one of its libraries like prism and reactive-ui

>I'm interested in programming purely to make money to be honest
You're not going to make it.

Probably about a half hour to "get" the modes, and some basic commands for 99% of just getting things done.
Then a lifetime of "Whoa it can do that?" and ricing out your .vimrc
vimtutor is great though, even just as an example of quality interactive instruction.

How bad is this?

Attached: hmm.png (711x56, 3K)

What can I do lol, following my passion? Drawing and creating music won't make me enough money to live even modestly. I'm interested in learning programming because the opening for programming jobs in my country are flooding while the applicants are very few. Also my job choices are actually limited because there are various circumstances in my personal life and I rather try to become a programmer while I still have the time compared to my other choices

dat fucking CCN

The "flood of job openings" is a lie. There are shitloads of programmers, but many employers have ridiculous expectations for what they can get.
They only want """senior""" programmers with 5+ years experience in a 3 year old framework type of shit. Nobody seems to want to hire graduates or junior-level developers and actually spend some effort training them up a little bit. You always hear about junior-level positions with literally hundreds of applicants and people struggling to get jobs out of university. It's especially bad with webdev, because that's even more oversaturated.

Basically, unless you're fucking amazing at programming or have a passion for it, don't bother.

mvwgetch returns a char you press, not retrieve a char from a position on the screen. You're not supposed to use the screen for storage.

fixed it
char test = mvwinch(screen, y, x) & A_CHARTEXT;

just doing that to test shit, plan on moving data to a structure later.

>later
sorry, now

A guy showed up to my GitHub project and he's submitting lots of extremely high-quality patches. This is a very good feel.

Attached: me-and-my-repo.jpg (561x474, 84K)

>letting more competent devs do things to your project you could never do while you just watch
enjoy being codecucked

Can you program without looking at other code for reference?

Depends on the language.

yes, but you need some practice.

It depends on what I'm programming.
Obviously I can write syntactically correct code by myself, but reference code is extremely helpful when working with unfamiliar APIs.

>Jow Forums command line browser

If I have a clear idea of what to do then yes. I push myself to not use an IDE and not look things up on the internet or copypaste. This is only for when I care about the implementation of something.

If it is some single use thing like some quick script or whatever I don't give a shit and will copypaste whatever I can find.

Only in languages and with libraries that I'm very familiar with. But there is no point in doing such a thing.

Tried to make an Random Number Generator that excludes numbers that have already been displayed. Can anyone help here?

put the generated number in an array and then add a check to the random-number-generater algorithm that checks the array for any repeated numbers

Thanks user for the idea. The real tricky part is doing it in C++. I'm hoping to make what is essential a bingo wheel minus all the letters. That way I can just have 100 numbers, and then when we go for 100 times, the game immediately ends lol. And it's for a pet project.

>Random Number Generator
>excludes numbers that have already been displayed
nigga wut

Are some people just unable to be programmers?

Allow me to clarify.
If a number is displayed on screen, then it doesn't show up again a second time. If it's been shown once, it cannot show again.

all niggers and women that are sub 100 iq

Yes, even in western countries it's probably a majority. Search the camel has two humps.

imo Bingo is more like a shuffled list than a rand

Alright. Thanks. I just wanna get that whole business outta' the way. If it's a shuffled list every time, how would I shuffle the list automatically then?

Cutoff for anyone worthwhile is probably 110 or so.

yes, some people are lucky

Is it really that bad? do I really posess a skill that only a few people in the world have?

Attached: 1548044549078.png (380x286, 144K)

if you mean already being able to then unfortunately, if you mean being able to learn then not really

Fisher-Yates algorithm

"It depends". I would look at the CCN cause that looks like a red flag. That's really what these tools are for: give me a heuristic and if something looks out of line, I'll take a look. There's no definite answer as it's all subjective

Thanks user you absolute madlad. I might do it tomorrow though, and figure out how I would implement the range, and then let the algorithm take care of itself.

>Implying
Everything is okay user you will git gud one day.

Your language's standard library might have a shuffle built in already.

Well, if I can get a shuffle working that exhausts all the numbers, then hot diggity I'll take it.

so i am trying to learn c on my own this summer cuz next semester class taught in c.

question: is #define .... basically a global final variable ?

Do you guys program on vertical monitors?

I program vertically on monitors.

>there will never be another movie like Sneakers that isn't a Hackers/Mr Robot type edgefest
feels bad