[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: 32
File: mg_statistics_big.png (268 KB, 474x626) Image search: [Google]
mg_statistics_big.png
268 KB, 474x626
Statistics edition, now that we have done the calculus and linear algebra prerequisites

Old: >>55071499

>tfw will be coding awesome AI stuff after this /dpt/ edition
>>
All praise D
>>
>>55077774
Thank you brother
>>
how to be master at c/c++/c99 ?
>>
nth for Go has generics.
>>
File: 7608s.jpg (685 KB, 800x1036) Image search: [Google]
7608s.jpg
685 KB, 800x1036
Tomohiko Sakamoto's Algorithm

Determination of the day of the week

#include <stdio.h>

int dow(int d, int m, int y)
{
int t[] = {0,3,2,5,0,3,5,1,4,6,2,4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}

int main()
{
const char *days[] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};

printf("%s\n", days[dow(14 , 6 , 2016)]);
return 0;
}
>>
I like this manga guide trend. Better than faggot anime at least.

>>55077796
Only on built-in functions.
>>
>>55077823
Why not just use jQuery?
>>
>>55077840
>Only on built-in functions.
No.
>>
>>55077855
Explain. Inb4 interface{}
>>
>>55077861
interface{}
>>
>>55077761
What is the purpose of this code found it in a thread a few hours ago?
def numFSM(a):
state='e2'
if a == '':
print('nigger')
else :
a = a.split()
case0 = {i: 'e'+str(i) for i in range(0, len(a))}
#case1 = {#...}
#case2 = {#...}
while a :
for x in range(0, len(a)):
if state == 'e0':
state = case0[x]
print(state)
elif state == 'e1':
#state = case1[x]
print('case1')
elif state == 'e2':
#state = case2[x]
print('case2')
>>
>>55077870
Not type safe. Type assertion/switches are slow.
>>
>>55077871
finite state machine
>>
>>55077877
That's not the point. It has generics.
>>
>>55077884
Dynamic typing != generics
>>
>>55077878
ok, what language is this, never seen something like this:
{i: 'e'+str(i) for i in range(0, len(a))}
>>
>>55077917
Python dict comp
>>
>>55077902
interface{} can be abused as a generic.
>>
main(c){return c ? c*main(c-1) : 1;}
>>
>>55077917
isn't that the Python?
>>
File: karlie.jpg (81 KB, 600x566) Image search: [Google]
karlie.jpg
81 KB, 600x566
>>55077871
that code is fucking ugly
>>
>>55077960
Surely she must be pretending
>>
>>55077927
But it does not provide zero runtime cost type safe generics, which is what all other people except for you mean by generics.
>>
>>55077969
Wouldn't bet on it, there are many wannabe nerds/low-techs out there.
>>
>>55078003
>wannabe nerds
Why did nerdom ever become cool? I preferred it as a shunned hobby/profession.
>>
can i make a macro like this

#define FOO_0 (foo + 1)
#define FOO_1 (foo + 4)
#define FOO_2 (foo + 2)

#define FOO(X) (FOO_(X))


not sure about the syntax but i hope you get the idea
>>
>>55078105
>Why did nerdom ever become cool?

A lot of people started playing videogames, and because it was formerly shunned, it became cool to be a nerd.
>>
>>55078105
>>55078133
Thank god normies will stay away from muh InfoSec
>>
>>55078122
or do i need to store the values in an array in order to loop through them
>>
>>55078105
Nerdom as itself never really became cool, but somehow the idea that people who do edgy things, browse tumblr/reddit, can 'program' in html, use apple products and go to starbucks are nerds spread across society. I think thats why now everyone wants to be 'nerdy'.
>>
File: index0_vs_push_back.png (14 KB, 600x371) Image search: [Google]
index0_vs_push_back.png
14 KB, 600x371
Is Rust good or is it just a meme?
>>
Does anyone know of a site that gives you beginner "practice problems" in Java
>>
>>55078148

You just wait. Right now "dude programming lmao" is the maymay, but "dude security lmao" can't be too far around the corner.
>>
File: >watchdogs.png (310 KB, 849x436) Image search: [Google]
>watchdogs.png
310 KB, 849x436
>>55078148
Yeah, most people don't even know that this is a thing, but I'm a bit concerned about the amount of edgy 12yr olds playing this game and installing Kali Linux after it, thinking they are hackers.
>>
>>55078183
I'm blaming Jobs for this too.
>>
File: autism.gif (240 KB, 320x240) Image search: [Google]
autism.gif
240 KB, 320x240
>>55078207
also pay attention to the fucked up apt command
>>
What language to learn after Python?
>>
>>55078195
The hope here is that the required low-level knowledge will scare them away.
>>55078207
I'm sure they'll learn how to ddos like every other l33t haxx0r, but not much past that.
>>
>>55078229
F#
>>
>>55078229
C, asm , C++, perl, Lisp, prolog, there are plenty of good languages out there
inb4
> prolog
> good
>>
>>55078261
Probably they'll also find out about metasploit after a while.
>>
>>55078229
Go.
>>
File: lost.jpg (23 KB, 480x360) Image search: [Google]
lost.jpg
23 KB, 480x360
>>55078261
> tfw my interest in infosec, linux system administration and programing started like this.
>>
>>55078271
Why learn that instead of Haskell?
>>
This is right down my alley! I've been coding a regression analysis program, and it can calculate univariate and bivariate regression models. Two questions: One, how do I calculate r and r^2 values for bivariate models? And how do i calculate coefficients for a multivariate model (more than two)?
>>
>>55078381
F# is more friendly, Haskell is more punishing.
>>
>>55077737
>>55077792
>>55077862
>>55077926

Ok, I figured where my problem is, Top->next is NULL when called into the function despite the fact that normally it points to the second element of the list.
Can someone explain why?
>>
>>55078472
I like it hard and rough
>>
>>55078477
Pastebin the relevant code, I want to see how you're building your list
>>
>>55078491
Download GHC and read this every night before you sleep

https://wiki.haskell.org/Monad
>>
>>55078207
Could someone explain
>>
File: Programming Shelves.png (952 KB, 2100x1400) Image search: [Google]
Programming Shelves.png
952 KB, 2100x1400
>>
>>55078616
He tried to use apt-cache search to find all packages that involve BlumeDB and Marcus Hollaway. What he does instead is trying to read config file ache.
>>
>>55078510
Here
pastebin.com/4LnWZ7Q8
>>
>>55078158
You have these special preprocessor constructs with hashes... Try
#define FOO(X) FOO_ ## x

If it doesn't work, google some about the preprocessor.
>>
>>55078630
chuckled
>>
I cannot satiate my lust for LINQ
var foo = Directory.EnumerateFiles(@"C:\temp\folder\Folder1");
var bar = Directory.EnumerateFiles(@"C:\temp\folder\Folder2");


var baz = foo.Concat(bar.Where(x => !(foo.Select(y => y.Split('\\').Last()).ToList().Intersect(bar.Select(y => y.Split('\\').Last()))).Contains(x.Split('\\').Last())));
>>
Are any of these manga books any good?
>>
File: output.png (44 KB, 120x187) Image search: [Google]
output.png
44 KB, 120x187
Alright, lads. Going for 1000 triangles and 5000 candidates. This should produce a pretty convincing mona lisa.

This is one with 500/2000.
>>
>>55078653
>
    for(;;){
printf("%s\n",Top->word);
if(Top->next)
Top=Top->next;
else
break;
}

Pro: Now you know about the for(;;)
Con: That's surprising, and surprising things should be avoided in coding.

for(; Top->next; Top = Top->next)
printf("%s\n",Top->word);
>>
>>55078667
You should try Haskell or F#
>>
>>55078694
No. Though I did like the Database one.
>>
>>55078653
>>55078701

>
Elem = Elem->next;
Elem = malloc(sizeof(struct list));

lines 58-59

Think about it, about sequence and such. Your problem lies right here.
>>
File: my sides.jpg (41 KB, 573x313) Image search: [Google]
my sides.jpg
41 KB, 573x313
>>55077960
>bajs
>>
>>55078701
Wouldn't that not print the last string of the list?
Can I do something like (Top->next)->next?
Still, it doesn't solve my problem.
Thanks for your time btw man.
>>
>>55078696
Are you a fucking ant?
>>
>>55078788
It'd take longer if it were bigger
>>
>>55078796
For you
>>
>>55078761
>Wouldn't that not print the last string of the list?
No, it's a shortcut, 100% equivalent to
for(; Top->next; Top = Top->next) {
printf("%s\n", Top->word);
}

I assumed you knew that. The rule is that if there is only one statement in the loop body (or the if body for that matter) then you don't need braces to group statements together because there's only one. It's optional tho, put in braces for clarity and ease of editing if you want.

>Can I do something like (Top->next)->next?
It's possible and you don't need the paren pair, but where and why?

>Still, it doesn't solve my problem.
Yes I know

>Thanks for your time btw man.
You're welcome. Good luck
>>
>>55077761
holy crap, wasnt that on scholastic before
>>
Currently sprucing up my regex-based X12 parser. Pleased with how fast it is, but I can't help but feel like I will regret doing this.
>>
>>55078696
Post progress when done
>>
>>55078827
The loop stops when Top->next stops being valid (==NULL), which since Top=Top->next happens at the end of the loop, Top->next==NULL for the last string so the loop isn't executed for the last string.

>>55078754
Could you elaborate? Is there a problem when using malloc on NULL pointers? Should I set only the last ->next pointer to NULL out of the loop?
>>
File: print-church-at-auvers.jpg (67 KB, 300x380) Image search: [Google]
print-church-at-auvers.jpg
67 KB, 300x380
>>55078696
Do a van Gogh

van Gogh is pretty based
>>
Does anyone actually understand Makefiles?

I just copy and modify some example code
>>
>>55079005
Somewhat.
>>
>>55078979

I'll try that after this run. I'm on triangle 7 of 1000 and 15 mins of runtime so far.

This will take forever.
>>
>>55079005
This helped me; maybe you'll find it useful.
https://learnxinyminutes.com/docs/make/
>>
>>55079073
what's the algorithm? this seems like something you should be doing on the gpu with shaders
>>
Anyone else struggling to decide what to work on? I wish there was a repository for current /g/ projects to contribute to.
>>
>>55079183
somewhat, kinda deciding to do a project on js, that would be like a addon for a browser, not sure what to do though. What language are you going to base your project on, or plan to
>>
>>55078963
>The loop stops when Top->next stops being valid (==NULL), which since Top=Top->next happens at the end of the loop, Top->next==NULL for the last string so the loop isn't executed for the last string.
M8, I'm so busy parroting I don't even reflect! Yes you're right. It can be fixed EZly tho
for(; Top; Top = Top->next)

PriTop: Them CS boyz call the second part of a for, as well as the only part of a while, the /invariant/ for a reason: it is what will by construction invariably be true in the body of the loop. So if you express precisely what you *want* from the loop --- that i is strictly inferior to ARRAY_LENGTH otherwise I'll overflow my array, that Top isn't NULL otherwise I'll dereference it, but
Top->next
is fine, I won't dereference it in this iteration --- then your condition is the good one. Obviously I failed at my own advice tho.

>Could you elaborate? Is there a problem when using malloc on NULL pointers? Should I set only the last ->next pointer to NULL out of the loop?
No, malloc doesn't even know you're assigning its result on a formerly NULL pointer, it doesn't care. No, outside of the loop would be already too late.

I'll give you this to chew on: it's not only with the last node that there's a problem. With this example program, we have an irregularity already on the second node.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

struct list {
/* ... */
struct list *next;
};

int main(int argc, char *argv[]) {
struct list *Top = malloc(sizeof(struct list));
Top->next = NULL;
struct list *Elem = Top;
for(int i = 0; i < 10; i++) { // create 10 nodes because why not
Elem = Elem->next; // your two lines
Elem = malloc(sizeof(struct list));
Elem->next = NULL;
}
assert(Top->next != NULL); // this assertion fails, and it's related to the second node (or rather the first node, depends)
}

Why does this happen?
>>
>>55079183
no
>>
>>55079140

For a total number of triangles, generate a bunch of candidates. Select the one which produces the lowest error value and apply it to the canvas.
>>
>>55079196
I was also thinking JS or Golang, what do you have in mind?
>>
>>55079251
What kind of genetic algorithm?
>>
>>55079075
# Warning - only use TABS to indent in Makefiles, never spaces!


wat
>>
>>55079301
it does not sound like a GA.
>>
I found all the manga guides in a single zip!
http://rg-gosset.co.uk/files/mangaGuides.zip
>>
>>55079319
>generate candidates
>select the best and apply it
>>
>>55079301

GTP's own™
>>
>>55079317
wat what? Makefiles require tabs.
>>
>>55079349
that is not GA. in GA you don't even generate new candidates other than initial ones
>>
>>55079382
Yes it is
https://en.wikipedia.org/wiki/Differential_evolution
>>
>>55079395
The page you post says nothing about GA. I think you are mixing GA with evolutionary algorithms.

the algorithm he tells looks more like a hill climbing to me
>>
>>55079426
Differential Evolution is a genetic algorithm
>>
>>55079461
*
Apparently it's not, but it definitely seems like one and appears odd it isn't considered to be one
>>
>>55079199

Ok, I think I figured it out.

Top->next is NULL even in the main function, despite the fact the list is created normally.

I think this happens because I use the Elem pointer to create the list.

/*the Top pointer is created here*/
Elem=Top;
while(...){
Elem=Elem->next;
/*...*/
Elem->next=NULL;
}


I don't think Top->next is connected to the second node, anything else is connected because the Elem pointer is used for all of them.

I'll test it a bit.
Thanks again man, you really helped me a lot.
>>
>>55079476
he is just doing a hill climbing. he has a single solution and iteratively improves it by using best of 1000 triangles
>>
>>55079518
But hill climbing could stop at local maxima
>>
How can i make a trully peer-to-peer chat system? Would i have to boardcast via multicast for discovery?

what is the current going best encryption for end to end chat systems? RSA variant?
>>
I decided to run the van gogh one at the same time, since it won't make much of a difference.

Resized it to 195x247 and doing 1000/2000.
>>
>>55079504
>Thanks again man, you really helped me a lot.
You're welcome. You're almost there. I'm going to bed now. May the Force be with you.
>>
>>55078477
are you CS? if you cant write a linked list on such a huge time, you should switch courses
>>
>>55079562
I cant answer the first one

but for the second i know for standard encryption its 256 bit, rsa high end would be 4096. Signal i know is a fairly good for messenging, it uses 256 if that helps
>>
>>55079704
or he ahould stop running from his problems and solve them and learn from it
>>
>>55079005
output: input
command to create output from input

what the fuck is there to understand?
>>
>>55079562
multicast outside of local networks is almost guaranteed to be dropped unless you pay some prekium to your ISP.
>>
File: 1383518116213.png (430 KB, 625x480) Image search: [Google]
1383518116213.png
430 KB, 625x480
>applying for local software engineering positions in my city
>8 jobs
>mfw 7 of them declined without a phone interview
> I talk with human resources about some job statuses after 1-2 weeks
>within an hour get back more declines

I don't know what I did senpai.
>>
>>55080207
post CV / github
>>
>>55079183
Almost all I work on is a realtime imageboard and related libraries. It's a big enough project, so there is always something to do. If you know Go or JS and are bored enough, I can link the repo. Contributions are welcome.
>>
I have a new laptop for development purposes. I have created a script, winclang, for cross compiling to Windows from clang. It looks like this:

#!/bin/bash

clang -target x86_64-w64-mingw32 -I/usr/x86_64-w64-mingw32/include -L/usr/x86_64-w64-mingw32/lib -L/usr/lib/gcc/x86_64-w64-mingw32/5.3-win32 $@


It's an ugly hack.
>>
Why I can't do this in Python when something is passed as a closure to reduce?

n = 0
def something(x, y)
if n < 10:
pass

n = n + 1


It basically says n is undefined.
>>
>>55080344

is n defined as a global?
>>
Coding a free Minitab alternative, anyone know how to calculate multivariate regression coefficients?
>>
>>55080344
The pass statement is a null operation; nothing happens when it executes. The pass is also useful in places where your code will eventually go, but has not been written yet.

you probably want
 continue 
>>
anyone here ever try to download pics from instagram?

they haev some sort of a barrier that prevents me from even getting the links
>>
>>55080344
because python is a shitty language
>>
>>55080380
*tips fedora*
>>
>>55080363

>>55080344

hey you need to add this line above your for loop:

global n

that should fix it so n is defined.
>>
>>55080344
n = 0
def something(x, y)
global n
if n < 10:
pass

n += 1
>>
>>55080363
>>55080400
Ah, I get it, but when I change to global n it still says it's referenced before assignment.

>>55080367
That's not the issue I just replaced the actual code with pass here because it's a long snippet of code.
>>
>>55080269
Sure why not! I'd love to contribute.
>>
>>55077761

link for that pdf?
>>
>>55080444
https://github.com/bakape/meguca
>>
made this thing to get a little more familiar with Go
http://shitpostgen.herokuapp.com/

it goes through /g/ posts and then later generates text from them using markov chains
>>
>>55080420
>Ah, I get it, but when I change to global n it still says it's referenced before assignment.

I don't know python very well, but it most likely is due to n+= 1 since it involves assigning a value.

maybe change it to n = n + 1?
>>
>>55080566
this is your average python programmer /dpt/
>>
>>55080527
http://www.pdf-archive.com/2015/04/27/manga-guide-to-statistics/manga-guide-to-statistics.pdf
>>
>>55080600

thanks.
>>
>>55080564
>muh newfags go into destroying the white belkin strip, 1W wifi mikrotik routerboard. I blame women who don't know a non-ugly way to make games run worse on AMD not being retarded? If yes, very unimaginative though. Just let this shit to explode. Distribution review anon's I, you will DIE! Too tend keys lame my o still front anyone in here have experience in buying xiaomis on ali? With the kernel, which format is best, lower price. Especially removing MagSafe, if anyone would ever want to drop support of el Capitan takes up a strong signal from my colleague's PC, instead they generate html code from the FSF. that's why we laugh at console peasants and AMDrones. Usually >break into major website or company's servers >dump many, but in Australia, it uses the global menu bar. Why Mega have to regrap your mouse. That is made for using modern components. A watch a livestream on youtube. You don't hear anything then it's alright like that AP >mfw 7 of them look good, shit.
>>
File: 1454911774398.jpg (100 KB, 800x568) Image search: [Google]
1454911774398.jpg
100 KB, 800x568
>>55080590

you fix it then bitch
>>
>>55080527
Here's all of em
>>55079346
>>
>>55080539
>https://github.com/bakape/meguca
>High performance real-time imageboard in Meme, MemeScript and MemethinkDB https://meguca.org/a/
>>
File: 1432414650098.jpg (22 KB, 373x434) Image search: [Google]
1432414650098.jpg
22 KB, 373x434
>don't program for months
>forget how to even do basic shit
>>
>>55080539
Done! Will contribute as i understand it.
>>
>>55080630
there is nothing to fix. other than introducing an explicit way to declare your variables. python pays hard for allowing not to declare variables
>>
>>55080660

Thanks, but I'll have to wait for better connection, to download all of them.

I have yet to load the Statistics one alone.
>>
>>55080673
*tips fedora*
>>
Keep your pedo cartoons in /a/ you filthy weeaboo
>>
>>55080673
Do you only use COBOL, CGI and text files?
>>
File: 1449431590419.jpg (23 KB, 604x604) Image search: [Google]
1449431590419.jpg
23 KB, 604x604
>>55080681

that's me but I'm doing job interviews now. Praying I can make it past whatever interviews I get.
>>
>>55080727
can you reverse a binary tree?
>>
>>55080805
with my eyes closed.
>>
>>55080564
Nice anon. Ramp up the racism and it could sound like something Terry Davis would come up with.
>>
>>55080564
where can i find a nice introduction to markov chains and applied them to programming?

some implementation in python would be nice.
>>
>>55080710
Nope, I use Arc and JavaScript for all my web projects.
>>
>>55080892
>python
>>>/reddit/
>>
>>55080897
you're already in reddit
>>
>>55080897
>>>/out/ you fucking virgin NEET
>>
>tfw coreclr is still half-broken on Linux
>dotnet cli utilities depend on libicu52
>won't work with libicu55
>>
Rumours point to above 390x performance, but this has happened pretty much everything is just that they just have extensions on chrom/ium with military tutorials if options of things we don't pay taxes on online purchases from overseas :p the feel I it life at Euro
where the hell do you dislike a suggestion? Could you give us cooler gaymen laptops.
>buh- *crying*
>no Gpu
>buy R9 280 for 200 Euro
>Buying the 480 kind of IRONY WITH A 3GB GPU? What rom? For how ridiculously expensive, you treat it like you should then move this file off the Nvidia Gpu and only turns on when I eventually bought from here: can probably be true though, anon? Looks lovely $200 I will put you out a decent performer for my hackintosh config, I probably just should've gone for college and I'd like something you would never want to replace anything. I usually go with 1080/1440p depending on how well the with Crt don't than if legit company same the in mutually all, there's a need for brand new. Pics incoming. $80 paypal?
>>
>>55080920
python will get you nowhere outside of web dev and making half-broken reddit scrapers
>>
>>55080951
what do you suggest then?
>>
>>55081040
java and/or C++
>>
>>55081046
and do what with those languages? suggestions?
>>
>>55080951
>python will get you nowhere outside of web dev and making half-broken reddit scrapers

just ignore this anon, I've used python libraries for nuclear engineering simulation and deep learning. It's one of the most commonly used languages and a hell of a lot better than javascript for learning
>>
>>55078630
The unicorn is magical and it can summon perfect bookshelf.
>>
>>55081122
make games
>>
How do I properly use rand() in C?

I'm using rand() % to + from, but it doesnt seem to work with negative numbers
>>
>>55081150
It's used for plugins and scripting in GIS type work as well if you're into that.
>>
>>55081190
num = (rand() % 2) ? num : -num;
>>
>2nd year pol sci phd here

What do you guys use for the usual stuff in CS? frequentist or bayesian?
>>
>>55081190
Use arithmetic
>>
>>55081190
>How do I properly use rand() in C?
By not using rand() because it's garbage and is not uniformly distributed.
>>
>>55081190
>How do I properly use rand() in C?
>I'm using rand() % to + from, but it doesnt seem to work with negative numbers


you should use a prime modulus multiplicative linear congruential pseudo random number generator
>>
File: brogram.png (60 KB, 800x800) Image search: [Google]
brogram.png
60 KB, 800x800
which language is better for game dev, c or c++?
>>
was the C++ 'auto' type a mistake?
>>
>>55081534
c++
>>
>>55081534
C++, it is just as fast C when you know what you are doing. Has enough abstraction to tidy things up and probably will have better library support.
>>
>>55081534
>no *lisp
>brogram

normie shit die
>>
>>55081555
it's great when the type can be easily deduced from the right side of the expression, saves a lot of typing and redudancy, even better when working with heavily templated code
>>
File: sbahj_high.jpg (21 KB, 340x292) Image search: [Google]
sbahj_high.jpg
21 KB, 340x292
>>55081569
>2016
>caring about lisp
>>
>>55081555
It is golden when using data structures with templates and trying to use iterators with them.
>>
>>55081534
C++

it can work with C libraries the same way you would in C.

Using classes as resource handlers is great.

OOP is trash tho
>>
>>55081566
>better library support

you can literally hook anything into C
>>
How do I get around C's lack of namespaces?

No I can't simply use C++.
>>
>>55081606
proper use of header files and variable/function naming as follows

headername_thing()
headername_thing2

I wish C would add simple things like namespaces ;~;
>>
>>55081606
you put "_namespace_" before everything and call it a day
>>
>>55081595
Yeah, I was thinking of doing that (I already have a display engine in C but nothing else yet) just for vectors and classes and ignoring the shit like templates, etc that I don't need; I kind of enjoy the challenge of working with C tho.
>>
>>55081596
what ever you can do in C, you will be able to do in C++ plus you will easily use C++ libraries.
>>
>>55081636
>shit like templates
you take that back
>>
>>55081636
>uses std::vector
>does not use templates
I think you should stick to C
>>
>>55081636
I started with C as well since I really wanted to learn low level stuff like assembly and proper memory management. Then, I learned that you can do all of that in C++ with extra shit that is convenient.
>>
Gnumake, cmake, gradle or ??? for building c/c++ projects ?
>>
>>55081190

rand() generates a random integer number between 0 and RAND_MAX.

The modulo operator performs integer division on two numbers and returns the remainder. If you have some number x modulo k, the result is always going to be between 0 and k-1 inclusive.

Combining these two, we can generate a random number between 0 and k-1 with rand() % k, giving us k possibilities. If I wanted a custom range, I would consider the first number in the range and the number of numbers in the range. So for instance, if I wanted something between -2 and 5, I would know that the range contains the numbers { -2, -1, 0, 1, 2, 3, 4, 5 }, and therefore a modulus of 8 should be used. If I call rand() % 8, I will get a number between 0 and 7. Subtracting 2, and I get a number between -2 and 5.

The problem with your formula is that you think the modulus necessarily represents the end of the range, when it is actually the number of numbers in the range. If you want to get a random number in the range a..b inclusive, let k = b - a + 1, and use rand() % k - a.

That said, I would note that rand() likely won't give you perfectly even odds, especially with a modulus. If your RAND_MAX == INT_MAX == 2147483647, which is a not too uncommon case, then modulus that are a power of 2 will not affect the odds, but any other power will lead to something a bit off. Let's consider you want a number between 1 and 6. Well, in the range of 0 .. 2147483647, how many numbers have each modulus? Well, 2147483647 % 6 == 1, so that means the last two numbers in this range have about 1 higher count than the rest, giving these modulus counts:

0: 357913942
1: 357913942
2: 357913941
3: 357913941
4: 357913941
5: 357913941

Not exactly something I'd use in a casino, but maybe acceptable for D&D?
>>
File: ml68k.png (4 KB, 84x128) Image search: [Google]
ml68k.png
4 KB, 84x128
Here is mine http://b.1339.cf/egmktco.webm (skip to the end to see the final result).
Adaptive mutation rate helped a bit.

Still, could be better. This should not take 68k generations.
>>
>>55081693
Templates r dum and working with """flexible array meme-bers""" is annoying & you're restricted to 1 per struct
>>
>>55081778
>templates r dum

let me just define a nice polymorphic type:
int_vector
double_vector
char_vector
longlong_vector
wchar_t_vector
obj1_vector
obj2_vector
obj3_vector
...
obj15815_vector
>>
>>55081745
that looks horribly inefficient. it basically zeroes every triangle then hopefully ones better results by purely random mutations.

I believe your background being black makes it worse. if there is no triangle, black is closer to original pixel so your triangles moving there gives worse fitness value most of the time. maybe not having a triangle should be worst fitness for that pixel
>>
>>55081778
I don't get what you are saying. You are not restricted 1 template class. templates enables you to reuse your code with no overhead. and they let you do much more than "flexible array meme-bers", whatever that exactly means
>>
>>55081813
I think this is an issue with my alpha-blending implementation.
I think it promotes too much coadaptation of triangles early which gets increasingly hard to untangle later when algo could use more of them. This picture is not the easiest one, for sure.

Still I'm going to refrain from tweaking the fitness function and GA just to help this concrete case, because I'm interested in GA that can achieve good performance on a variety of tasks.

This mona lisa imitation task is just a benchmark for me.
>>
So, I want to make a program that will draw a bunch of different fractals, where there will be a menu where the user can choose what kind of fractal, then they can input a number for the size of the fractal. I'm trying to do it in Java, because I haven't used it in a year.
Right now I just have this to get familiar with how Java's graphics works, it just draws garbage now:
import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Color;
public class drawing extends JFrame
{
public static void main(String[] args)
{
drawing a = new drawing();
a.setVisible(true);
}

public drawing()
{
super("Fractal Generator");
setSize(1000, 1000);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setBackground(Color.white);
}

public void paint(Graphics g)
{
super.paint(g);
int x = 1000;
int y = 250;
while (x > 2)
{
g.drawOval(y, y, x, x);
x *= 0.8;
y *= 1.1;
}
}
}


What I don't understand is how is paint called? The book I have just says, "The method paint is called automatically, and you normally should not invoke it in your code." I want to invoke it though, so that I can have the method signature be:
public void paint(Graphics g, int x, int y)

So that I can recursively call paint, where x and y are getting smaller, and also so that the user can input what x and y will be.
>>
>>55081859
I don't know, with your background being black and picture mostly being black, your triangles will converge to a small area since fully black picture is a pretty good local optima and it is easy to get there. after that you will hope that mutations save you from there.
>>
>>55081886
>uses swing
you should probably hang yourself
>>
>>55081950
(You)
>>
>>55081932
I see this as an interesting challenge to design the GA that is good at getting out of local maxmas.
Also I will try it with other images.
>>
Let's try Nep!

node evolve_image.js nep_nep.bmp 
MODE: LOCAL, SERIAL
Approximating image "nep_nep.bmp" : 175 x 204 px with 50 triangles
GA started
No initParams given to GA
No copyGenome function given. Using util.clone
Using default serial task executor, pass executeTasks in config to override
No PRNG class given, using Math.random as random source
Start
Fitness evaluation time: 3.430s
Mutation Rate [+]: 0.10500000000000001 parentFit: -10000000000 Nbetter: 600 pop: 600
>>
File: 1463949823658.jpg (97 KB, 480x604) Image search: [Google]
1463949823658.jpg
97 KB, 480x604
>tfw your 6 core CPU allows you to do 4 concurrent genetic algorithm experiment runs easily

>tfw sit and relax while the computer does all the hard work
>>
>>55082228
post code
>>
>>55082268
Later.

Also it's not even hard to code it yourself from scratch in any fast language.
>>
guys, whats the most convenient framework to parse HTML i can use?
i dont want to write a couple hundred fucking lines of code just to scrape a few images
>>
>>55082353
https://github.com/cheeriojs/cheerio
>>
>>55082353
>parsing a non-regular language
>>
>>55082353
https://github.com/lazytiger/gumbo-query
>>
I want to make myself more valuable for the job market. Should I learn C# or Android development?
Also, I'm more of a Linux user. How likely is it i will have to deal with Windows Server as opposed to RHEL? I dont come from a huge city, this place is more "traditional" and backwards, so im afraid companies probably use Windows Server here. im planning to move to virginia though (which might be even more backwards)
>>
>>55082435
>I want to make myself more valuable for the job market.
Learn Java, C, C++ and C#

anything else is a meme
>>
>>55082395
what do you suggest? i just want to download and get a list of URLs from a webpage

>>55082386
anything that isnt javascript?

>>55082428
>C++
pls no, i said i dont want to waste time writing trivial code
>>
How many of the programming projects out of my programming book should i do each chapter to be sufficient?
>>
>>55082454
>plz no js
>plz no C++

What do you want then lol?

Personally I have used cheerio a huge lot, I parsed millions of pages with it. It is nice.
>>
>>55082461
All of them.

Even if you think you're capable of them already, you should attempt them.
The hardest part of learning programming isn't syntax, it's learning how to write solutions in a computational way.
Literally, boiling down your logic so a dumb adding machine will understand it.
>>
>>55082461
8
>>
>>55082461
if you have to ask then all of them
>>
>>55082353
BeautifulSoup
>>
>>55082435
>How likely is it i will have to deal with Windows Server as opposed to RHEL?

Extremely unlikely.

It is likely you will work with ubuntu server though, it has became a standard OS for the cloud instances.
>>
>>55082474
something that isnt js and isnt a massive pain in the arse to do anything with like C++ is
>>
File: Capture.png (10 KB, 572x146) Image search: [Google]
Capture.png
10 KB, 572x146
there goes the dream, lads
its been a good run
>>
>>55082480
>>55082487
I'm just dumb so they take me a long time, but I guess I'll just keep truckin
>>
>>55082515
Why does wikia even exist?
Their abomination of a wiki software is so shitty compared to mediawiki.
>>
File: into_the_light.jpg (13 KB, 700x700) Image search: [Google]
into_the_light.jpg
13 KB, 700x700
>nobody to do cool machine learning bullshit with

Would anyone be up for doing some sort of computer vision of NLP project over Tox?

Here's a simple Seq2Seq implementation I made for shits once:
https://github.com/adamchanson/seq2seq
>>
>>55082526
When i started, I literally spent 5 hours trying to write fizzbuzz without looking it up.
>>
>>55082535
Seq2seq is very impressive, anon

though I'm not into tox

/g/ has rare AI general threads, you can post there
>>
>>55082353
despite people going apeshit when you mention html and regex in one sentence, if all you need is a simple dirty script to get a bunch of images it'll do just fine
>>
>>55082535
i eventually want to learn AI/CV/machine learning but i'm still trying to get the basics down pat.
just wrote my first simple parser
>>
>>55082545
Thanks man that's actually pretty reassuring
>>
>>55082534
idk, it's actually quite detailed for what I'm using it for

I was thinking though, this is more of a legal question.

All of their content is available on the net. Their terms say you can't scrape their site, unless you go through their API. Their terms also say if you want to use their API for commercial use you need approval.

However everything is legally licensed under http://creativecommons.org/licenses/by-sa/3.0/, which gives me the right to commercially distribute anything I get from the site. So if I violate their terms of service, do I not have the right to distribute all the text I've scraped?

I think I might be able to circumvent everything if I say I have manually copied all of the text, lel.
I think I'll still give it a try...
>>
>everything works on desktop
>rsync to server
>blows InterruptedException
Is there any way to figure out what interrupted a thread? It doesn't seem like there is one, but this is driving me nuts
>>
>>55081697
SCons
>>
>>55082656
til it breaks and you spend 8 fucking hours trying to figure out whats wrong with it
>>
>>55082474
>Personally I have used cheerio a huge lot, I parsed millions of pages with it. It is nice.


can you explain in layman's terms what is cheerio exactly for?


what can you do with it?
>>
>>55082754
Well gee, I can guess pretty good when I have no clue what you're doing.
>>
>>55082228
>CPU multithreading
>not doing your parallel computations on GPU
Go to bed grandpa
>>
>>55082880
I meant more generally, though to be specific, I'm putting together an application with Spring Data Couchbase on an OSX localhost and moving to a server running Ubuntu; the issue appears when using a repository implementation produced by a repository implementation factory (since I'll be deploying to an OSGi environment, registering it as a bean in a Spring Boot context would do me little good)
>>
>>55082929
>>55082228
I hope you're at least using SIMD extensions.
You can make your code at least 4x faster without resorting to cheap tricks like multithreading.
>>
>>55082861
node
> var cheerio = require('cheerio')
undefined
> var myHttpResponse = '<body><div class="important">important data</div></body>'
undefined
> var $ = cheerio.load(myHttpResponse)
undefined
> $('.important')
{ '0':
{ type: 'tag',
name: 'div',
attribs: { class: 'important' },
children: [ [Object] ],
next: null,
prev: null,
parent:
{ type: 'tag',
name: 'body',
attribs: {},
children: [Object],
next: null,
prev: null,
parent: null,
root: [Object] } },
options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xmlMode: false,
decodeEntities: true },
_root:
{ '0':
{ type: 'root',
name: 'root',
attribs: {},
children: [Object],
next: null,
prev: null,
parent: null },
options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xmlMode: false,
decodeEntities: true },
length: 1,
_root: [Circular] },
length: 1,
prevObject:
{ '0':
{ type: 'root',
name: 'root',
attribs: {},
children: [Object],
next: null,
prev: null,
parent: null },
options:
{ withDomLvl1: true,
normalizeWhitespace: false,
xmlMode: false,
decodeEntities: true },
length: 1,
_root: [Circular] } }
> $('.important').text()
'important data'
>
>>
>>55082861

