/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: programmers.png (712x546, 26K)

Other urls found in this thread:

github.com/victorqribeiro/faceRecognition
htdp.org/2018-01-06/Book/
docs.racket-lang.org/ts-guide/
ccs.neu.edu/home/stchang/popl2017/
pastebin.com/v4UraADU
twitter.com/SFWRedditImages

>What are you working on, Jow Forums?
Trying to learn J as a mongoloid. Mindfuck

Lisp is the most cost post frost lost toast

Attached: 1548020984592.jpg (401x500, 32K)

friendly reminder to fucking proofread lest you waste multiple days trying to solve a problem that doesn't exist

Fuck that. A real programmer always wastes twice as much time in his laziness on hacking away as what it would have taken to properly study and plan beforehand.

I just got hands on a database.
the collation is set to latin1_general_ci but whenever I run a query (a big one) it tells me
>illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_general_ci,IMPLICIT) for operation '='

The thing is that the tables I use do not use utf8mb4_general_ci collation or any utf8 charset.

Any idea what's happening ?

>chmod +x program
>mkfifo pipe
>nohup ./program >nohup.out 2>&1

Right now, I'm working on a Python based search engine. I'm not too far into the project. I've only gotten to the stage of making a web crawler.

Try running

SHOW VARIABLES;


and seeing the output.

Can someone please explain to me why python is a majorly used language? Not sure if this is the right thread or not but I felt this was a programming oriented thread I might get better voices in here. As far as I can tell it's very limited as an interpreted language and has strange variable and indexing rules?

Just imagine how much money the resident Cniles must be making. After all, they never make mistakes managing memory in complex multi-threaded programs. They handle all possible errors and faulty user input perfectly. $300k starting, more commonly $3M though. But how do they have the time to post here? Probably retired at age 25.

Brainlet friendly and lots of libs

Non programmers like Python because it's convenient as a scripting language. It's also convenient for a lot of scientific work.

This
It's basically advanced pseudo code
Also, I'm a big fan of static languages, but the dynamicity of python is great for trying things out and quick scripts for scientific work

probably a retarded question but what should I use to store an actual (word) dictionary with definitions to access? I doubt it's a good idea to load millions of strings at once into a hashmap

>it's very limited as an interpreted language
its very expressive and easy thanks to dynamic typing and comfy REPL
>strange variable and indexing rules
not at all, it has very standard indexing rules
it doesn't have variable keyword, so you just assign shit like
variable_name = "value"

python is really easy, clean looking, has a lot of libraries and is very comfortable for quick'n'dirty scripts or numericalanalysis/ML

it depends on what you want to use it for
what language?

python

>it depends on what you want to use it for
in short I'm parsing large texts and want to look up every word used

github.com/victorqribeiro/faceRecognition

I'll Port the MLP code to go so I can train the nn faster

If the complete set of exceptions that can be thrown is declared then the overhead can be reduced considerably, to the same order of magnitude as just returning a value.

In Java, can threads be used to run different, specific branches of code?
E.g. use a load of threads to calculate a number of independent calculations in the same object.

There's no point using threads that all do exactly the same thing, so of course.

yup, dictionary is what you want

C++ is so fucking fat and retarded

Attached: local gopher not so tough after being typed.png (1456x1388, 245K)

This will be my contribution to humanity
var num = 1, x, y, len_num= 8;
var numbers = [];
for(x = length_num; x >= 1; x--) {
num = num * x;
y = x-1;
numbers.push(x);
if(test.length === len_num){
console.log("ANSWER: ");
console.log(test.join('*') + " = " + num);
}
}

Who are these people who use Go? Becuase it looks like a huge step back from wherever you're now. Hell, I would rather use C than Go.

tfw your code is so bad that as someone who writes a lot of JS I had to take a step back and realize that it was indeed JS.


Damn nigga. What the fuck are you trying to do?

>===

Attached: 1520987687923.jpg (211x239, 6K)

