[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - daily programming thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 28
File: 20-15-50-maxresdefault.jpg (117 KB, 1280x720) Image search: [Google]
20-15-50-maxresdefault.jpg
117 KB, 1280x720
/dpt/ daily programming thread

What are you working on, /g/?


Previous Thread: >>55173239
>>
>>55180495
>Posted before the bump limit
Delete this invalid thread, you fucking autist
>>
>>55180528

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

You're the autist
>>
>>55180528
Other thread has reached bump limit, wtf you on about?
>>
>>55180538
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.

>>55180559
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 == '<':
cellPos -= 1
elif cChar == '+':
cells[cellPos] += 1
elif cChar == '-':
cells[cellPos] -= 1
elif cChar == '.':
print(chr(cells[cellPos]), end = "")
elif cChar == ',':
cells[cellPos] = stdin.read(1)
elif cChar == '[':
stack.append(input.tell())
if cells[cellPos] == 0:
stack.pop()
move()
elif cChar == ']':
if cells[cellPos] != 0:
input.seek(stack.pop() - 1)
else:
stack.pop()
>>
>>55180574
instead of popping the stack, why don't you try popping your cherry
>>
>>55180581
Why don't you do that for me anon-kun~~~~~
>>
>>55180565
Nope. It was made at 308 and it's at 312 now.

Why am I arguing with a retard?
Fuck off.
>>
>>55180495
Why do universities start with java?
Is it a good beginner language?
>>
>>55180604
>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.
>>
>>55180617
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.
>>
>>55180617
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
>>
>>55180649
Isn't python easier though?
That's what I've been told anyways.

>>55180668
I'll look into Scheme, thanks.

>>55180638
Go be butthurt somewhere else you fucking degenerate.
>>
>>55180675
>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
>>
>>55180668
The boilerplate is tedious precisely because it is simple: it is brain-atrophyingly uninspiring, boring, dull, uninteresting, unimaginative, prosaic, bland, flat, and repetitive.

>>55180675
Businesses don't like universities teaching Python as much because Pajeet doesn't know it.
>>
>>55180694
I'll bear that in mind.

Thanks again anon.
>>
>>55180721
It's a beautifully simple type system. If you knew any compiler theory you'd appreciate that.
>>
File: projection_matrix_eq.png (6 KB, 435x172) Image search: [Google]
projection_matrix_eq.png
6 KB, 435x172
>>55180495
>>55180495

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 4chan banner urls, saves to urls.txt

URL=http://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 http://boards.4chan.org/"${arr[$i]}"/ | tr '<' "\n" | grep "data-src" | cut -c 52- | sed 's/">//g')
echo $URL$PIC >> urls.txt
sort -u urls.txt > /dev/null
echo "Currently have: $(wc -l urls.txt)"
sleep 5
done
done
>>
File: Screenshot_2016-06-20_19-02-17.png (22 KB, 1094x168) Image search: [Google]
Screenshot_2016-06-20_19-02-17.png
22 KB, 1094x168
Pure Python ran through an interpreter
>>
File: Screenshot_2016-06-20_19-02-42.png (22 KB, 1126x165) Image search: [Google]
Screenshot_2016-06-20_19-02-42.png
22 KB, 1126x165
>>55180785
Exact same code compiled with Cython
>>
>>55180738
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.
>>
>>55180574
What kind of language is this? Ruby?1
>>
>>55180812
>terrified generics
I mean reified generics.
>>
>>55180617
Many of them are switching to python now
>>
>>55180820
Cython
Ease of Python programming, speed of C. A bit of a bitch to actually compile though.
>>
What do you /g/oys reccomend to start learning C and make?

>>inb4 c the hard way
>>
>>55180852
Macquarie university starts with processing, then moves on to Java.
>>
>>55180804
How easy is compilation? And can any Python script be compiled with Cython?
>>
>>55180863
>speed of C
Yeah, no.
>>
>>55180804
If you compile it to C, why are you running it with the Python interpreter?
>>
>>55180812
and you need all that shit, why exactly?
>>
>>55180880
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=http://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
>>
>>55180495
>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.
>>
File: Screenshot_2016-06-20_19-25-06.png (38 KB, 469x490) Image search: [Google]
Screenshot_2016-06-20_19-25-06.png
38 KB, 469x490
>>55180914
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.
>>55180931
It can get very close, I'll post other benchmarks.
>>55180963
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
>>
File: smug.png (662 KB, 862x1000) Image search: [Google]
smug.png
662 KB, 862x1000
>finally finish program that took forever to write
>it works perfectly and does so in an just 6 seconds
>>
>>55181094
>It can get very close, I'll post other benchmarks.
What is the code you're even benchmarking?
>>
>>55180742
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?
>>
>>55181163

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?
>>
>>55181272
C++ stringstreams are pure trash.
>>
File: REEEEEEEEEEEEEEEEE.png (17 KB, 465x98) Image search: [Google]
REEEEEEEEEEEEEEEEE.png
17 KB, 465x98
SOMEONE FOR THE LOVE OF ALL THAT IS HOLY PLEASE HELP ME

I'VE GOT THE FORMULA FROM HERE:

https://en.wikipedia.org/wiki/Line%E2%80%93line_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
>>
File: Screenshot_2016-06-20_19-37-07.png (105 KB, 1101x875) Image search: [Google]
Screenshot_2016-06-20_19-37-07.png
105 KB, 1101x875
>>55181158
I'm not doing the benchmarking, I'm grabbing it out of a book I'm reading (who grabbed the program off here http://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: http://pastebin.com/ri4k05HL
Code in Cython: http://pastebin.com/ahaehsVV
Code in C: http://pastebin.com/BiHx93db
>>
>>55181320
now i noticed the mistake lmfao i wrote x1*x2 instead of x1*y2
>>
File: Screenshot_2016-06-20_19-43-56.png (16 KB, 884x133) Image search: [Google]
Screenshot_2016-06-20_19-43-56.png
16 KB, 884x133
>>55181324
Time for actual Cython code
>>
Are Lazy Foo's SDL 2 tutorials any good? any better alternatives?
>>
File: Screenshot_2016-06-20_19-44-39.png (16 KB, 772x128) Image search: [Google]
Screenshot_2016-06-20_19-44-39.png
16 KB, 772x128
>>55181342
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?
>>
>>55180768
curl --silent 'https://boards.4chan.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
>>
>>55181297
that's ipv4, not ipv6
yes, but there are reserved and private areas as well, which may not be used for public adresses.
>>
>>55181312

You're pure trash.
>>
>>55181404

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
>>
File: 1463174335918_0.jpg (98 KB, 865x924) Image search: [Google]
1463174335918_0.jpg
98 KB, 865x924
Why aren't you programming in c++?

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

> it's a OSGTP has an opinion thread
>>
>>55181481
>/po/tard racemixer trying to talk down on somebody else

>>55181495
Stop posting your forced memes. God damn, you're fucking worse than frogposters.
>>
>>55181495
Hime only likes real programmers that program in (((((((((((lisp)))))))))) and hask : -> ell
>>
>>55181492
no, because the amount of public ips used for websites is a lot smaller than the amount of all public ips
>>
File: data.png (560 KB, 1920x1200) Image search: [Google]
data.png
560 KB, 1920x1200
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?
>>
>>55181675
>Visual basic
>Microsoft Access
>>
>>55181681
Yeah, learn to use the tools your programming language gives you.
["card"+str(n/10)+str(n%10) for n in range(1, x)]
>>
>>55181681
the thing you're looking for is a "loop"
also, you might need to look up "array"
>>
>>55181681
>What are for loops.
cards = [ ]
for i in range(1, 53):
cards.append("card" + str(3).zfill(2))
>>
>>55181681
awk '{for(i=1; i<=52; i++)printf("\"card%02d\",", i);}'

:^)
>>
>>55181681
Combining >>55181716 and >>55181777

cards = ["card" + str(n).zfill(2) for n in range(1, 53)]
>>
>>55181055
Walk him through the official Sun spec.

It's the best way
>>
>>55181681
(loop for i from 1 to 52
collecting (format nil "card~2,'0d" i))
>>
>>55181835
thats like 10 years old and he wont learn how to AbstractBeanImplicitBeanFactoryBean
>>
>>55181867
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]
>>
>>55181681
vector<string> vCard;
for (unsigned int i = 1; i < 53; i++){
stringstream ss;
ss << setw(2) << setfill('0') << i;
vCard.push_back("card" + ss.str());
}
>>
>>55181681
map ("card"++) (map show [1..53])
>>
>>55181381
where do i learn this magic?
>>
>>55181681
arr=[]
for e in range(52):
arr.push('card',str(e))
>>
>>55181912
>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
>>
>>55181942
>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)]