I had a really specific use for cheerio. I was making a multiplayer game that stored the game state on the server in XML, and then rendered the same XML as HTML in the client for "graphics". It's a weird game based around binary trees.
>>
File: plot_4.png (2 KB, 640x480) Image search: [Google]
plot_4.png
2 KB, 640x480
>>55082964

I don't. The code is probably 6x slower than equivalent C++, but I can rewrite it in C++ in any moment.

I am writing it in high-level language to prototype the algorithm, it has a lot of non-trivial details like mutation schedule (see picrelated for example) etc.
I would waste a week writing the same things in C++.

Once I settle for a solution that satisfies me I will rewrite, though I could just rewrite only 5% of hottest functions though.

Writing research-tier software in C++ === cucking yourself.
>>
>>55082982
?
>>
>>55082929
My Nvidia Thermi unironically fried itself ;__;
>>
>>55083031
>Writing research-tier software in C++ === cucking yourself.
I'll accept this, it's not a language for prototyping. You doing this in Python or Lisp or something?
>>
>>55083031
If you were actually proficient in C++, you could write the entire thing in C++ the first time without wasting effort.
>>
>>55083037
he's demonstrating cheerio use from uses of nodeJS in bash
>>
>>55083076

plz don't shill for C++, I won't fall for the meme
You can never stop thinking about containers, types, references, static classes while writing your algo in C++. If you internalize all this bookkeeping bullshit in your head there will be less place for algorithms and math.
Then your start debugging and you hit segfaults and memory leaks..

