/dpt/ - Daily Programming Thread

What are you working on?
Previous:

Attached: d8b.jpg (640x480, 39K)

Other urls found in this thread:

godbolt.org/g/Q5bkPR
pastebin.com/7AjUPVCq
twitter.com/SFWRedditGifs

>What are you working on?
I'm trying to think of how to handle input and output on a single interface, with multiple types, without using switches everywhere.

I feel like what I'm writing is too verbose, and might be the wrong approach.
I'm wondering if adding methods on structs is the way to go here, instead of just having a type switch with cases, but I'm not sure if this is just a subjective thing or if either is technically bad.

Attached: 1385077398214.jpg (261x287, 58K)

You can't spell "trust" without Rust.

What is the best way to learn Java? I already know C.

Reminder.

Attached: privacy.png (1361x687, 122K)

Roko's basilisk. I'm okay AI rule, it really is better for everyone. We should all push for it.

programming a step motor(looking for good frequencies, by having it up my ass) to make a vibrator that I can operate with my phone

I guess I'm trying to design a multiplexer. I think that fits the description of my goal.

literally a great idea

>Live off the government
>Expect to have privacy of what you do with the resources the government gave you
lmfao

>if you're poor you don't deserve basic human rights
Get a load of this guy.

>Tech Workers Coalition
Stupid fucks prefer to go after conspiracy theories instead of things like shorter work days or more vacation days. Never change, americans.

The poor don't deserve it.
t. poorfag

Always thought computer vision was a joke, glad it's used for something useful at last.

meh, I heard it's having some success for medial imaging, especially in image segmentation in CT/MRI but also RoI selection.

Coding an interface with Wonderware and trying to have my popups get their button tags linked by the "mother" button so that I can just use a template without having to create a hundred different ones.

please don't judge for this cringe code, new to java serialization. How can I fix this up? How can I somehow improve this repetitive code for better code? The layout for the try and catch was just me trying to get serialization working and keeping it confined so will clean that up aswell.

Attached: Screenshot_20180810_002155.png (744x809, 173K)

Make an array of file names their respective objects.
Loop through that and do the Stream open & write for each pair.

Appreciate it, thanks user

Extract out the try-catch block into its own method, and call that method with the specifics?

>casting to a generic type
bad juju

>poorfag
You misspelled "paid shill".

Playing around with tail-end recursive C. This works but doesn't check if player is honest.

Objective is write short stateless recursive code.

How should I improve this?
#include

int guess(int min, int max, int score) {
char input;
char c;
int myguess = (max-min)/2+min;
printf("My guess is %d.\n", myguess);
printf("Hint (H/L/W):");
scanf("%c", &input);
while ((c = getchar()) != '\n' && c != EOF) {}
if (input != 'W' && input != 'w') {
printf("Turn %d\n",score);
if (input == 'H' || input == 'h') { return guess(myguess,max,++score); }
if (input == 'L' || input == 'l') { return guess(min,myguess,++score); }
} else {
return score;
}
return score;
}

int main()
{
int min = 0;
int max = 100;
printf("Hello I will try to guess your number by you providing hints.\n");
printf("L = your number is LOWER than my guess.\n");
printf("H = your number is HIGHER than my guess.\n");
printf("W or any other key = I found your number.\n\n");
printf("Think of a number between %d and %d.\n",min,max);
printf("Press enter when ready...");
getchar();
int score = guess(min,max,1);
if (score == 1) {
printf("\nFound it in my first try! Thanks for playing.\n");
} else {
printf("\nFound it in %d tries! Thanks for playing.\n",score);
}
return 0;
}

>tail-end recursive C
Do the C compiler even have TCO?

Apparently they don't godbolt.org/g/Q5bkPR

gcc -O2 can but where's the fun in using the compiler's TCO.

this

>What are you working on?
A clone of Cookie Clicker in good ol JavaScript

Anyone here program using Intermediate Language directly? I'm wondering if there is any benefit in learning it.

totally owned some nub on le reddit

you tried disassembling a bought vibrator?

you cant spell dick without c

you do, but you don't deserve gibmedats however

How are the people building the underlying technologies going to do anything about this?

What do you call a Rust program that links with C libraries?

Attached: a0118017329_2[1].jpg (350x350, 29K)

A Rust program.

So I aced my F500 interview. I solved their bullshit hackerrank questions within minutes.
But I didn't get the job. Their reasoning? "They've decided to move forward with the process, we have come to the conclusion that you would not be a proper fit here."