>>
>>55181994
[email protected]

message me for the name of the site.

fuck. it, it's the comfy.chat one.
>>
>>55181716
It's for school, so I don't really have an option.
>>
>>55181867
That's a design pattern. It has nothing to do with Java as a language
>>
>>55181675
your formatting is nice
>>
>>55181940
through fapping to traps
>>
>>55182033
>needing the language to take you by the hand and sandbox you
>>
>>55181681
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
>>
>>55182053
kill yourself
>>
>>55182072
>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
>>
>>55181940
what are regular expressions?
>>
>>55182072
Wouldn't it only go up to 51 in the first place?
>>
>>55181740
>>55181773
>>55181777
>>55181800
>>55181803
>>55181839
>>55181912
>>55181923
>>55181942
>>55182072


Thank you. Will look up loops. I've been learning to code for about 3 days so know nothing.
>>
>>55182101
the i+1 makes it go 1-52
>>
>>55182100
Semantic cruft
>>
>>55182105
http://www.gigamonkeys.com/book/macros-standard-control-constructs.html#looping
>>
>>55182100
https://en.wikipedia.org/wiki/Regular_expression
>>
>>55182100
regexr.com

because I'm feel like being nice
>>
>>55182128
I honestly didn't expect to get much out of this thread other than abuse.