C++ is bad language for exploratory programming, nobody in science/engineering uses it directly. Everybody uses matlab and scientific python, then falls back to C/C++ only when necessary. There is reason behind such order of things.
>>
>>55083077
so he parsed an html website?

so confused
>>
File: hmmm.jpg (21 KB, 393x360) Image search: [Google]
hmmm.jpg
21 KB, 393x360
Isn't there a quicker and prettier way to add or modify an object in a database without creating a ton of variable to create that said object ?

for example this shit. I feel that it's retarded because of the number of variable I created


String nom = JOptionPane.showInputDialog(this, "Entrez le nom", "Nom",JOptionPane.QUESTION_MESSAGE);
String prenom = JOptionPane.showInputDialog(this, "Entrez le prenom", "prenom",JOptionPane.QUESTION_MESSAGE);
String adresse = JOptionPane.showInputDialog(this, "Entrez l'adresse", "Adresse",JOptionPane.QUESTION_MESSAGE);
int idVille = Integer.parseInt(JOptionPane.showInputDialog(this, "Entrez la ville", "Ville",JOptionPane.QUESTION_MESSAGE));
Employe emp = new Employe(nom, prenom, adresse, idVille);
boolean bol = daoEmp.insertEmploye(emp);
if (bol == true)
{
JOptionPane.showMessageDialog(this, "Ajout de l'employé confirmé", "Confirmation", JOptionPane.OK_OPTION);
}
else
{
JOptionPane.showMessageDialog(this, "Erreur pendant l'ajout de l'employé", "Confirmation", JOptionPane.OK_OPTION);
}