>What is factorial?
>tfw your code is so bad that as someone who writes a lot of JS I had to take a step back and realize that it was indeed JS.
What did you expect from JS? Mona Lisa?
Also the code without any fuckery...
var num = 1, x, y, len_num= 8;
var numbers = [];
for(x = len_num; x >= 1; x--) {
num = num * x;
y = x-1;
numbers.push(x);
if(numbers.length === len_num){
console.log("ANSWER: ");
console.log(numbers.join('*') + " = " + num);
}
}

Kotlin does === right.

A database is well suited for this.

epic meme image OP LOL!

>not using camelcase with JS
>using global variables
>initialising a bunch of things all at once for no reason, making it impossible to know what is what and what you are using it for
>mutating things all over the place and then reusing it again in the next loop
>initialising x inside and outside a for loop, as var too for extra confusion

JS is not the problem buddy, your code is nonsensical to look at.

>if inside the loop, checking for something that happens AT THE FUCKING END
just put it outside you flaming brainlet
>declares y, assigns to y, never uses it
FOR WHAT PURPOSE

damn nigger that's some niggerlicious kode
have some in haskell
factHisto = ((++) . intercalate "*" . map show (" = " ++) . show . product) . enumFromTo 1

>apply for job
>automated HR reply
>heart sinks into rectum

A Javascript demodulator that uses the microphone. As it is a relatively new API there is a lot of conflicting and deprecated information.

Working on my OS as usual. Splitting up all the window compositor's dirty rects into unique pieces that don't overlap. I need this because overdraw caused alpha blended windows to look all wrong in areas where they were drawn more than once :)

Attached: Screenshot at 2019-02-19 14-21-14.png (1920x1080, 855K)

I commented out my patreon button module because Patreon has turned into a platform of censorship and my web platform promotes freedom of speech. Unironically what I last worked on lol. Granted, it was for like 1 minute. But I feel like I accomplished a lot at that moment.

RIIR

No

ЯIIR

Wow! Thank you for the code. Do you want to partake in the cool aid drinking?

no thanks, not my cup of tea
certainly looks like yours so have fun
>>>/wdg/

JavaScript rocks!

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

how do I learn LISP from absolute 0

htdp.org/2018-01-06/Book/

Imagine having no type system but wanting one so badly.

Attached: Screenshot_2019-02-19 I Fixed-Size Data.png (731x853, 100K)

After troubleshooting some horrible template linker errors in C++ a long time ago, I have become fascinated by the idea of generating a database for code during the preprocessing and compilation steps of a build. I’d have it track Everything: variable names and types, functions, files and lines, etc. all so the next time the linker tells me there’s an undefined reference to some unreadably name-mangled template function, the DB would tell me that it’s from preprocessor generated code in this file at these lines with a preprocessor macro from that file at those lines called with these parameters.

I realize that to do so, you pretty much have to know the compilation model inside and out, but jizzus, is it too much to ask?

docs.racket-lang.org/ts-guide/

>Imagine having no type system but wanting one so badly.
You can implement your own in Racket.

ccs.neu.edu/home/stchang/popl2017/

Easy to use and has lots of libraries for most work.

It's great if you just want to open up a text editor and write a script to do something for you because it's the closest to pseudocode compared to most languages.

SQLITE is pretty fast if you care about speed.

Yeah but the book is not about Typed Racked, it advises you to put type signatures into comments for readability.

6502 ASM. An NES game engine. Fun Stuff!

Attached: asdf.png (1847x1071, 360K)

var nums = math.range(1, 9).toArray();
var products = nums.join("*");
var result = nums.reduce(function(a, b) {return a*b;});

console.log("ANSWER:\n" + products + " = " + result);

Hi, Bill.

#!/bin/bash
# This bash script is used to backup a user's home directory to /tmp/.

user=$(whoami) input=/home/${user}/Programming output=/tmp/${user}_home_$(date +%Y-%m-%d_%H%M%S).tar.gz tar -czf $output $input echo "Backup of $input completed! Details about the output backup file:" ls -l $output