Thanks, anon.
>>
File: you-wellcum.png (86 KB, 640x480) Image search: [Google]
you-wellcum.png
86 KB, 640x480
>>55182172
>>
Best SDL Tutorials for C++?
>>
is there any heavily used language where literally every feature is just built into the syntax?
>>
>>55182264
Jabba aims for that
>>
>>55182254
prolly lazyfoo
>>
>>55182293
not him


>lazyfoo
Did he finally get around to finish his SDL2 tutorial?
>>
>>55182278
Java doesn't even come close. It's the wordiest language out there
>>
>>55182338
>wordiest language
How do you expect to (try unsuccessfuly to) cram every feature into the syntax otherwise?
>>
>>55182293
>>55182325

I figured it was going to end up being Lazy Foo but wanted to double check.

SDL2: http://lazyfoo.net/tutorials/SDL/
>>
>>55182370
I meant I am not whom you were replying too. I used lazyfoo long ago and enjoyed it.
>>
>>55182363
`echo "backticks do shell scripts"`
/regex in slashes/
[0:10:2] #colon-separated ranges
*asterisks_create_pointers
join(' ', ['elipsis', 'create', 'splats']...)


Shit like that
>>
>>55181997
It's not padded for values less than 10 either.
>>
>>55182464
Oh, that. Easy, just define a reader macro- oh right, Java doesn't have those :^)
>>
>>55182520
Which is why I haven't used java in years
>>
>>55182264
APL?
>>
>>55182587
NFL?
>>
>>55182520
which language has the power to do that with macros? I know for a goddamn fact C/C++ can't and they're the only language I know with macros
>>
File: 1465871665826.jpg (112 KB, 987x741) Image search: [Google]
1465871665826.jpg
112 KB, 987x741
In C#, what's the fastest way to store an object and a value (in this case, a reference to a node and a weight) and then retrieve the node with the smallest weight?
I'm currently just iterating over a list, but there must be a faster way.
>>
>>55182520
Reader macros are disgusting.
>>
>>55182631
Common Lisp, among many other lisps, has them, and way better than C/C++
http://letoverlambda.com/index.cl/guest/chap4.html
Example:
http://weitz.de/cl-interpol/
>>
>>55182675
Nobody forces you to use them. Most Common Lisp packages I've met so far that add reader macros usually have their "vanilla" bases visible, with the reader macros optional
>>
>>55182609
what?
>>
>>55182683

what would be the point though? so much convenience is lost just through polish notation and surrounding everything in parens
>>
>>55182702
Why use a macro when you could use a monad?
>>
File: 1465869795000.jpg (60 KB, 456x810) Image search: [Google]
1465869795000.jpg
60 KB, 456x810
Is the 'self-teach then get yourself a job' just a feelgood meme or is it true?

Whenever I look on jobsites they always require a bachelor's degree. Once in a while I'll see a job posting that doesn't require a degree but 5 years experience instead.
>>
>>55182767
>convenience is lost
>[citation needed]
>>55182769
You can have your cake and eat it too
https://common-lisp.net/project/cl-monad-macros/monad-macros.htm
>>
>>55182666
A Parallel.Foreach?
>>
>>55182841
The algo is already threaded and given the number of checks, I'm already effectively maxing out my CPU. I want to find a cheaper way, CPU-wise, to find the nearest neighbor
>>
>>55182789
If you already made a brand of yourself people will hire you.

However, most of the time people in industry have no idea who the fuck you are.

Those "Self-teach" people already had a ton of connections and those connections needed people at the time so they hired them.

