/dpt/ - Daily Programming Thread

old: What are you working on, Jow Forums?
reminder: python best lang

Attached: Drunk_Kobayashi_Python.png (640x362, 220K)

Other urls found in this thread:

usledsupply.com/shop/12v-rgb-flex-strip.html
youtube.com/watch?v=0lfX1XONM4Q
osepp.com/electronic-modules/sensor-modules/61-gyroscope-sensor-module
osepp.com/electronic-modules/sensor-modules/54-accelerometer-sensor-module
jsfiddle.net/XBfzn/
biblegateway.com/passage/?search=Matthew 22:36-40&version=NIV
pastebin.com/1xKmAQ0K
anyforums.com/
twitter.com/SFWRedditImages

>reminder: python best lang
[citation not required because this is fake news]

>What are you working on, Jow Forums?
Loading up on caffeine and sugar to hopefully start programming soon. Don't feel ready yet. Tedious work ahead and I need to be ready.

Attached: 1504792383889.jpg (600x797, 220K)

i want to nakadashi kobayashi

Someone make a real thread please

What job skills or certs will make the most money and be most secure today and for the next 5 years? Not looking to work 50+ hours a week unless the pay is $250,000+.

I.e., Python, R, C++, or Certs like CISA, CFA, etc.

Attached: career_skills.jpg (680x460, 174K)

I've been working on a 64 bit NASM project for the last few days. Only person in my assembly class using it. My life is a meme.

Attached: maxresdefault.jpg (1280x720, 58K)

just become a neet, it's a lot easier

Attached: 1548336418663.jpg (1920x1080, 198K)

Become a DBA. You can pull down six figures despite being an unwashed philistine.

If you did okay in set theory, learn relational database theory. Otherwise fuck around with SQL on a competitive programming site for a while.

I just daisy-chained a couple of shift registers together. It's messy but it works.

Attached: s2.png (651x875, 988K)

I don't get a syntax error when i put it in ghci, are you sure you've posted what you wrote?
Btw the parentheses aren't necessary (but aren't an error either)

It was something unrelated. I figured it out.

neat. You know you can use a LED strip like this and all you need is 1 pin.

usledsupply.com/shop/12v-rgb-flex-strip.html

Attached: output.webm (720x480, 2.57M)

Attached: IMG_20180516_132732.jpg (2592x1944, 1.08M)

I saw that kid Devon Crawford use these to do music stuff. They seem pretty fun.

It draws a lot of wattage at full power. Also I would have added some more rows or gone with a different resolution so I could at least draw some sprites from NES and gameboy games. Also, I cut the leds and wired them all together to space them out and I wouldn't do that again.

Attached: 1500089046150.gif (320x291, 2.97M)

Having mostly done web development, I now have to programm a pong which is playable through the network in C++. I understand the basics of sockets / networking, but I don't have much experience in C++. What's a nice IDE for the start on Linux ?

Are you using arduino? I've been wanting to get into PIC controllers for a while to get away from the god awful arduino IDE/ perverted arduino C, but I'm still a baby and probably need to put in several more hours with electronics in general

>IDE
>C++
>linux

Raspberry Pi 3b+ to be specific. All you need is 1 PWM pin which is all pi's have.

Attached: voltage.png (1736x1836, 3.26M)

>C++
>IDE
Gross user. Just use C and vim.

Attached: cat++.png (200x209, 34K)

I have been working on some guides that condense 15 years worth of learning on the chans into one image. When I was a young lad older guys would make these kinds of images that were like guides for the youth and they disappeared. I guess because they were stale meme.

But guides aren't a meme guides are guides and good guides kick ass.

Attached: april.png (2232x2122, 2.62M)

Maybe IDE is the wrong word. I just want to use something else than nano that is not vim / emacs.

I like sublimetext

1. It's may
2. What does this have to do with programming?

vscode just werks.

I use compact c language + vi

I was turned off VS Code for a long time but it's actually really comfy

Cool. I'm using an Uno clone with an expansion shield. Looking to graduate to a PIC18F877A - they're like $5 and you can use them on custom PCBs, which sounds pretty a e s t h e t i c to me.

Attached: expboard.jpg (400x720, 55K)

This was my original arduino project. Had a wireless ps2 controller hooked up and ran off a 7.2v LiPo. Arduino's are great. I have never used PIC but I am sure they are great too.

youtube.com/watch?v=0lfX1XONM4Q

Pretty cool. I'd convert that to a wall plug and have it on top of a bookcase or something running all day.

That's the funniest end table I've ever seen. Are you using a GY-521 gyroscope module or what? How fast is the data read interval? Really nice man!

Comes with default dark mode. First impression looks good

It's all from Fry's it's OSEPP, some overprices shit.

osepp.com/electronic-modules/sensor-modules/61-gyroscope-sensor-module

osepp.com/electronic-modules/sensor-modules/54-accelerometer-sensor-module

It had/has an accelerometer and a gyroscope that run off i2c.