I'm learning shell. this script "executes" but gives the following:
tar: Backup of completed! Details about the output backup file\:: Cannot stat: No such file or directory
tar: ls: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

script examples from this this website(linuxconfig.org) worked before.
I'm not running it on the home directory because it's too big. help?

Looks like fun user :))

Hi, person who read my notepad++ file directory

Attached: billgates.jpg (600x600, 103K)

you have to put newlines or semicolons between commands

>notepad++
Use notepad

what are your learning resources bruh?
i want to tackle famiclones in the future.

Find and replace with regular expressions is so nice though.

Go already has OpenCV bindings.

I guess

Yeah, that a pretty good solution. It's a old program I made. Thanks for a greater way to solve it!

using python, i'd life to do the following:
1. download a piece of encrypted payload over http
2. feed it to the decryptor
3. write the plaintext to a file on the local filesystem
which approach would result in the highest throughput? i already know how to do it synchronously on a single thread but that's slow
i was thinking about using asyncio somehow so i can get a speedup at network and disk i/o, not sure about the decryptor
do i just put that on a separate thread and keep feeding it the data i receive from network (until i saturate the decryptor's buffer or something)? do i also write to the local file on the decryptor thread?

For most problems, Python is the fastest solution. It very rarely is the most efficient solution in terms of computations, but it certainly is that in terms of work hours. If you value your time more than your computer's, you use Python. Only in cases where even your computer would struggle with time limitations, do you need to switch to something faster, and most problems are not like that.

retarded website smashes it all onto one line and expects me to know. thanks.

Recently made some shitty chat using javascript, php and sql. (it is a learning project)
It's actually functional and I use it with a friend so we can talk at work without being noticed.
Now I just wonder if I should continue and add more functionalities or if I should start something else.

The chat works like this :
>With the main password can create a room (eventually I could remove it so anyone can create a room)
>you need to know both room name and password to join it
>anyone posting there is anonymous but namefagging can be a thing.

Features I'd like to add are :
>client side crypto using the room password so whoever maintain the database can't read discussions
>modify your messages (only from the current session)
>allow sending pictures and videos (+ encrypting them so only people with password can see them).

But after reading and trying to learn about security and cryptography I found out It would be better start an actual software rather than using webshit to do it cause it wouldn't be secure at all.

use rsa to encrypt an aes key
encrypt chat using aes key

it's perfectly implementable in javascript, honestly

where's the pastebin with learning resources for small i386 brains like me

Why is the sign in signed integers conventionally encoded by the MSB and not the LSB?

Because otherwise you'd need different circuitry for implementing signed and unsigned math.

2's complement signed integers are basically the simplest and cheapest way to implement this shit in hardware.
Adds and subtracts are the same for unsigned and 2s complement integers. You'd need extra hardware to do what you suggest.

Making a webbased game with tanks shooting at each other.
Using websockets for Muh performance. Going pretty well

Attached: IMG_20190219_162355.jpg (1280x907, 329K)

>implementing your own crypto
shiggy diggy

what are you using on backend?

I got memed into reading SICP. Got up to 1.3 since yesterday. When are the exercises going to start being challenging? It's not like I didn't know how Miller's test works before. Is it just a meme freshman book?

Nodejs

>try to find a good, minimalist youtube client that uses mpv+youtube-dl and has a subscriptions system
>all of them are garbage
>write my own in python under 100 lines

Attached: ok.gif (500x500, 800K)

>>write my own in python under 100 lines
Post it. Sounds pretty concise.

i have almost no experience in python and wrote this as a quick solution, so probably many things can be improved, but works for me
pastebin.com/v4UraADU

>what are you working on?
Frontend for my backend. It's web shit so it doesn't belong.
But I miss /dpt/. You're my safe haven.

I'm writing a small temple run clone. Should I use Vulkan or SDL or something else?

>literally 99 lines
cheeky

op here, I could read somewhere about crypto library in javascript. I'll never implement my own stuff (or else it would be only for learning purpose but I'd never use that)
Problem with those is they are not always maintained and it's difficult to know how secure it is. Best solution is to go with an actual language after my searches

