/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

')
')
'
youtube.com/watch?v=3bCT3YxZfAY
jackxmorris.com/posts/traveling-salesman-art
github.com/duneroadrunner/SaferCPlusPlus
twitter.com/SFWRedditImages

Just comfy Sunday working. Hasklel.

Spent 2-3 hours trying to find a bug yesterday, found it in 15 minutes with fresh eyes today…

My import list is ever-increasing…

I've started learning Go again for shits and giggles--no future project in mind for the knowledge. Maybe a toy web server?

I was learning scala, expecting to replace python, but stumbled in it's crappy tensor libraries.
Now I'm thinking of picking clojure just to have a language to use in the jvm, while not expecting to do numerical simulations with it.

Rate my python code for fetching text from websites, /dpt/

from bs4 import BeautifulSoup
import urllib2

data = open('Input', 'w')

def fetcher():
text = []
for request in range(0, 3):
request = raw_input('What is the URL you wish to use?\n')
if request.startswith('') == True or request.startswith('') == True:
continue
else:
request = '' + request
for site in range(0,3):
site = urllib2.urlopen(request)
article = BeautifulSoup(site, 'html.parser')
for x in article.find_all('p'):
text.append(x.get_text())
fetched = (u''.join(text).encode('utf-8').strip())
return fetched

data.write(fetcher())
data.close()

>python
That is where your mistake.

show how you do it with you favorite language then faggot
>but muh lambda calculus
useless also in maths

bikeshedders, everybody!

>dpt
>knowing how to program
I bet you even ask about technology on Sup Forums, lol.

>if … == True
stopped reading there desu

Programming makes me want to kill myself

thanks, figured it out

I'm that guy from last night making rare pepes with traveling salesman art and stippling.

This is the final outcome after changing a few pieces of code so it'll be quicker.

The input image

The stippled images

The corners where it crosses over its own path trigger me

Did you just assume its lack of gender?

mind you tell what is clojure good for?

>urllib2
>not requests

An OCR document processing application, both web frontend and the backend because it turns out our client's "programming company" doesn't know how to program for shit.

Web developer comes to the rescue of incompetent C# "developers". Again.

>webdev

>python

This is a programming general, not a "coding" general.

I'm also doing systems programming on the backend, since systems "programmers" don't seem to be able to do the job properly. Fucking embarrassing, isn't it?

Keep crying, faggot.

How would I check for an if statement between Python and SQL, basically if Table has Object then X happens in Python. I feel like this should be very obvious

res = db.query(Object.id).filter(Object.prop == prop).first()
if res:
print('yes')

This reply is so much more entertaining than I'd hoped for.

Coding an algorithm to efficiently compute the least number so its factorial ends with a given number of zeros.

Why the fuck is there still no standard or at least GNU extension way to simply fucking embed arbitrary files into a C or C++ program?
I don't mean externally by the linker, but by the language itself.

Use nodejs, it's way comfier for web scraping.

Convert the file to a char array and include that?

No, that's a stupid fucking way.

Ok.

'let' was an unnecessary addition to JavaScript, function scoping is all you need.

'let' just feels weird.

>let it, be;

Here's the effect with no region division. Not sure how I want to implement that.

Why is my audio coming out way too high pitched (64 hz is a loud noise, 64hz samples online are too low for my speakers/ears. 2kHz is a shrill, brain melting tone, 2kHz samples online are a highish beep)?

fn callback(&mut self, out: &mut [f32]) {
let mut data = self.data.lock().unwrap();

let phase_inc = data.frequency / self.sample_frequency as f32;

for x in out.iter_mut() {
*x = match data.phase {
0.0...0.5 => data.volume,
_ => -data.volume
};
data.phase = (data.phase + phase_inc) % 1.0;
}
}

No, 2KHz is indeed shril, brain melting tone.

>youtube.com/watch?v=3bCT3YxZfAY
Yeah, that's really shrill and brain melting.

Oh, I am thinking now.

ok, another question.
My program creates a thread, which loops infinitely. When I end my program with SIGINT, I want to close the thread so that memery addreses it used can be freed, but AFAIK i can't join that thread, because it will never return. Is there any way to do this?

look, sorry to be this guy, but asking completely genuinely- whats the best way to get into programming and coding, and what the most viable languages to learn, or strive to learn? any help or pushed in the right direction to start are greatly appreciated

What the fuck am I doing wrong? I have more than 1 row in my SQL table. I am trying to do some shit inside the loop but it does not work and program ends immediately.

db = sqlite3.connect('database.db')
c = db.cursor()
count=c.execute("SELECT COUNT(*) FROM mytable")
db.commit()
k = c.fetchone()[0]
print(k) #just to make sure that k is bigger than 1 and yes it is
while k