>>
>>55083202
>confused

IF YOU WON'T HAVE BREATHING REFLEX YOU DIE

IF YOU WON'T HAVE GOOGLE REFLEX YOU WON'T LEARN ANYTHING EVER
>>
>>55083158
You sound like a fucking moron, and you're basically admitting that you know nothing of the implementation details of your shitty algorithms, nor do you care to learn that your MATH doesn't exist in a vacuum.
The computer doesn't give a shit, you need to boil down your logic to a dumb adding machine if you want any semblance of performance.
>>
>>55083242
I know/have written code in assembly (not only for x86, son), C, C++ and a host of other languages.

I'm an adult, I value my time, thus I write the prototype of my code in javascript (which can be thought of as a dynamic functional jit-compiled C with garbage collection).

"Write everything in C++" sounds like a religious-ish teenage attitude to me.
Adults choose the right tool for the task and are not afraid to use several tools in one task.
>>
Best resource for learning Java and Swing?
>>
>>55083242
Don't you have some Fizzbuzzes to write?
>>
>>55083316
see >>55081950
>>
>>55083242
Of course he doesn't know the implementation details because he's designing the algorithm.

pajeet pls go and stay go
>>
>>55081534

both
>>
>>55083214
Different language and maybe different database.
>>
File: 3.jpg (204 KB, 640x640) Image search: [Google]
3.jpg
204 KB, 640x640
i feel like there are no ideas left for me, and everyone else has the good ones.
i know it's irrational but i'm demotivated. how do i stop being blinkered like this?
Thread replies: 255
Thread images: 32

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.