Unless you have connections you need a bachelor's degree since most companies do not have time to go through all the resumes they are sent so they just filter resumes by whether or not they have a degree.
>>
>>55180804
Now try with pypy

>>55181094
How easy is using the library from C programs?
>>
File: dfsfsf.jpg (206 KB, 1366x768) Image search: [Google]
dfsfsf.jpg
206 KB, 1366x768
Can't seem to find my error. Anyone knows what could make all my values to not be in the right column ?

They're off by one plance from right. First column should receive an int Id.
I launcheud a select query from my java application and when I lauch the same query in my sql database, it works juste fine.
>>
>>55182264
>heavily used
No. Who would want to use an awful golf language?
>>
>>55183058
What program are you using?
>>
>>55182963
Writing the library in Cython and then calling it from C? Linking wouldn't be hard I'd imagine, the tough part here would probably actually be creating the header file (which I'm sure wouldn't be difficult either). I'd have to mess around with it tomorrow and report back.
>>
>>55183257
If it actually works it would be able to give easy and native access to most of the python libraries in C, really nice.
>>
>>55183058
>find my error
>java
>>
in c++, if a class gets a virtual method then it becomes abstract and can no longer be instantiated, right? it's not just pure abstract classes that can't be abstracted, correct?
>>
>>55183209
>>55183320
forget it, I just found.
>>
>>55183279
http://docs.cython.org/src/userguide/external_C_code.html
Look under the section "Using Cython Declarations from C". Even generates the header files for you as well.
>>
>>55183343
pure abstract classes cannot be abstracted without a level of abstraction demanded from abstract mathematics in an abstract world
>>
>>55183343
correct
because one of its functions has no implementation, so what would happen if it were to be called?
>>
File: 1458054038714.jpg (52 KB, 742x720) Image search: [Google]
1458054038714.jpg
52 KB, 742x720
So did ya'll learn? College? Online resources? Books?

What is the best method, in your opinion?
>>
>>55183523
I learned how to program (in C) myself in high school. I don't even remember what I used to learn, but there were some shitty online resources.
I'm now in my third year of university, and was able to skip the COMP101 introduction to programming shit.
There are all sorts of CS shit you'll learn in university that you're unlikely to pick up anywhere else. I would recommend going there. Although CS is a lot more than just programming.
>>
>>55183523
>What is the best method, in your opinion?
sitting at the computer and banging away at a problem until you solve it
then you move on to a slightly harder problem and repeat
if you wait until college you will be way too old, you'll never be anywhere near as good as the rest of your class who started at age 10-13
>>
>>55183596
>if you wait until college you will be way too old, you'll never be anywhere near as good as the rest of your class who started at age 10-13
What a load of crap.
>>
Could "fast inverse square root" have just used a union? That seems like pretty much what unions were made for. I can't think of any other uses of unions and never see anyone using unions.

float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}
>>
>>55183523
Beginner tutorials -> school (useful against unknown unknowns) + intermediate books -> personal projects -> advanced books

You can probably replace the school step with MIT opencourseware and other online courses.
>>
>>55183714
>Could "fast inverse square root" have just used a union?
Yes.
But at the time (C89), I think reading out of a union that wasn't the last member written to was unspecified (maybe undefined) behaviour. C11 makes it implementation defined behaviour, so it would work as expected now.
Also, type punning like that was much more common. I think more people have to realise that it's undefined behaviour now though.
>>
File: akari a cute.gif (880 KB, 500x281) Image search: [Google]
akari a cute.gif
880 KB, 500x281
I finally made something in javascript!
It's a 4chan banner scraper!
pls rate

https://a.pomf.cat/wbettf.html
>>
>>55183964
naice
>>
>>55183964
>1.jpg,1.png,1.gif,2.jpg, 2.png, 2.gif,...
Oh god why would they index them like that
>>
>>55183683
how do you expect to compete with people who all have that many years experience on you?
>>
>>55183964
BEST
>>
>>55183683
He is right you asshole
>>
>>55183964
Oh god, did they removed the one where the little nichijou removes her hair?
>>
>generate a bitmap image programatically
>have it open in windows photo viewer
>right click on image file in eclipse
>computer freezes and the hard drive makes a "chuck, chuck, chuck..." noise
>fails to boot at first, get "secondary master hard disk error"
>boots but windows says there was an error so it made a temporary page file
is my hard drive fucked? but it seems like a software error since it happened exactly when i right clicked the file in eclipse after having written to it
>>
>>55184187
when i tried to open the image again it says
>Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted, or is too large.
can a corrupted image file crash a computer/harddrive?!
>>
>>55183683
He's right though. If you don't at least get your feet wet before you're already a fucking adult, you are seriously handicapping yourself. This is because programming isn't just syntax; it's a mode of thinking -- and a habit best formed early.
>>
>>55184213
or it probably got corrupted when the crash/freeze and hard reset happened i guess
>>
File: haha ok.gif (1022 KB, 640x480) Image search: [Google]
haha ok.gif
1022 KB, 640x480
>>55184228
>"this is the only thing i'm good at and i'll be damned if i let some 30yo truck driver switch industries and become competent enough to take my job away!~!!"
>>
>>55184228
it's fine to start as a young adult if you're a genius and already good at math and problem solving
>>
>>55184246
What a realistic scenario! You sure got me, regretful-college-grad-desperately-looking-for-a-job-with-his-useless-degree.