Honestly, I think it's because of two reasons: I give off an asocial vibe and I have very bad acne.

It doens't help that one of my fucking pimples decided to burst on my way there. I noticed that I had a bit of dried blood trickling down my forehead when I got home.

Fuck my life, man.

Attached: 1529972311019.jpg (702x562, 67K)

That's cs grad worthy

Ended up with pic related after first user's advice and works fine, might do what you say for try catch and call in the for loop further down the line.

Didn't know I could leave out the LinkedList casting for the input streams.

Attached: Screenshot_20180810_010317.png (824x591, 77K)

Useful.

How to use "IO.popen" when you want to use flags?

I'm having a bit of trouble learning Ruby, if you couldn't tell.
d.each { |file|
next unless is_png?(file)
application_name = "Preview.app"

input_array = ["open", FLAGS , file]

puts "CURRENT FILE: ", file
puts "PASSED IN: ", input_array.join(" ")

# error: Invalid option "--"
opened_process = IO.popen(input_array)

Attached: Screen Shot 2018-08-09 at 8.10.04 AM.png (1812x220, 47K)

Also, double dashes don't work either

Attached: Screen Shot 2018-08-09 at 8.19.01 AM.png (1232x270, 56K)

jesus ruby is ugly

It's very diverse with it's use of {} [] () | and other syntactic gems.

>tfw self taught but take in information like a fucking whale eating tiny fishies from the moment you wake up until you sleep

who needs university when you have the internet

Attached: 1533824823376.png (744x809, 226K)

>gibmedats
That name implies the economy is a zero-sum game, which it isn't.
>you don't deserve
Get corporations to pay us living wages then, jackass.

Attached: DiS5qXWX0AEywDo.jpg (729x1200, 108K)

whales don't eat fish

Theft doesn't help the economy. And amazon paid no federal taxes because they didn't make any taxable income.

depending on the species, they do.

Why do mainstream languages have such limited capacity for abstraction

It's what mainstream programmers are capable of

Listen guys. I send a lot CVs last days, and some guy called to me, he wanted me to use my programming skill to sell credit loans (?). I refused, i thought he may want someone to make website in PHP with ads of his scam or something? But maybe i did wrong refusing? I never had job programming yet. Shame i did not ask about used technology, i am such a sperg

quick question, what is the replacement of $ in jquery. Because $ conflicts with some stuff in tampermonkey i think. For instance $("#id").text("blabla") doesnt work because $ is not being recognized but jquery should be loaded properly.

I can't find it but i remember it replacing something like "jquery" or something but that was years ago in class.

fuck wrong general srry

>Theft doesn't help the economy
Why do you keep defending Amazon stealing from its workers?
>amazon paid no federal taxes because they didn't make any taxable income
So you oppose welfare for the poor, but support corporate welfare? Sounds sensible.

What's the best way to return the first file from each directory recursively in python?

Include a privilege detection algorithm, obviously

take a look at os.walk()

I don't support corporate welfare because I don't support welfare, but by current democratic doctrine we live under, it's perfectly sensible. No, amazon shouldn't exist in it's current form, but that doesn't make the whole practice of employment "theft", you commie fuck.

I had gotten far enough to return all the files with os.walk, but I figured out I could just check for a specific part of the file name before adding it to the array.

I'm working on some scripts to help organize my music collection and this part needs a list of each song from each folder so I'm just checking for "01." in the filename before adding it.

>I don't support corporate welfare
So you believe Amazon should pay federal income tax? Good.
>that doesn't make the whole practice of employment "theft"
You're correct, what makes it theft is not that, but the exploitation of surplus value. And even if it weren't theft, you still haven't explained how paying workers famine wages benefits the economy, you only seem to see a problem with social welfare, which is not sensible by any "democratic doctrine we live under", it just means you think it's okay to watch those people starve and be denied basic human rights.
>you commie
You say "commie" as if it were a bad thing.

What's up with the ISC license? Is it the modern MIT license?

Being a communist in itself isn't bad. Acting on those communist urges is bad.

other way around but this is a bit off topic

>So you believe Amazon should pay federal income tax?
I believe nobody should pay any tax.
>surplus value
Doesn't exist, value is completely subjective. Neither do "basic human rights" to a living wage. Obviously I'm not against paying workers high wages, but I'm against government price floors on the price of labour.
>You say "commie" as if it were a bad thing.
It's fairly bad, because if I keep responding to your shitty bait, the janitor will come and delete half the thread.

Attached: 1465509253964.png (1280x720, 335K)

>shitty bait
Can you honestly call that bait?

what the hell are you doing man?
show your entire class.
you should just make an array of streams with a fixed length instead of putting those oisXXX shit in them, same for the linkedlist.

I'm legitimately on the brink of breaking out into tears trying to set up fucking wt
why can't it be just simply some nuget package for visual studio on windows, then target loonix straight out of visual studio, and can deploy in one click to a server
WHY

Attached: 487237423784.png (497x480, 218K)

>value is completely subjective
Suuuure... but only when it's convenient for you and corporations, right? Yeah nah, fuck off!

Attached: value.jpg (750x1064, 90K)

>I believe nobody should pay any tax.
You mean like in North Korea?

Attached: NK.jpg (720x474, 36K)

>I believe nobody should pay any tax.
I agree with you, but "Amazon" is not "somebody". Corporations aren't people, and should be taxed heavily and progressively.

Attached: Eisenhower.jpg (500x623, 42K)

>>value is completely subjective
>Suuuure...
How is it not? If I baked some cookies and decided to sell them and charge a dollar per cookie. Dependending on the person, they may or may not buy the cookie. It's all how they perceive the item.

daily """"programming'''''''' thread

HAHAHAHHAHAHAHAHAHAHHA

>special snowflakes thinking that their opinion on politics matter
How cute.
Anyway, is it safe to ignore disk I/O errors? I have no idea how to catch the error from 'sinkFile'
eres

>hasklel

lmao

I don't even know.
Here is the class where those streams are: pastebin.com/7AjUPVCq
I'm still learning so at this point I'm just happy it's working perfectly fine.

>How is it not?
Because computers can objectively calculate it, hence it is not subjective. How can you be into programming and not know this?

Attached: science.jpg (557x275, 27K)

Finaly decides to bite the bullet and install the rust compiler. Give me a project that I can do in rust that will show me why I should continue with rust over other languages.

i don't know conduit but there's probably a way

Attached: 1522955011471.png (579x761, 719K)

Attached: 1_vzwAxAI6RB89kPZZJIGkOA.png (1400x800, 58K)

a compiler

Traceback (most recent call last):
File "/usr/share/nemo-python/extensions/nemo-media-columns.py", line 26, in
import urllib.parse
ImportError: No module named parse


But when I open up a Python interpreter and type:

import urllib.parse

everything works as expected. Does anyone have an idea why this is happening? Why can't the script import that module, but the same Python interpreter can do it.

>Pinecone

what's literally the point

because you are not running the python script with the same env as the python interpreter

what an awful language

Attached: 1502982809338.png (265x209, 59K)

Rust boasts about fearless concurrency...
A high-performance server (IRC, HTTP) perhaps?

Maybe it's defaulting to python2

Pretty much anything works, unless you're trying to do something that might not be well supported because of a slightly undeveloped ecosystem. I'm mostly talking about complicated GUI apps. CLI stuff is pretty nice to write and well supported with a lot of libraries, and there's the shell of a web server project in the official rust book (which is probably worth a look at).

How could I further troubleshoot that?

The shebang in the script points to Python 3.

You're right. I did print(sys.version) and it's indeed showing Python 2.7.15. Man, this sucks, time to look for help on related channels.

It's similar to haskell in spirit. Functional, terse, and beautiful syntax.

Try looking into HashMaps to save streams and lists, and make sure you initiliase the streams only once, you can do this in your constructor.

Use one try and catch different exceptions.

Yeah, I'm sure there's a way. It's just that conduits are pretty complicated.

So when people criticise Haskell for having too many "hieroglyphics", your solution was to make even basic language features and statements involve them?

C question.
Should I initialize
int* x;
using
x = malloc(sizeof(int));
before assigning it a number entered n the console?

>Rust boasts about fearless concurrency...
so does every language ever, nobody gives a shit

I'm just parroting what's on the homepage.

>trying to learn how to properly use IDEs and workspaces and shit instead of ghetto-rigging everything with text editors and tard-proof compilers
>try this VSCode Jow Forums keeps talking about
>okay gonna look the debugging instructions and try on Palemoon and see if I can use that symbols malarkey
>"install C/C++ extension"
>simple enough
>"Note: it doesn't include a compiler nor a debugger"
>th-thanks.webp
>go through instructions on downloading and configuring mingw or whatever
>try to figure ou why the fuck the installer seems to install everything but the compiler and debugger
>fuck it, time to take the coward's route and Google for an easy solution
>"C/C++ extension includes debugging"

Oh Microsoft, you card.

Attached: 136593557547.jpg (300x345, 49K)