It seems alright. I usually use "with open(..) as f" for RAII. You should also use "w+" for the file writing or creating instead of catching the exception of file not existing. There's also this python library "requests", which I've found often behaves better than urlllb.

I need to write a script which will launch a video in full-screen mode every 2 hours and then close the video and proceed as normal. Questions:
1) What do I need to know to do that if the video-player is Windows Media Player (standard, Win7)? Should I read about it's API or public functions/classes somewhere?
2) What should I write it on? C#, any other language? Shall it be a permanently run console app?

You can probably do it in a few lines with powershell. All you need is a loop with a timer. It opens mediaplayer and sends it a fullscreen signal and later kill signal. You don't need any APIs for this at all, just a tiny script with any language.

Can anyone help me figure this nonsense out? I'm trying to parse a text file line by line and store each line in a variable in C but I keep running into issues. I'm use fgets to read the file and sscanf to do shit line by line.

while(fgets(BUFFER, sizeof(BUFFER), file) != NULL){
sscanf(BUFFER, "%s", firstLine);

//I've tried sccanf(BUFFER, "%s[^\n]", firstLine), but it just adds every first char/string before spacing
}


I just have no clue how to read a line, add it to a variable, and then do the next line until we're at the end of the file. Google is giving me nothing.

Attached: ineverhadachoice.jpg (667x659, 77K)

#include
#include
#include
#undef RAND_MAX
#define RAND_MAX 10
struct point_archetype
{
unsigned int X_point;
unsigned int Y_point;
}point;
point.X_point = 0;
point.Y_point = 0;
struct line_archetype
{
struct point A;
struct point B;
};
typedef struct point_archetype POINT;
typedef struct line_archetype LINE;
struct figure_trilateral
{
LINE AB;
LINE CD;
LINE EF;
};
POINT define_point(unsigned int,unsigned int);
POINT define_point(unsigned int x,unsigned int y)
{
POINT location;
location.X_point = x;
location.Y_point = y;
return location;
}
LINE define_line(POINT,POINT);
LINE define_line(POINT A,POINT B);
{
LINE AB;
AB.A = A;
AB.B = B;
return AB;
}
unsigned int compute_distance(POINT,POINT);
unsigned int compute_distance(POINT w,POINT x)
{
unsigned int x_of_w = w.X_point;
unsigned int y_of_w = w.Y_point;
unsigned int x_of_x = x.X_point;
unsigned int y_of_x = x.Y_point;
unsigned int a = x_of_x - x_of_w;
unsigned int b = y_of_x - y_of_x;
unsigned int c = (a * a) + (b * b);
return c;
}
int main()
{
unsigned int points;
unsigned int generic;
const unsigned int pointss;
unsigned int points_list_index;
unsigned int bound_X = 10;
unsigned int bound_Y = 10;
unsigned int X_position = 0;
unsigned int Y_position = 0;
printf("Enter number of points to create:");
scanf("%u",&points);
pointss = points;
putchar('\n');
POINT* space = (POINT*)malloc(sizeof(point)*bound_X*bound_Y/*(*bound_Z)*/);
POINT* points_list = (POINT*)calloc(sizeof(point)*10,sizeof(point));
memset(space,0,sizeof(point)*bound_X*bound_Y);
while (points-- > 0)
{
X_position = rand();
Y_position = rand();
*(space+X_position+(Y_position*bound_Y)) = define_point(X_position,Y_position);
}

free(space);
}

Come on, it's not that hard. Google "c read a file" and open the first stack overflow link.

Went full autism and did fp16 and int8 inference on object detection. sub millisecond inference time lmao

Attached: h27.webm (1920x1080, 2.95M)

>fgets(BUFFER, sizeof(BUFFER), file)
you're sizeof()'ing a char pointer and putting it into an int
set it as an upper bound or -1

I want to learn Forth, is it worth it?

Thank you, user, I will start learning how to work with Powershell rn.

I can kill those bots faster without a cheat????????
dogshit