I forget the exact specs. I would not recommend buying these components, it's just what my local store had.

If you look at my wiring the EMI that those wires would have had must have been immense. I don't think it matters how fast the i2c modules are.

Also, the motors had built in encoders, so I could cheat and return to original position without a problem.

At first to combine sensor data I just used something like gyroscopeVal * 0.85 + accelerometerVal * 0.15 at first, then I switched to a Kalman filter.

Then I used a PID loop to tune how well it could balance. It was a quick and dirty hack. Definitely would change things about how it was done.

Attached: 800px-Pneumatische_regelaar.jpg (800x826, 159K)

Try doing a live session with someone. So fun.

that's sick man. Did you essentially write your own Kalman filter from the ground up? How did you find the process, generally?

Thank you. There were posts on forums of people explaining how they made their bots that were similar which is how I found out what algorithms are popular for these bots.

The Kalman filter I just found an implementation of (probably on stack overflow). I am not good at math and that algorithm in particular makes no sense on wikipedia.

Attached: 1530886134575.jpg (1200x900, 210K)

>asuka
>not a meme

Very nice, thanks for sharing that. I have a bunch of ideas going through my head. Going on vacation soon and won't be able to take anything with me really other than a laptop. Do you know of any good hardware simulation software for linux that allow you to test your programs? I fear I'll get rusty after making decent progress this week.

>Do you know of any good hardware simulation software for linux that allow you to test your programs
No
>I fear I'll get rusty after making decent progress this week.
Don't know what to say here. I have to relearn anything electical every time I do it. You can always program though. After I made my bot I made a "simulation" of it on jsfiddle using webgl that used the same PID loop and linear filter to balance the robot.

O hey... I found it... google is nice

jsfiddle.net/XBfzn/

wasted hours of my life because some stackoverflow tard recommended msys2. mingw will probably play nicer with cmake. and mingw has gcc 8.2 instead of gcc 7.3

Just use VS code with some plugins. There are some other minor IDEs and text editors, but most people use Vim or Emacs for everything on Linux.

What is faster for a Computer, (5000/2)/(100/2) or 5000/100

Emacs + rtags

yes

Attached: porn_mode.png (1177x876, 61K)

>What is faster one arithmetic operation or two arithmetic operations?
Any non-shit compiler will optimize both to a constant though.

Programming noob here, is there any reason why using UUIDs as a way to generate unique filenames wouldn't be a a good idea?

Yea but the numbers are bigger in ones

>Any reason using a universally unique identifier as a universally unique identifier wouldn't be a good idea?

nigga just use wsl

Best frameworks or whatever to build single page app forms? We are ditching a form RAD tool for another and I figure I might as well convert some of them to actual web pages.

REACT

Jesus this is hard

Nano is actually pretty good. If you have syntax highlighting and constant cursor position and the file is small...

There should be a bunch of *.nanorc files in $PREFIX/share/nano for different lang syntax.

biblegateway.com/passage/?search=Matthew 22:36-40&version=NIV

Try something like this. Then you tune the loop based on what keeps it stable..

// Global vars or functions here
reset(); // reset robot
var P = 30.0;
var I = 14.0;

var last_angle = 0.0;
/** overridden mainLoop function, ran inside main loop */
function mainLoop() {
// insert your main loop logic here
var p = getAngle();
var i = p - last_angle;
last_angle = p;

var out = P*p + i*I;
if (out > 0) {
goLeftAt(Math.abs(out));
} else if (out < 0) {
goRightAt(Math.abs(out));
}
}

Attached: bot.png (652x785, 38K)

Holy shit I didn't know about that file. Thank you user

I can get the balance to thrash and overcompensate with these values.

var P = 40.0;
var I = 34.0;

Attached: bot_2.png (424x210, 12K)

is it a good idea to use std::optional with a trivial raii type or should i just use unique_ptr?

That's perfectly sensible. Why would you think it's a bad idea?

at least have the decency to recommend vscodium instead of code

shill me the comfiest SQL IDE. I used the trash microsoft studio shit and the ultra buggy dbeaver. any suggestions?

SQL IDE? Why not just use phpmyadmin which comes with every xamp installation

it is not free and my jewish employer wont pay for it.

A big meme, she takes half the image.

How do you guys program/learn to program without wanting to kill yourselves? I fucking wish I had a teacher to help me, because sometimes I don't even know what to do. I wish there was a book that covered everything from start to finish, like the bible of computer science: from total retard to Donald Knuth in 40k pages.

Attached: 1535397967748.png (1004x612, 48K)

do shit
when you find something you can't do ask a stupid question
do shit again

Eh, that's why courses exist. You either feel you need guidance, or you are actually an alert, lucid self-educated man. Or a little of both.

What do you mean it's not free are you retarded

Thanks, friends. I'll keep doing shit then.

im not the guy to ask cos im just starting learning myself but

1) lots of googling at every step (mostly for syntax help)

2) step away from the computer if you are stuck

3) (worst option but sometimes needed) find a similar project and see what they did

