/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1492863866127.png (1280x720, 611K)

Other urls found in this thread:

voice.mozilla.org/en/datasets,
twitter.com/NSFWRedditImage

Reminder that the only difference between struct and class is that class is private by default and struct is public
Besides that they are completely identical

So if you hate looking like an OOP peasant, and want to be respected like a C wizard, write structs everywhere instead of classes

It's 100% guaranteed to work

Attached: 1533623613309.gif (400x225, 1.71M)

JavaScript rocks!

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

repost
Coding the board game, Forbidden Island, for when bored at work.
t5. aD. flood trs -- X G: h K
... ... =========== ========= ==== N: h O
... ..D 1 O1 1 K1 3 w -- 5 D: O O
1 O2 1 K2 1 h --
H2. K1~ aM. aX~ 1 T1 1 aX 2 s ====
... ~~~ ... ~~~ 1 T2 1 t2 2 O -- 4
... ~~~ ..M ~~X 1 H1 1 t6 5 T --
1 H2 1 t7 4 K ====
T1. H1. aP. ta. t4. K2~ 1 aP 5 H -- 3
... ... ... ... ... ~~~ 1 aG --
... ... ..P ... ... ~~~ 1 aD --
1 aM ====
t8. t3. T2. t9. O1. t2~ 1 aN -- 2
... ... ... ... ... ~~~ 1 t1 =>
... ... ... ... ... ~~~ 1 t3
1 t4
aN. aG. t7~ t6~ 1 t5
... ... ~~~ ~~~ 1 t8
..N ..G ~~~ ~~~ 1 t9
1 ta
O2. t1.
... ...
... ...

semantically speaking struct implies data class implies functionality
programming is as much about readability as it is syntaxical correctness

Sauce on this THOT

A struct also packs the bit patterns of its members into a contiguous block. A class is not always guaranteed to do this.

First for C++

Attached: who-would-win-reply-to-this-post-or-your-mother-18696701.png (500x300, 81K)

Attached: 1553020439493.jpg (884x574, 78K)

C++ is shit

all I found were blogposts and an odd unreviewed kindle only book
Is The C Programming Language still the go to too learn that?

Pic is free on Amazon on Kindle for some reason

Attached: 5166RlcIX+L.jpg (364x500, 34K)

All books are free tho

Working on the /dpt/ thread collection project:

After trying for like 3 hours, I finally found a way to connect mongodb to elasticsearch. It just werk! Thank you based golang users for your cool network utility. On a side note: this JSON has way too many redundant fields. This is the near raw JSON response that Fool Fukka gives. I need to strip the fields and make it more compact. I'm thinking of replacing my "threads" collection with a "posts" collection seeing as people prefer to search by post and not by thread.

Attached: elasticsearch.png (1917x925, 66K)

I usually like physical books and saw it was free on Kindle while browsing
Pic is also on sale, but I'm not sure which is better

Attached: 41n9peH5i5L._SX331_BO1,204,203,200_.jpg (333x499, 28K)

Does that mean you like me?

tfw there was blood on my toilet paper and my butt hurts

hemorrhoids
>drink more more water
>eat fibers
>clean your ass
>stop eating sugars and carbs

Yo Jow Forums. I am writing a toy compiler. What do you think of the syntax?

require std::io;
require std::parse;
require std::sys;

let format_operation(num1: i32, num2: i32, calc: str) -> str:
letm result

match calc:
"+": result = std::format("$num1 + $num2 = $(num1 + num2)")
"-": result = std::format("$num1 + $num2 = $(num1 - num2)")
"*": result = std::format("$num1 + $num2 = $(num1 * num2)")
"/": ~
let num1f = f32: num1
let num2f = f32: num2
result = std::format("$num1 + $num2 = $(num1f / num2f)")
~
else: sys::exit("Invalid operation: $calc")
~match
~format_operation: result

let main(argv: str[]) -> i32:
printf("#---------[Calculator]---------#")
while true:
let in = io::input("Enter two numbers: ")
let _num1 = in.split(" ")[0]
let _num2 = in.split(" ")[1]

let num1, num2

