/dpt/ - daily programming thread

/dpt/ daily programming thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

s.4cdn.org/image/title/
en.wikipedia.org/wiki/Line–line_intersection#Given_two_points_on_each_line
benchmarksgame.alioth.debian.org/),
pastebin.com/ri4k05HL
pastebin.com/ahaehsVV
pastebin.com/BiHx93db
boards.Sup
gigamonkeys.com/book/macros-standard-control-constructs.html#looping
en.wikipedia.org/wiki/Regular_expression
twitter.com/SFWRedditGifs

>Posted before the bump limit
Delete this invalid thread, you fucking autist

>complains about bump limit
>then claims the OP is an autist

You're the autist

Other thread has reached bump limit, wtf you on about?

Pre-bump limit posting of new threads lead to all sorts of problems.
Don't fucking do it, ever. Even if it's just a single post.

It's only 309 at the time I am posting right now. It was 306 or something when this thread was made.

Finished my brainfuck interpreter senpai
from sys import argv, stdin

cdef char cells[30000]
cdef short int cellPos = 0, filePos = 0
cdef list stack = []

cdef inline void move():
cdef int i = 1
while i != 0:
cChar = input.read(1)
if cChar == '[':
i += 1
elif cChar == ']':
i -= 1

with open(argv[1]) as input:
while True:
cChar = input.read(1)
if cChar == '':
break

if cChar == '>':
cellPos += 1
elif cChar == '

instead of popping the stack, why don't you try popping your cherry

Why don't you do that for me user-kun~~~~~

Nope. It was made at 308 and it's at 312 now.

Why am I arguing with a retard?
Fuck off.

Why do universities start with java?
Is it a good beginner language?

>It was made at 308
Thank you for just validating what I just said, you fuckwit.
It shouldn't be before the bump limit AT ALL.
It leads to turbonerds (such as yourself) who will compete with each other and post earlier and eariler, just so they can shitpost and spread their forced memes in the OP.
All pre-bump limit threads need to be deleted and should not be posted in, so that this sort of faggotry is discouraged.

Because it's a simple language, mind-numbingly so, and businesses love it because it means they can fire all their American engineers and replace them with Pajeet.

Java and C# are basically the same language.

It's easy to get going.

That said, Scheme does it better, and it probably the bestest place to start to be true.

>it's a simple language, mind-numbingly so
no it isn't. It's full of boilerplate that you can't really appreciate until you're more experienced

Isn't python easier though?
That's what I've been told anyways.

I'll look into Scheme, thanks.

Go be butthurt somewhere else you fucking degenerate.

>I'll look into Scheme, thanks

Keep in mind, Scheme is good precicely because of how unfriendly it is to the beginner. Don't get discouraged early on if you feel like you're forced to think differently to suit the language's syntax. The greatest lesson to be gained from Scheme is that it takes you out of the iterative mindset.

Oh, also it's called Racket now

The boilerplate is tedious precisely because it is simple: it is brain-atrophyingly uninspiring, boring, dull, uninteresting, unimaginative, prosaic, bland, flat, and repetitive.

Businesses don't like universities teaching Python as much because Pajeet doesn't know it.

I'll bear that in mind.

Thanks again user.

It's a beautifully simple type system. If you knew any compiler theory you'd appreciate that.

In IPv6, what is a port?

also what is the actual format of an IP address? I mean what bytes are the unique part and which ones are fixed for a certain type of IP type (port?)

i can't into regex so rate my stupid shell script
# grabs Sup Forums banner urls, saves to urls.txt

URL=s.4cdn.org/image/title/
declare -a arr=("a" "b" "c" "d" "e" "f" "g")
for (( ; ; ))
do
for i in "${arr[@]}"
do
PIC=$(curl -silent //g')
echo $URL$PIC >> urls.txt
sort -u urls.txt > /dev/null
echo "Currently have: $(wc -l urls.txt)"
sleep 5
done
done

Pure Python ran through an interpreter

Exact same code compiled with Cython

Are you joking?

Its type system is 'simple' (or more correctly, limited) to the point of almost being unusable. It is only thanks to users' demands for backwards compatibility that it has type erasure, and therefore parametricity (well, as long as you don't use instanceof or reflection) instead of terrified generics.

Let's also mention the presence of null, and the horrid distinction between primitive and reference types.

What kind of language is this? Ruby?1

>terrified generics
I mean reified generics.