Or maybe you're a dropout working some menial retail job, hoping to cash in on a lucrative developer gig like one of your more studious friends did. You're right, I'm sure you can be as good as him if you try.

Best of luck m9
>>
>>55184187
>>55184213
Not programming

>windows
>>
>>55180495
Get in here /dpt/
https://discord.gg/015Q4PbF08GkKfKZw
>>
>>55184337
no thanks
>>
>>55184337
>>55184337
Your friends list is full
>>
>>55184332
*tips*
>>
>>55184337
Can't join
>>
>>55184297
you don't understand, if he tries hard enough and believes in himself he can succeed no matter how late in the game

it's just like the pokemon cartoon
>>
>>55184361
>>55184347
Why?
>>
>>55184374
It's true tho, if you can bust your ass hard enough you can do anything, it's just often people dont bust their ass at all and then complain about how hard they tried
>>
>>55184439
That isn't true at all
it's just not realistic
>>
>>55184439
this, especially women and poorfag uneducated minorities and fuccbois
>>
File: sudoku.png (30 KB, 453x528) Image search: [Google]
sudoku.png
30 KB, 453x528
Just finished a sudoku solver. Too lazy to use backtracking/recursion - it's just a brute force algorithm.

>le green text black background meme
>>
>>55183964
>realising your favourite banner got removed
Feelsbadman.jpg
>>
File: Capture.png (24 KB, 1063x494) Image search: [Google]
Capture.png
24 KB, 1063x494
>>55181716
it's called getting work done

making a risk game in c#. linq is so fucking good. I wish java predicates where as effortless to use as this
>>
>>55183714
Well how would the union code look like
>>
>>55184547
I think a lot of people here would be horrified to learn just how much of the business world is held together with nothing but MS Office heaped with steaming piles of VB[A].

Certain industries just cannot move past 2003. And that's if you're lucky.
>>
>>55184625

It just works, why break it?
>>
>>55184544
which was it?
>>
Id(e.f.) is an endofunctor in the category of endofunctors
>>
>>55184625
I know, i've been to the dark land of VBA and saw nothing but pain and misery
>>
why should destructors provide no throw argument?
>>
>>55184937
holy shit

destructors with exceptions sounds great

try {
FileHandle x(filename);
} catch (FileNotFound) {
}
>>
>>55184937
>argument

oops i mean't

>why should destructors provide no throw guarantee?
>>
In C++, should I always be using std::string wherever I can? or is there still a reason to use char * except for when interfacing with C code?

Also, what's the performance overhead of std::string.c_str() and std::string in general?
>>
>>55185217
I think in C++14 or something they guarantee std::strings end in a \0, so no overhead for .c_str()
>>
>>55185217
yes you should always use string
you can even use it when interfacing with c code that wants char*'s
unless that c code tries to allocate memory to the pointer you're passing it (which should never be the case)

the performance hit is negligible
you'd have to go well out of your way just to be able to measure any difference at all
>>
>>55185217

>In C++, should I always be using std::string wherever I can?
If it meets all of your needs, it is useful. Otherwise, consider that other libraries may provide a better string class.

>or is there still a reason to use char * except for when interfacing with C code?
Takes up less space, doesn't require double indirection to pass to a function without copying shit.

>Also, what's the performance overhead of std::string.c_str() and std::string in general?
Depends on implementation. I would suggest looking up some benchmarks.
>>
>>55185271
>doesn't require double indirection to pass to a function without copying shit.
>What are references.
>>
>>55185278
Wait, ignore that post, I'm retarded.
>>
>>55185258
>you can even use it when interfacing with c code that wants char*'s
You mean by using .c_str()? or will it automatically convert or something?
>>
>>55185278