if not (let num1 = parse::stoi(_num1)): sys::exit("Not a valid number: $_num1")
if not (let num2 = parse::stoi(_num2)): sys::exit("Not a valid number: $_num2")

let calc = io::input("Enter an operation: ")

let result = format_operation(num1, num2, calc)

printf("$result")
let option = io::input("Do you want to exit? [Y/N])
if option.lower() is "y": ~
printf("#---------[Exiting]---------#")
return 0
~ else if option.lower() is "n":
continue
else: sys::exit("Invalid result: $option")
~while
~main: 0

> spent half an hour profiling code to figure out why it was so slow
> realize I left the -fno-inline compiler flag on

>hemorrhoids
Thank you
>>clean your ass
>>stop eating sugars and carbs
I'd rather let my ass bleed

based masochist

Assembly RISC

(R1)+ is saying to increment the register R1, right? But, by how much? If R1 is a decimal value, do I just increase it by 1? Say R1 has 40 loaded into it, would the effective address be 41?
Similarly, for decrements how many would you decrease it by?
I've tried looking it up in my textbook but the section that says it goes over it doesn't seem to exist.

Attached: caveman-with-computer-stock-photo__x75790892.jpg (450x319, 28K)

Hi, brainlet here

Looking to develop an algorithm in python that finds all non-unique combinations of elements in a list of data. (for example, if I have 'AB', I don't care about 'BA'. If I have 'AEF', I don't care about 'FEA'). I'm looking for a way to do this recursively, but I keep getting a RecursionError. Any help appreciated.

POST CODE

Reminder that silverlight is dead and you need to stop using it.

What are the data?
Can multiple instances of the data appear in a single "string"?
Is it actually a string? Why aren't these just sets?

>let
Stop using this cancer. It's a crutch for a shitty parser.

>::
>std::kitchensink
You're not C++, stop trying to look the part.

>func(...) -> y
Don't know what the obsession with -> is, far too many nu-langs trying to look Functional I guess.

>~this
>~that
wtf

>ident: type
>type: ident
Make up your fucking mind.

>if option.lower() is "y":
What's wrong with ==, or just =? More operators is more confusion (get it?).

>printf
>no actual formatting
Stop repeating C mistakes. You shouldn't do printf("No formats\n"); in C either.

this is my pathetic attempt so far

import string

data = list(string.ascii_uppercase)

permuted = []

def permutation_algorithm(data):

r = 1
n = len(data) - r

for i in range(n):
permuted.append(data[i]+data[i+r])
r += 1
if (i+r) > n:
break

permutation_algorithm(permuted)


permutation_algorithm(data)

print(permuted)

>using windows
Is this OS not meant for C and C++ development? Why is setting up GCC and bash so cumbersome here? I'm unironically tempted to use other languages rn. Not even joking. I can get Rust no problem. It's setting up CMake, bash and GCC that's troubling me.

I just tried WSL, is this a fucking joke? Apparently microshaft does not recommend using distro data folders which means that I can't even start a project in ~
What the fuck is the point of it then? I just wanted to do some C++ on GCC+CMake and looks like windows is not meant for it.

On top of it windows might have bricked my wireless adapter.

Attached: 1538759723990.png (832x868, 371K)

>>clean your ass
>americans
>being capable of anything but spreading shit all over their perineum

Just use visual studio.

what do c# developers do

I have no idea what you're trying to do there

try this to see if it does what you wnat
def uniqueStrPerms(strs):
uniques = set()
for str in strs:
strset = set()
for char in str:
strset.add(char)
uniques.add(frozenset(strset))
return uniques

>using MSVC
>just bend over and let telemetry module be injected into the binaries through your anus

Beg for jobs

Attached: 1534935983694.jpg (1291x3600, 610K)

>Is this OS not meant for C and C++ development?

Attached: tenor.gif (220x150, 365K)

>Manjaro
>#pacman -Syu qtcreator cmake clang++ git
>done, good to go

>microshaft 10
>download install qt creator
>download install msys
># pacman -Su
># pacman -Ss gcc, look for the msvc one
>install
>download install cmake
>download install gitbash
>still doesn't work, try WSL
>youre not even supposed to modify distro folder

Now I have to install a Virtual Machine and install Manjaro on it.

Attached: 1539532169343.jpg (372x278, 9K)

Currently working on not ripping my hair out while doing this assembly assignment.

Negative.

I'm looking to recursively find the set of all combinations (non-unique) of elements E in list D when the length of E is less than factorial of D.

ex:

'AB' is valid if 'BA' not already in set E
'ABDF' is valid if no other permutation of 'ABDF' in set E
'AAA' is NOT valid because A repeats
'A' is not valid because it's a single value
The entire alphabet is a valid element because all characters are unique
The entire alphabet except for 'F' is a valid element because all characters are STILL unique
'QRZ' is valid if no other permutation of it exists
'ABCDEFGG' is NOT valid because of double G

I think you get the point.

wasted dubs

use clang-cl
it's a drop-in replacement for msvc

they stopped doing that, but they still inject metadata that can be used to identify who created binaries into executables and have done for years even before they fell for the telemetry meme

so, a power set?

What's a good text to learn Python for a total brainlet? I want to go to school and it's on the curriculum. Also has a fair bit of Cisco CCNA and also Network+

Attached: 1400966915131.jpg (357x251, 33K)

fuck you

windows is meant for office monkeys and vidya gamers

Attached: fish.jpg (448x506, 22K)

checked

yes, basically a power set that works with strings

the data are actually .wav files to be merged together

no multiple instances can occur in a set. Yes they are manually determined sets.

What's the difference between
class A {
// ...
std::vector references;
};

class B {
// ...
std::vector references;
};


and

class A {
// ...
std::vector references;
};

class B {
// ...
std::vector references;
};

Attached: mrm0nl8cctl11.png (2025x1125, 297K)

When the destructor of A is called, all the B pointers in the vector will have their destructors called as well (and vice versa).

>Arch
>pacman -Syu base-devel
>100% ready for C programming

I installed that group once while bootstrapping the system, it came ready for programming

Wait a second, msys2 didn't work? It's usually all you need and it gives you a linux style terminal with pacman, bash, git, everything.

But does it matter whether we choose naked or smart pointers here? I presume I'd be adding some entities into the both groups.

>But does it matter whether we choose naked or smart pointers here?
The unsmart pointers will not call destructors. Depending on how you use them, it is a leak.

>naked pointers

l-lewd

Attached: 1552869445613.jpg (842x699, 61K)

>tfw even pointers are brainlets

cfags btfo

Wibdows is no different than any other os.
>download gcc, clang or msvc
>download cmake
>write a .cpp file and CMakeLists.txt
>run cmake
If you can't even manage those basic steps, programming is probably not for you.

Think about how the lifetimes of your objects. Is A responsible for cleaning up the Bs?

>cmd.exe
>libraries

Attached: 1552912585793.jpg (525x600, 59K)

in haskell this is just
powerset = filterM (const [True, False])

>not using powershell
it takes a little bit of effort to get a windows dev environemnt setup in it but it's comfy
i might actually write a build system for it at some point

what language should I study to automate actions? for example, if I get an email containing a specific string, I want to move something on hard drive a to hard drive b... what am I writing this in?

If you want help, you need to tell us which assembler and which architecture you're using.
And if it's a real architecture and not just some shit your textbook's author made up, why not just write a program that uses that instruction and watch what it does?

Attached: Screenshot_20180617-193216.jpg (1080x2160, 596K)

ruby
def power_set(ary)
a = ary.uniq
return a.each_index.flat_map { |i| a.combination(i).to_a }
end

I'm making a crappy javafx program for uni. I have no clue how I should structure stuff, but I think I've got something that werks.

>cmd.exe 2.0

Attached: 1552866469572.jpg (200x313, 10K)

user, I would if I could.
We're not using any specific assembler. I know next to nothing about it.
The only information that was given to me is that it's RISC. I'm not even sure if its pseudo code or some actual thing.
Its just a set of problems asking what each thing will do. Like, "R2 = 5 R3 = 4 What is (R3,R2)?" But the only ones I'm not sure about are the increment/decrement ones. I cannot find any similar examples in the textbook or class notes. Nor can I find any references to incrementing/decrimenting anywhere.

Every single person I've talked to in this class has no idea whats going on. And the campus CS tutors have no idea, either.

How do I Python with curly braces and no whitespace as a syntax asshattery?

Attached: 1539566666919.jpg (1232x1226, 374K)

from __future__ import braces

1488

It probably means dereference the address stored in R1 and increment what you find.

I'm getting a segmentation fault (core dumped) in this line:

cout

Increment = add 1.

in c# structs are inlined value types whereas classes are reference types

>Sepples
That's obviously the problem.

GODDAMNIT SCALA JUST INFER THE TYPE

That's what I thought it would be, but I wasn't sure.
Thanks

Should I really put my exhentai account in my C.V., what if the HR can't get past the sadpanda?

What? This could be C, the problem is the function. How is omp_get_max_threads() giving me segfault. GDB claims it's in this line, specifically in malloc?

... did you add -fopenmp?

Yep. I'm using ICPC, and I've included omp.h too.

If they can't get past the sadpanda that's a huge red flag. You probably don't want to work there anyways.

Yes GCC does not work

How many hours of speech would you need to train a speech-to-text model? Assuming the timestamps are accurate down to the word level.
Mozilla has this, voice.mozilla.org/en/datasets, but it's only 800 hours.

My idea is that you would scrape youtube and use it for training, of course.

can someone help a brainlet (me) with simple steps to find, download, locate/ place, link and use C libraries that aren't in the standard lib? Every answer I get for this is different. I'm on Ubuntu

sudo apt-get install -dev
then put in gcc
gcc -l
and #include header

what libraries do you want? you should be able to get most of them with apt

ur supposed to use the visual studio debugger

> then put in gcc

you mean in /usr/local/lib ? I try every location I could think of that might be relevant and I still get a file not found error. When you say "put in gcc" what EXACTLY is this process?

libcurl

>libcurl libsndfile

sure, but what does "put in gcc" supposed to mean

not sure tbqhwy, maybe he means "use it in gcc commands as follows: gcc -l"

No
If you have libpthread, then you do -lpthread for instance

I also have a hacky version, where you put all the headers in a folder, then all the .so files in one. Then you have two files:
build.sh
gcc 'main.c' -I deps/l1/include -I deps/l2/include -lssl -lcrypto -lpthread -Llibs -l:libone.so -l: libtwo.so

run.sh
LD_LIBRARY_PATH=libs ./a.out


This is ugly as sin, but it's neat for debug builds. For release I do static builds with a different compiler anyway.

I wrote a DNS lookup server and it works pretty reliably. Then I hooked it up to LibC's gethostbyname() and now I can actually browse the web with Lynx without hard-coded IP-addresses :)

While working on this, I kept tripping over bugs and other shortcomings in local sockets so now I'm working on debugging those. I spent the last hour debugging a dumb race between accept() and connect(), and now I'm moving on to some memory leaks.

Attached: Screenshot at 2019-03-20 02-25-05.png (1920x1080, 702K)

>not having your makefile setup a local build/include directory
>not simulating a library/dependency install there

I just removed python 3.6 because I have 3.7 and now a bunch of shit with gnome isn't working. That's fucking gay. Should I just sudo apt install gnome again and will it just go back to normal?

Attached: immunity-doggo.jpg (500x860, 188K)

Enter word or sentence (EXIT to break): water

Word: water Position in vocabulary: 288

Word Cosine distance
------------------------------------------------------------------------
seawater 0.674472
groundwater 0.644973
moisture 0.609002
evaporation 0.596427
aquifers 0.594831
nutrients 0.585671
saline 0.582689
evaporate 0.582394
nutrient 0.581684
sediment 0.567470
watery 0.563323
reservoir 0.563149
perlite 0.560144
brine 0.553516
brackish 0.553449
evaporated 0.553244
pcbs 0.551544
evaporates 0.550201
surface 0.549226
topsoil 0.547090
catchments 0.545224
vapour 0.542492
landfills 0.542468
droplets 0.542182
dry 0.542100
rainwater 0.540921
silt 0.534183
heat 0.530720

That's pretty fucking cool yo

Will learning c help me become a better programmer?