Many of them are switching to python now

Cython
Ease of Python programming, speed of C. A bit of a bitch to actually compile though.

What do you Sup Forumsoys reccomend to start learning C and make?

>>inb4 c the hard way

Macquarie university starts with processing, then moves on to Java.

How easy is compilation? And can any Python script be compiled with Cython?

>speed of C
Yeah, no.

If you compile it to C, why are you running it with the Python interpreter?

and you need all that shit, why exactly?

K&R

make is a glorified batch language... you can only appreciate it once you understand how a c compiler is used at all

Why don't these nested loops increment at all?
right now it's just saving 0.jpg over and over
URL=s.4cdn.org/image/title/
declare -a arr=("jpg" "png" "gif");
for (( ; ; ))
do
for i in $(seq 0 500)
do
for j in "${arr[@]}"
do
wget $URL$i."${arr[$j]}"
sleep 5
done
done
done

>no forced trap meme
Best OP.

What's a good source for learning java outside of uni, I want to start teaching my little bro so he'll ace uni.

Not much more work than compiling other languages, though it took me a bit to figure out a good way to compile it to an executable instead of a shared library (because it seems like every Cython tutorial only talks about compiling Cython files to shared libraries, with only minor hints on making executables). Pic related is how I got it setup for compiling a single file.
It can get very close, I'll post other benchmarks.
So how it's supposed to work is that when you compile a Cython program, it gets made into a shared library. That shared library can then be import as a Python module, so that file you see being run through the Python interpreter is actually a driver for that shared library.

Not much more shilling I can do for Cython since I'm still learning it myself, but that's my spiel

>finally finish program that took forever to write
>it works perfectly and does so in an just 6 seconds

>It can get very close, I'll post other benchmarks.
What is the code you're even benchmarking?

ipv6 is layer 3, there are no ports

Is using stdio.h v iostream a personal preference or is one actually better than the other?

So if I wanted to iterate through every possible IP address in the universe, would I just start at 0.0.0.0 and go to 255.255.255.255?

C++ stringstreams are pure trash.

SOMEONE FOR THE LOVE OF ALL THAT IS HOLY PLEASE HELP ME

I'VE GOT THE FORMULA FROM HERE:

en.wikipedia.org/wiki/Line–line_intersection#Given_two_points_on_each_line

double
x1 = -1, y1 = -1, x2 = 1, y2 = 1,
x3 = -1, y3 = 1, x4 = 1, y4 = -1;
double Px =
((x1*x2 - y1*x2)*(x3 - x4) - (x1 - x2)*(x3*y4 - y3*x4)) /
((x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4));
double Py =
((x1*x2 - y1*x2)*(y3 - y4) - (y1 - y2)*(x3*y4 - y3*x4)) /
((x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4));

(Px, Py) IS (-0.0, -0.0)

FAIR ENOUGH

BUT THEN LOOK AT THIS MOTHERFUCKING SHIT:

double
x1 = -1, y1 = 1, x2 = 1, y2 = -1,
x3 = -1, y3 = -1, x4 = 1, y4 = 1;
double Px =
((x1*x2 - y1*x2)*(x3 - x4) - (x1 - x2)*(x3*y4 - y3*x4)) /
((x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4));
double Py =
((x1*x2 - y1*x2)*(y3 - y4) - (y1 - y2)*(x3*y4 - y3*x4)) /
((x1 - x2)*(y3 - y4) - (y1 - y2)*(x3 - x4));

(Px, Py) IS NOW (0.5, 0.5)

(((WHAT THE FUCK)))

EXPLAIN THIS BULLSHIT

I'm not doing the benchmarking, I'm grabbing it out of a book I'm reading (who grabbed the program off here benchmarksgame.alioth.debian.org/), though I do plan on doing my own benchmarks at some point if I find good code to test with. The code the book is testing with is basically a simulation of a solar system.

Code in Python: pastebin.com/ri4k05HL
Code in Cython: pastebin.com/ahaehsVV
Code in C: pastebin.com/BiHx93db

now i noticed the mistake lmfao i wrote x1*x2 instead of x1*y2

Time for actual Cython code

Are Lazy Foo's SDL 2 tutorials any good? any better alternatives?

And for C code

bit of a problem

so lets say I have a database of about 400 entries with 10 attributes per. I have a website on github which needs to access this database for pertinent information.

This information needs to be kept current (updates every minute)