Reference to string -> first indirection
Get character from reference to string -> second indirection
>>
>>55185304
you can pass it like this
&mystring[0]
>>
>>55185333
C++ is such a beautiful language
>>
>>55185333
Is there a difference at all between that and .c_str()?
In fact is that even portable?
>>
>>55185364
yes there's a difference
.c_str() will append a '\0' to the end
if you just pass the address of the first character and your string doesn't end with a \0, and the c code is expecting a null terminator, then you're going to have a problem

on the other hand if you're passing it to a function which also takes the length in another parameter, or if your string does end with a null, then it's fine

you'd have to actively seek out a compiler + system that will fuck it up
but yeah, the purists would say it's not portable
>>
>>55180694
scheme is love, scheme is life
>>
Does github let you have a full fledged personal site, or is it just dumbed down markdown crap?
>>
>>55180495
What are some examples of things one might use Hadoop for?

I may wind up working with a friend on a project (no details, though).
Either way, one thing led to another, and I'm now wondering if my own project (alternative social network) might somehow benefit from Hadoop, if not immediately, then sometime in the future.

What are the most common uses of Hadoop?
Why might I want to include it on top of my LAMP?

Just maybe 5-10 good (sort of specific) examples would be appreciated*. Or however many you want.

*NOT like: "Data mining". Instead gimme an example of WHAT I might actually want to mine. I already know "data mining", and I plan to mine (incredibly) limited data on an opt-in basis for a few optional features. Would it be significantly more efficient than say RegEx flagging posts that might contain illegal content or blocking banned hashes of files using PHP? What might I gain in terms of DB analysis?
>>
>>55185537
yes you can push regular html files and it'll work
>>
>>55182666
List with a key value pair. Then use LINQ to do ordering
>>
>>55185838
So basically 1GB of free hosting, like with their regular repos?
>>
>>55185537
markdown is amazing you can do anything you normally would do with it[1] it's *super* easy and _convenient_ ![](girls_laughing.jpg) and extremely readable

[1] https://www.gentoo.org/#!/install
>>
>>55185747
Anyone? Just a few specific examples of what Hadoop could be used for would really be appreciated
>>
>>55184484
Now make a NP complete solution so you can fit in with us
>>
>>55185848
dunno what the size is but yeah, it's free hosting
though it's safe to say that if you host some random website not related to the github project it's attached to (and you draw lots of visitors) they will remove it
>>
What the fuck do I do, I'm one year away from graduating and I don't think I've learned how to do shit. Going back and relearning fundamental stuff seems pointless but I also have no idea what the fuck to work on. Applying for internships was a bust so I don't know what the fuck to do
>>
I forgot, what's the command in gdb to constantly print out a value of a variable with each step?
>>
>>55185915
If you're graduating without any personal projects or internship experience, your degree is completely worthless.
>>
>>55185952
I am very aware. I spent college dealing with depression and dumb shit that doesn't matter if you're trying to find a job. Sure that's fine and dandy if I want to make myself feel better about graduating with a useless piece of paper saying I graduated, but I don't know what to do in this weird as fuck position where I've technically "learned" things but haven't actually done shit. I'm just blindly throwing myself at shit to program: for now, Android shit because I don't fucking know
>>
>>55185984
>weird as fuck position where I've technically "learned" things but haven't actually done shit.

You haven't actually learned anything.

What you're describing is like learning jap from a book and thinking you'll be able to converse with a nip without having ever spoken it.
>>
>>55182869
Not true. I'm self taught and I did fine. I just made a completed project and became maintainer of a relatively small (200 stars on Github) open source project.
>>
>>55185952
>>55185984
that's true for liberal arts and english degrees, but not comp sci
most large employers consider a bachelors degree equivalent to 4 years experience

all you have to do is apply to a bunch of places, get hired for any dev position you can, and then learn on the job
they will have a training period anyway and they assume you know nothing if you're a recent grad/applying for your first dev job
you'll be fine
>>
>>55186007
yeah that's why I put that shit in quotes
>>
Guys, something crap is going on, when I read from a file the current offset isn't incremented by the number of bytes read.
>>
>>55185859
Hadoop might be used whenever you need to transform huge amounts of data. For example, you have some logging service that logs all your users actions, this log is absolutely huge. You want to extract all users that have liked a certain page. You might want to use hadoop.

If you have data that is way too much to handle in a single database, and you only need to do bulk actions (no modifying a single row), hadoop is an appropriate tool for the job. Or spark.
>>
I just discovered annotations in Java today and feel like a retard. Most of my professional experience has been in C and various functional programming languages.