I think I have full autonomy, it is slow as fuck though.

// Global vars or functions here
reset(); // reset robot
var P = 29.0;
var D = 11.0;
var speed = 5.5;
var target_x1 = 40;
var target_x2 = 360;
var curr_target = target_x1;
var last_angle = 0.0;
/** overridden mainLoop function, ran inside main loop */
function mainLoop() {
// insert your main loop logic here
var offset = 0.0;
if (getX() > curr_target && curr_target == target_x1) {
offset -= speed;
} else if (getX() = curr_target && curr_target == target_x2) {
curr_target = target_x1;
}
var p = getAngle();
var d = p - last_angle;
last_angle = p;

var out = P*(p + offset) + D*d;
if (out > 0) {
goLeftAt(out);
} else if (out < 0) {
goRightAt(Math.abs(out));
} else {
setThrottle(0);
}
}

Attached: bot_3.png (423x223, 13K)

Why does refactoring, fixing, and tidying up code which was previously rushed to meet a deadline feel so comfy?

Oops.. this cheats by overwriting speed which the engine uses. Here is the solution without cheating.
// Global vars or functions here
reset(); // reset robot
var P = 22.0;
var D = 40.0;
var dt = 4.5;
var target_x1 = 50;
var target_x2 = 350;
var curr_target = target_x1;
var last_angle = 0.0;
/** overridden mainLoop function, ran inside main loop */
function mainLoop() {
// insert your main loop logic here
var offset = 0.0;
if (getX() > curr_target && curr_target == target_x1) {
offset -= dt;
} else if (getX() = curr_target && curr_target == target_x2) {
curr_target = target_x1;
}
var p = getAngle();
var d = p - last_angle;
last_angle = p;

var out = P*(p + offset) + D*d;
if (out > 0) {
goLeftAt(out);
} else if (out < 0) {
goRightAt(Math.abs(out));
} else {
setThrottle(0);
}
}

baste optimisers

peak segway code here
// Global vars or functions here
reset(); // reset robot
var P = 12.0;
var D = 76.0;
var dt = 8.5;
var target_x1 = 70;
var target_x2 = 330;
var curr_target = target_x1;
var last_angle = 0.0;
/** overridden mainLoop function, ran inside main loop */
function mainLoop() {
// insert your main loop logic here
var offset = 0.0;
if (getX() > curr_target && curr_target == target_x1) {
offset -= dt;
} else if (getX() = curr_target && curr_target == target_x2) {
curr_target = target_x1;
}
var p = getAngle();
var d = p - last_angle;
last_angle = p;

var out = P*(p + offset) + D*d;
if (out > 0) {
goLeftAt(out);
} else if (out < 0) {
goRightAt(Math.abs(out));
} else {
setThrottle(0);
}
}

Attached: bot_4.png (424x225, 11K)

threadly reminder

Attached: CppCon 2016 - Jason Turner “Rich Code for Tiny Computers - A Simple Commodore 64 Game in C++17”- (1280x720, 1.93M)

I cant tell if this is completely retarded or not

Attached: clion64_17XZ2ZwYUc.png (846x246, 16K)

It's C++, so it certainly is.

Work through MIT's EECS curriculum on OpenCourseWare.

I'll check it out, thanks man.

That only matters for really large numbers.

>What are you working on, Jow Forums?
I finally found out how to loop over beliefs in jason/agentspeak
Only took around a day

>using an iterator recursively
why

also, code duplication is bad

wtf I'm #WithHim now

Attached: 1556879624016.png (602x687, 285K)

>why
because of how i was trying to do this earlier
>also, code duplication is bad
thanks for pointing that out

Attached: clion64_1XoXnSBq7D.png (853x207, 13K)

Man, politicians these days are pathetic. Wish they'd stop dragging programming into their oppressed minority pandering contests.

Take this code, either clean it up or port to whatever language you prefer. Then start adding features and improvements.

Questions are welcome if you need help.

[edit.c] pastebin.com/1xKmAQ0K

Attached: IMG_20190503_033855.jpg (960x960, 110K)

>indenting case labels

Attached: tom.jpg (480x362, 28K)

>insert(rub)

>break

Attached: ahe.jpg (613x582, 166K)

Reads better desu

source pls

I like it when a complex project I like gets new issues.

Attached: 1556689257947.png (4000x3530, 72K)

How much of a paradigm shift is dependent typing?
How compatible is dependent typing with programming paradigms other than functional?

not very
it depends

Learn to reverse image search

Attached: unknown.png (1221x605, 356K)

Can someone explain how C# ref/copying works?

Attached: c#.png (297x576, 14K)

types defined as classes are reference types
all variables of this type are references and the dot operator implicitly dereferences
it's fucking dumb

When you set r.i = 4 on line 26, you're also setting t.r.i = 4 because r and t.r refer to the same object. But when you assign a new object to r on line 28, you aren't affecting t.r.

>reminder: python best lang
Incorrect: QuakeC best lang