I don't want to push commits every minute to github (for obvious reasons) so I need an online host which:
1. Has an api
2. Allows frequent posts or updates
3. Has permanency (don't want to lose that data every time I turn off my own server which pushes to it)

This information is not confidential in any way.

I can push to any database really easy with scrapers or whatnot and was thinking about pastebin or twitter but neither are really ideal imo. Any suggestions?

curl --silent 'boards.Sup Forums.org/g/' | tr -d '\n' | sed 's/^.* data-src=.\([0-9]*\.[a-zA-Z]*\).*$/https:\/\/s.4cdn.org\/image\/title\/\1\n/g'


here ya go

that's ipv4, not ipv6
yes, but there are reserved and private areas as well, which may not be used for public adresses.

You're pure trash.

Would the brute force method I described be advisable for a real world web crawler if it skips reserved ranges?

What optimizations could be made if I didn't want to index any websites?

Forgive me, I know very little about networking

Why aren't you programming in c++?

Do it for Hime. It's objectively the best language

...

> it's a OSGTP has an opinion thread

>/po/tard racemixer trying to talk down on somebody else

Stop posting your forced memes. God damn, you're fucking worse than frogposters.

Hime only likes real programmers that program in (((((((((((lisp)))))))))) and hask : -> ell

no, because the amount of public ips used for websites is a lot smaller than the amount of all public ips

Program for editing/adding things in access, shit like that.

I want to create a large array of assets, for example I am creating a card game with 52 cards and the assets are all called card01, card02, etc.

Is there a tool or shortcut I can use to generate a list e.g. ["card01", "card02", etc] to save me having to type that crap out 52 times?

>Visual basic
>Microsoft Access

Yeah, learn to use the tools your programming language gives you.
["card"+str(n/10)+str(n%10) for n in range(1, x)]

the thing you're looking for is a "loop"
also, you might need to look up "array"

>What are for loops.
cards = [ ]
for i in range(1, 53):
cards.append("card" + str(3).zfill(2))

awk '{for(i=1; i

Combining and cards = ["card" + str(n).zfill(2) for n in range(1, 53)]

Walk him through the official Sun spec.

It's the best way

(loop for i from 1 to 52
collecting (format nil "card~2,'0d" i))

thats like 10 years old and he wont learn how to AbstractBeanImplicitBeanFactoryBean

There's a joke in Spanish about the ArrayDeque:
"Dequé me sirve saber cómo está implementado?"
[spoiler]
deque ~= de qué: what for
What for do I need to know how it's implemented?
[/spoiler]

vector vCard;
for (unsigned int i = 1; i < 53; i++){
stringstream ss;
ss

map ("card"++) (map show [1..53])

where do i learn this magic?

arr=[]
for e in range(52):
arr.push('card',str(e))

>later, a buggy function steps beyond the previous variable to vCard and overwrites it with garbage
>lose vCard
>still virgin

Working on a chat...

just put up some new injection defenses and i need peoople to try to break my little bitch again

>uses a list
>push

its append, not push. notice the string card too
arr = []
for e in range(52):
arr.append('card' + str(e))


or more simply

arr = ['card' + str(e) for e in range(52)]

[email protected]

message me for the name of the site.

fuck. it, it's the comfy.chat one.

It's for school, so I don't really have an option.

That's a design pattern. It has nothing to do with Java as a language

your formatting is nice

through fapping to traps

>needing the language to take you by the hand and sandbox you

char* cArr[52];
char* card = "card\0";
for (int i = 0; i < 52; i++){
char num[3];
sprintf(num, "%02d", i + 1);
cArr[i] = malloc(7);
strcpy(cArr[i], card);
strcat(cArr[i], num);
}


the supplied answers were seriously lacking in potential memory leaks

kill yourself

>doesn't check the return value of malloc
> no main function
> no include guards
> no return from function
> not using semaphores
> not using pthread_mutex_lock


get out pleb

what are regular expressions?

Wouldn't it only go up to 51 in the first place?

Thank you. Will look up loops. I've been learning to code for about 3 days so know nothing.

the i+1 makes it go 1-52

Semantic cruft

gigamonkeys.com/book/macros-standard-control-constructs.html#looping

en.wikipedia.org/wiki/Regular_expression

regexr.com

because I'm feel like being nice

I honestly didn't expect to get much out of this thread other than abuse.

Thanks, user.

...

Best SDL Tutorials for C++?