Are annotations as fucked a way of doing things as I think they are, or is there some hidden wisdom to them? I see spring using them everywhere, but they just seem to add magic and make things harder to actually understand.
>>
>>55182869
>Those "Self-teach" people already had a ton of connections and those connections needed people at the time so they hired them.

Another "self teach" person here. You're right and wrong. I made it because of my connections, but I made those connections because my main way of learning was by getting involved in open source and going to meetups.

I found several mentor figures who became fairly invested in teaching me to program. Some of them felt the best way to foster my growth after a certain point was to help me get a job as a junior dev.
>>
>>55186066
So, likes and stuff might benefit from Hadoop. That is helpful. I do plan to have a liking feature.
However, only extracting them for some reason? Other than listing them on the page I can't really see what my personal implementation might extract from it. I'll look into that more, though

>If you have data that is way too much to handle in a single database, and you only need to do bulk actions (no modifying a single row)
I'll keep this in mind if I have something like that in the future.
Other than backups, atm, I can't think of anything in this category.
Like 80% of the site will focus on inserts, deletes, and selects.
Most of the rest will deal with uploading and deleting images.

On the application end, almost everything will be display and concatenation based on session user data and image-related functions.

I'll keep that in mind, though. Bulk actions may be a possible thing in the future at some point.
>>
>>55186072
Annotations a set of bandages for Java
>>
>>55186199
You could not use hadoop for "listing likes in a page". Hadoop queries start too slow and take a long time. People use hadoop for analytical queries on huge datasets, not for something like you described.

Nothing of what you talk about would justify using hadoop. Just use a regular database.
>>
If you put an IPC socket on a network filesystem, does that make it a network socket? Or will the operating system tell you to go fuck yourself?
>>
>>55186518
Seems to explain your problem as well.
https://stackoverflow.com/questions/783134/af-unix-domain-why-use-local-file-names-only
3rd answer specifically.
>>
>>55186590

Ah. Figures Unix wouldn't allow you to be a cheap shit about things like that.
>>
>>55184464
yes it is

as an analogy, take the lykan hypersport or the new acura nsx, they're fucking ridiculous garbage shit cars

and then there's koenigsegg, ferrari, lamborghini, pagani etc, passionate guys that put a ton of effort and made some of the best cars in the world

you're like the woman who designed the new acura nsx, you're hardly even trying compared to people who really busting their ass
>>
>>55186731
that's the wurst analogy ever
only half of it even fits the discussion
I think you just really wanted to make car references
>>
>>55186813
it's 100% possible to do almost anything in programming if you're not retarded and put an honest amount of effort into it
>>
>>55186856

>almost anything
Well, actually there are an infinite number of undecidable problems...
>>
>>55186856
>100% possible to do almost anything in programming
write a program that says if a given program will terminate or not.
>>
Friendly reminder that the IO monad is just a stateful container and as long as your function just returns code that the runtime runs eval on, it is guaranteed to be side-effect free.
>>
>>55186870
>>55186924
nice meme
>>
>>55186939
ur dum
>>
>>55186939
friendly reminder that you should kill yourself
>>
>>55186962
>>55186963
Butthurt haskellfags detected

Why can't you be cool about it, like lispbros? They admitted a long time ago that REPL is the only "real" requirement to functional languages.
>>
>>55186982
>functional languages
bad meme
>>
>>55186995
t. working lang pleb
>>
>>55186939
hum, ok..., thanks, ...for the. . ., ...tip. right?
>>
>>55186924
Anon did say "almost anything", thus he admits undecidable problems exist. The only problem with this is that "almost anything" doesn't work with infinite sets, especially when the set of undecidable problems is also infinite.
>>
>>55187021
"100% possible to do almost anything" doesn't even make sense.
>>
>>55187021
>"almost anything" doesn't work with infinite sets
I would argue that it does
since the set of solvable problems is a faster growing infinity than the set of undecidable ones, I'd say that it is acceptable to state that "almost all" problems are solvable
>>
>>55187021
what's the cardinality of the set of undecidable problems
>>
>>55180495
If there is any form of program that is cancer is its own form, I would simply say it is web programming.

Fucking end yourself for being useless. PHP is for virgin retards,
>>
>>55187038
Well, I can't remember the exact proof, but I remember it used some variant of the diagonalization argument, so I want to say it's uncountably infinite. Would need to double check though.