Writing a tiling window manager for Wayland
What do you guys think that most tiling window managers miss?

>I am trying to do some shit inside the loop but it does not work
>just to make sure that k is bigger than 1 and yes it is
>while k

Holy shit I need some sleep please end my life

We all do that man, it's alright, we still love you :p

Install Fedora and start learning Python.

Is there a better way to do error handling and resource cleanup in C than using gotos?

I can't forget about wojak, can I?

Yeah, it's called switching to a better programming language.

input image

working on my decentralized TV system, and I have a networking question.

The TV system relies on TCP connections to work, and I want to see how far I can push consumer hardware (router) before it starts dropping TCP connections.

I want to solve this by simply making a function that opens TCP sockets to itself through the 192.168.XXX.XXX IP address and test to see if connections dropped after a new one is created.

My question is this: will this TCP connection make it to the router's table, or is my OS (Linux) smart enough to realize that the traffic will never leave the computer, and just add this connection to a local connection table?

Stippled image

And if the router does see that connection, is that defined behavior on all platforms?
Upgrade to C++ and use try-catch blocks.

Which C utility library with basic data structures and algorithms to use: tbox, qlibc, apr ...?

How long does it take to generate these?

so, did you wrote any code to do this or just used pre-existent code and run a few generations?

My code is totally unique, I'm just trying to see if I can sort-of replicate the effect. The other guy is using the code that comes with the TSP art generator.

it takes a while, if I'm being honest.

Let me have it run through it once, without creating the travelling salesman solution, and I'll post when it's done

I used jackxmorris.com/posts/traveling-salesman-art

Only changed two files because it was taking too long to actually process.

Hmm, I am becoming stronger.

you wrote it in C#?

>it was taking too long to actually process.
That's the travelling salesman for you. Takes longer to plan the route than actually make the trip.

Yes, and I wrote it by looking at the vague explanation, rather than the real algorithm which is why mine is [spoiler]wrong[/spoiler].

write it in a better language

how did you convert a normal image to an image with dots?

I'm still trying to figure it out, fambly. Give me a bit.

>want to declare variable of my object in main
>non-static variable this cannot be referenced from a static context

who thought of this gay shit
fucking shit gay ass java

What kind of naming conventions do you guys use in C?

I'm in a dilemma.

Oh no, I meant the actual stippling takes too much time. I shortened it by raising the limit when it stops

As much as java is an awful language, that makes perfect sense

yeah and why
what's the solution to this
how do I create my fucking object in my main

dont you just group pixels up?

learn what static means and then don't

read for a brief overview of the algorithm

>I'm also doing systems programming on the backend
t. pajeet

It's a bit more complicated than that.

As long as you don't use camelcase and don't have significant case, you'll be fine.

i don't get it user

you already made it, but when i asked you how you did it, you didn't know?

like, what?

ok I just solved it
that's utter bullshit and I don't see the point at all
why in the fuck am I not allowed to acces non-static shit in my static main
why in the fuck would I need to call some shitty method to initialize or change my variables everytime instead of doing it directly in the main
this sucks balls

>java

>why in the fuck am I not allowed to acces non-static shit in my static main
Because it's fucking static? Learn what that means you dipshit.

>you already made it, but when i asked you how you did it, you didn't know?

Because mine isn't correct yet, so asking me how I did it is a little premature.

>I have literally no concept of how OOP works but let me tell you what the designers of Java did wrong

dumbass

>why in the fuck am I not allowed to acces non-static shit in my static main
How is a static function supposed to know which instantiated object you are referring to?

To anyone who's seriously considering Rust, look at SaferCPlusPlus instead. It fits into the current ecosystem without reinventing the wheel, so you keep your existing skills and get to use your favorite text editor and everything. It also isn't pushing a toxic leftist narrative deliberately calibrated to undermine western civilization, but that's just a nice bonus, really.

github.com/duneroadrunner/SaferCPlusPlus

This should be pretty fucking obvious you retard nigger.

>It also isn't pushing...
Chuckled, would read again.

>hurr java is better
at least not pajeet like you seem to be

sttiiiiiiiiiillllll generating

It'll make it to the router and back.

sepples fags reimplementing their language again.

have you heard about threading?

It's not my code

You mean something like:

void main() {
char* somefile = #fileinclude(~/pepes/pepe.asciiart.txt);
printf(somefile);
}


Why would that ever be better than just including the file with the program?

>/dpt/ will still argue that java isn't shit

at least they're doing something useful with their life, unlike you

It's a library instead of a new language. Like Rust should have been in the first place.

We don't need more half-baked languages when we've got C++.

>we don't need C++ when we have C
>we don't need C when we have assembly

>we don't need assembly when we have machine code

If that shit worked in another language, that other language did it wrong.