>>55187037
Hmm... I think I may have found a contradiction to your claim. For any given decidable problem, there should exist an undecidable problem to attempt to decide if a turing machine will solve that problem or not. So there are at least as many undecidable problems as there are decidable problems.
>>
>>55187230
but since these are solvable problems, you will in fact be able to create a turing machine that will determine that this specific problem is solvable

therefore the problem of whether or not such a machine could be made is solvable (it can be made)
>>
>>55186294
Yeah, I got that much from what you said. That's why I questioned the 'extracting' part, because I don't have any current purposes for extracting anything from it.

But, I'll keep it in mind in case I ever DO anything with the likes and stuff.

>Nothing of what you talk about would justify using hadoop. Just use a regular database.
Hmmm. Alright then. That simplifies things.

Yeah, sorry for late response. Had to go do a number of things.

>People use hadoop for analytical queries on huge datasets
That probably wouldn't change much for my intentions. At least not for a long time. The biggest portion of most processing will be counts across different fields linked in a couple different ways; that's about the current limit of data mining I planned to do.
>>
>>55187323

Anon, telling if two Turing Machines are equivalent is undecidable.

Let D be the set of problems that can be decided by a Turing Machine
Let U be the set of problems that can't be decided by a Turing Machine

For all d in D, there exists a u in U such that u attempts to determine if a given Turing Machine is equivalent to/solves d.

Therefore, every decidable problem maps to at least one undecidable problem.

The size of U is greater than or equal to D, and likely strictly greater, but I'm too lazy to think of a good example that isn't such a mapping.
>>
Please help me ,the last print should but out 5 7 , but it puts out 5 and an overflow and i don't get why
>#include <iostream>
>#include <cmath>
>using namespace std;
>class Klasse {
> private:
> double *flugstunden;
> int size;
>
> public:
> Klasse();
> Klasse(double d=0){
> size=0;
> flugstunden = new double[size];
> flugstunden[size]=d;
> }
>
> void add(double d){
> double *buf;
> buf=new double[++size];
> for(int >i=0;i<size;i++)buf[i]=flugstunden[i];
> buf[size]=d;
> flugstunden=new double[size];
> for(int >i=0;i<size;i++)flugstunden[i]=buf[i];
> delete[] buf;
> }
> void print(){
> for(int >i=0;i<(size+1);i++)cout<<flugstunden[i]<<endl;
> }
> void printsize(){cout<<"size"; >cout<<size<<endl;}
> ~Klasse(){delete[] flugstunden;} //dtor
>};
>int main() {
> Klasse a(5);
> a.print();
> a.printsize();
> a.add(7);
> a.printsize();
> a.print();
> return 0;
>}
>>
So I've been working a lot on a game recently and I was wondering if you guys could give me a little input on map generation. currently at this point a bunch of rooms are placed around the map with no check for overlapping (I think it looks better). Then paths are drawn from point A to B where A is at least 40 away from B.

Is there a better way of going about room generation for a rogue-like game? I have been doing a good amount of searching, but everything I've found is roughly how I'm already doing it or isn't dynamic at all.

little note, the game has fog of war so the area that I walked around is all you can see.
>>
>>55187360
use <code> not >
([ ] not < >)
>>
>>55187360
I think you should read up on how arrays work.
Size is the highest index+1;
So if you have one element in your array there only is the index [0] but size is 1.
>>
>>55187357
>For all d in D, there exists a u in U such that u attempts to determine if a given Turing Machine is equivalent to/solves d.
but this may not be a 1-to-1 relationship
there could be many, or perhaps infinite d that map to a single u
>>
>>55187371
Maybe you could make both overlapping and non overlapping parts?
But yeah, from the screenshot it looks ok.
Have you looked at the external links on this
http://pcg.wikidot.com/pcg-algorithm:dungeon-generation
>>
>>55187432

Hmm... I've rephrased my argument a little bit, and I think it is a one to one relationship. It's in a new thread here:

>>55187437

Tell me if the reasoning is objectionable.
>>
>>55187371
Another technique is to put a random number of large rooms (say 3-6) down, and then randomly decide how many connections each should have
and then place the connecting corridors between them
>>
>>55187455
This is what happens when you use a tripcode, dumbass
>>
>>55187469
>>55187440

Thank you very much for you input. I because of that link you gave me I saw this link.

http://www.roguebasin.com/index.php?title=Dungeon-Building_Algorithm

THIS IS AWESOME!
can't believe I never thought to do it piece by piece! I'll have to rewrite about 200ish lines, but I ideas are already flowing!
>>
>>55187576
wow, I typed that way to fast. ignore my incompetence.
Thread replies: 255
Thread images: 28

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.