[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: ew.png (389 KB, 934x1000) Image search: [Google]
ew.png
389 KB, 934x1000
What are you working on, /g/?

Old thread: >>52130349
>>
Same question I posted in the prior thread: should I bother learning Lisp, or should I stick with something more conventional?
>>
File: checkem.png (41 KB, 965x476) Image search: [Google]
checkem.png
41 KB, 965x476
Daily reminder that comments and whitespace slow down compilation and aren't ever necessary
>>
https://github.com/gentoomen/bhottu/blob/master/modules/threadsearch.py

Rate my 4chan thread searching function

>>52134204
Do both. Lisp might be good for you as a programmer. Other languages will be useful in the industry etc.
>>
>>52134206
forth for forth
>>
how i get started with web developing in 2016?
>>
>>52134225
Learn C or C++ and then compile your code to asm.js using Emscripten and LLVM.
You don't have to learn a messy weakly typed language just to write web applications, and they'll run much faster because there's no automatic garbage collection.
>>
>>52134206
hard to imagine what you're trying to shill here, but lexing is a minor phase computationally.
>>
#include <stdio.h>
#include <stdlib.h>

#define ROUNDS 1000000

static inline void seed_rng() {
unsigned int seed = 0;
FILE *fp = fopen("/dev/random", "rb");

fread(&seed, 1, sizeof(unsigned int), fp);
srand(seed);

fclose(fp);
}

static inline void iterate_until_dubs(int *attempts, int *dubs) {
*attempts = 1;
while ((*dubs = (rand() % 100)) % 11)
(*attempts)++;
}

static inline double average(int *array, int array_length) {
register int sum = 0;

for (register int i = 0; i < array_length; i++)
sum += array[i];

return ((double) sum / array_length);
}


int main() {
int attempts_count_array[ROUNDS] = {9};
int dubs_array[ROUNDS] = {0};
double avg = 0.0;

seed_rng();

for (int i = 0; i < ROUNDS; i++) {
iterate_until_dubs(&(attempts_count_array[i]), &(dubs_array[i]));
printf("[%d] Attempts: %d dubs: %d\n", i, attempts_count_array[i],
dubs_array[i]);
}

avg = average(attempts_count_array, ROUNDS);
printf("Average attempts: %2.43f\n", avg);

return 0;
}


This was a really basic dubs simulator I wrote in C. I improved on it, but the improvements are on another machine
>>
>>52134253
sounds quite complicated, there are some libraries to help w/ web development?
>>
>>52134303
Yes, but they all seek to do the same thing, more or less.
Typescript, coffeescript, etc, all compile to javascript because javascript is so shit.
asm.js lets you avoid that
>>
>>52134303
There's a thread for that!

It's not this one.
>>
File: 452.gif (705 KB, 500x500) Image search: [Google]
452.gif
705 KB, 500x500
How do I learn how to regex senpai?
>>
>>52134206
You've inspired me to add a dubs checker to my 4chan analytics project. I dont record the number of dubs because I frankly dont care:
dubs :: Board -> [Int]
dubs b = filter (\x -> isDubs x) $ map P.no (b >>= posts )

isDubs :: Int -> Bool
isDubs x = case (digs x) of
x:y:xs -> x == y
_ -> False

-- convert number to list of digits
digs :: Integral x => x -> [x]
digs 0 = []
digs x = x `mod` 10 : digs (x `div` 10)

recordDubs :: MonadWriter [String] m => Board -> m ()
recordDubs board = do
let ds = map show (dubs board)
tell ["Found " ++ show (length ds) ++ " dubs:"]
tell [unlines ds]

doAnalysis :: BoardID -> Chan ()
doAnalysis boardid = do
board <- getBoard boardid
recordMemes board
recordCount board
recordPosts board
recordDubs board
>>
>>52134322
That thread is a meme, don't fall for it.

Webdev is ok here as long as you're not asking about HTML or CSS.
>>
>>52134329
Go to the wikipedia page for regexes.

It's actually really easy.
>>
>>52134322
discussing web development in here is ok so long as you're programming in a real programming language and then compiling to javascript as an intermediate language
>>
ascii raymarch dude here
I'm bored again
>>
>>52134337
Or because state in haskell is a pain
How do you tell if it's a magic dubs thread?

>>52134329
It's really easy once it clicks with you
>>
>>52134271
>Opening /dev/random to seed your PRNG
>Not just using /dev/urandom as your PRNG directly
>>
extern crate rand;

use rand::random;
use std::vec::Vec;

fn roll_dice(n_dice: i32, n_sides: i32) -> Vec<i32> {
let mut results: Vec<i32> = Vec::with_capacity(n_dice.clone() as usize);
for idx in 0..n_dice {
results.push(i32::abs(rand::random::<i32>() % n_sides) + 1);
}
return results;
}

fn have_yahtzee(dice: &Vec<i32>) -> bool {
let mut previous_die = dice[0];
for die in dice {
if *die != previous_die {
return false;
}
previous_die = *die;
}
return true;
}

fn main() {
let n_dice = 5;
let n_sides = 6;
let n_attempts = 1000;
let mut yahtzee_value = 0;
let mut n_rolls_in_attempt = 0;

for iteration in 0..n_attempts {
n_rolls_in_attempt = 0;
loop {
n_rolls_in_attempt += 1;
let mut results: Vec<i32> = roll_dice(n_dice, n_sides);
if have_yahtzee(&results) {
yahtzee_value = results[0];
break;
}
results.clear();
}
println!("{}: {} rolls. Yahtzee value {}", iteration, n_rolls_in_attempt, yahtzee_value);
}
}


Instant yahtzee simulator in Rust
>>
>>52134402
I used to do that, but it's too slow and inefficient.
>>
>>52134402

Yeah this.. wtf?

If you're going to use rand() you might as well not bother with a secure seed in general.
>>
Other than dubs checker, what can I do for a meme project using 4chan json?
>>
>>52134429
Do you not care about the quality of your random numbers?
Actually, you've already made your code non-portable. You may as well use lrand48 or something.
>>
>>52134441
Do like this >>52134222

A thread searcher that searches threads on a board by regex, and returns matching post URLs
>>
>>52134412
what language is that
>>
>>52134441
word counter
download all images in a thread
>>
>>52134462
It literally says it in their post.
>>
>>52134389
>state in haskell is a pain
come now, I'm sure you can figure out how to carry state with only pure functions. Regardless - in this case, we dont even need state. Recursion can do it for us. (You know this. Your program does it with Array.fold - a pure function that carries state.)
>How do you tell if it's a magic dubs thread?
there's no such thing as magic, anon
>>
File: uh.jpg (49 KB, 1280x720) Image search: [Google]
uh.jpg
49 KB, 1280x720
Is it autistic if I hate using third party libraries and I want to make everything myself from scratch?
>>
>>52134429

You broke something.

The only thing that could be called "slow" is using /dev/random, because it can block.

$ time dd if=/dev/urandom bs=128K count=1024 of=/dev/null
1024+0 records in
1024+0 records out
134217728 bytes (134 MB) copied, 10.8394 s, 12.4 MB/s


134MB in 10s? How much entropy do you need for your app?
>>
>>52134458
You mean like if I try daily-programming-thread as a regex pattern, it looks for it in the threads json file, and then opens it up in a browser if found?

>>52134463
download all images sounds nice. Might use it for /fit/ breh threads, /wsg/ y(love)yl threads or wallpaper threads

Someone did word counter already
>>
>>52134463
heh, my bad. i was pondering the code and didn't read the post.
>>
>>52134222
2/10, needs more threading.
Now the entire bot freezes while you're running the search.
>>
>>52134484
No, but you're going to have to bite the bullet eventually and learn to embrace 3rd party libraries because they save you so much time, holy shit.
>>
>>52134484
I think an autist could recognize that that idea is fucking stupid. See NIH.
>>
>>
>>52134540
who the fuck are these nerds, and why are they talking about us?
>>
>>52134540
>https://www.reddit.com/r/ProgrammerHumor/comments/3yoh4a/dpt_on_operators/
>810

Fucking hell, that will have made it to the front page.

We're going to be invaded by normies.
>>
File: 1448806319257.png (814 KB, 604x717) Image search: [Google]
1448806319257.png
814 KB, 604x717
>Post yfw you think about the literal babies at the end of every thread who get angry insult the OP for making the thread too early but the thread stays anyway
>>
daily reminder that reddit is the cancer of the internet and that anyone who is in /dpt/ that frequents reddit does not belong here and needs to fuck off
>>
>>52134606
I visit reddit, neogaf and 4chan every day :')
>>
>>52134575
How can we get more women and ethic minorities interested in tech, anon?
>>
>>52134606
I shill for right-wing parties on /r/ukpolitics, /r/unitedkingdom, and /r/europe, but 4chan will always be my true home.

Am I allowed to stay?
>>
>>52134575
I think this thread sums up everything I hate about reddit in a nutshell.
>"can someone pls explain, i don't get it"
>"what is /dpt/"
>"a horrible place where you should never go"
>"OMG THIS LITERALLY BLEW MY MIND *MIND BLOWN* I WILL NEVER LOOK AT DECREMNTERS THE SAME WAY AGAIN!!!"
>"HAY HERE'S THE SAME TRICK IN PERL EVEN THOUGH NOBODY ASKED ME AND I'M A PATHETIC SHOWOFF ATTENTION WHORE"
>>
>tfw it's my screencap even if I didn't make the legendary slides to post, the post it quoted or the reddit post
Is this what fame feels like?
>>
>>52134629
No, because nobody knows you made that screencap or that post, and surely, that image will make the rounds on dumb meme sites that will attach their logo on the bottom in order to brand it as theirs and monetize it through ad revenue.
>>
>>52134572
>>52134608
You don't have to keep deleting your posts, anon.
>>
#include <stdio.h>
#include <stdlib.h>

#define ROUNDS 1000000

static inline void seed_rng() {
unsigned int seed = 0;
FILE *fp = fopen("/dev/random", "rb");

fread(&seed, 1, sizeof(unsigned int), fp);
srand(seed);

fclose(fp);
}

int main() {
register int attempts = 0;
int total_attempts = 0;
int dubs[ROUNDS] = {0};

seed_rng();

for (register int i = 0; i < ROUNDS; i++) {
attempts = 1;
while ((dubs[i] = (rand() % 100)) % 11)
attempts++;
total_attempts += attempts;
}
printf("Average attempts: %2.43f\n", (float) total_attempts / ROUNDS);

return 0;
}


Improved upon the dubs simulator above.

(All of my deleted posts are going to look weird in the archive)
>>
>>52134616
>>52134626
neither of you are allowed to stay. you are whats ruining this site. please leave.
>>
>>52134646
It must be perfect! Anyway, check it >>52134651
>>
>>52134655
Been here since 2000. I have authority over you kid, not the other way round.
>>
>>52134664
It's fucking trash, so delete that too.
>>
How would I go about writing a 4chan extension in C and then compiling to asm.js using emscripten to output .js?
>>
>>52134686
You don't, you just write it in JavaScript from the start.

Stop being autistic, anon.
>>
>>52134412
fn have_yahtzee(dice: &Vec<i32>) -> bool {
for die in dice {
if *die != dice[0] {
return false
}
}
return true
}
>>
>>52134693
But I don't want to learn javascript...
>>
>>52134494
or
d(aily[- ]*)?p(rogramming[- ]*)?t(hread)?


It would search through every post on a given board, for matches on the regex
>>
>>52134712
It's piss easy senpai, especially if you just use JQuery.
>>
>>52134665
>4chan is twelve years old
>Anon has been here for fifteen years
baka desu senpai
>>
>>52134706
Oh anon, that's way better.
>>
>>52134719
And then list matches, and let you choose which to open, opening it in a browser, I presume. Sounds handy upon startup, I'll write it up later today
>>
$("#srDropdownContainer").click(); datastr = ""; $("#srList").find(".RESshortcut").each(function (idx, item) { datastr += $(this).attr("data-subreddit") + '%0A'; }); window.location = "data:text/plain;charset=utf-8," + datastr;


Some code to get a list of your subreddits, if you have RES installed and are on Reddit. Just run it in the browser console.
>>
writing a meme in meme lang
require 'json'
require 'open-uri'

def count(string)
str = string.chars
res = 1
first = str.shift
str.each { |c|
if c == first
res += 1
else
break
end
}
return res
end

board = ARGV[0]
num = ARGV[1]

thread = JSON.parse(open("http://a.4cdn.org/#{board}/thread/#{num}.json").read)['posts']

posts = thread.inject({}) { |hash,p| hash.update({ p['no'] => count(p['no'].to_s.reverse) }) }.reject { |num,count| count < 2 }.sort_by { |num,count| count }.reverse

posts.each { |num,count| puts "#{num}\t#{count}" }
>>
>>52134712
Learn Typescript.
>>
>>52134665
>2000
. . .
>>
>>52134771
-define(URL, "https://a.4cdn.org/g/thread/").
-spec threadcheck() -> ok.
threadcheck() ->
{ok, "200", _Headers, Body} =
ibrowse:send_req(?URL ++ "52134175.json", [], get),
BinBody = list_to_binary(Body),
{Start, Len} = binary:match(BinBody, <<"bumplimit">>),
Bump = binary:part(BinBody, Start + Len + 2, 1),
case Bump of
<<"0">> ->
timer:sleep(1000),
threadcheck();
<<"1">> ->
io:fwrite("/dpt/ is awaiting a new trap thread~n"),
ok
end.
>>
void histogramwordlengthsvertical()
{
int c, wl, i, j;
int lengths[25];
int state;

for (i = 0; i < 25; ++i)
lengths[i] = 0;

wl = 0;
state = OUT;
while ((c = getchar()) != EOF) {
if (c == ' ' || c == '\t' || c =='\n') {
if (state == IN)
lengths[wl % 25] += 1;
state = OUT;
} else if (state == OUT) {
state = IN;
wl = 0;
}
if (state == IN)
++wl;
}
putchar('\n');

for (i = 0; i < 25; ++i) {
printf("%2d |", i);
for (j = 0; j < lengths[i]; ++j)
putchar('#');
printf("\n");
}
}

void histogramwordlengthshorizontal()
{
int c, wl, i, j, wlmax;
int lengths[25];
int state;

for (i = 0; i < 25; ++i)
lengths[i] = 0;

wl = 0;
state = OUT;
while ((c = getchar()) != EOF) {
if (c == ' ' || c == '\t' || c =='\n') {
if (state == IN)
lengths[wl % 25] += 1;
state = OUT;
} else if (state == OUT) {
state = IN;
wl = 0;
}
if (state == IN)
++wl;
}
if (state == IN)
lengths[wl % 25] += 1;
putchar('\n');

wlmax = 0;
for (i = 0; i < 25; ++i)
if (lengths[i] > wlmax)
wlmax = lengths[i];

for (i = (wlmax + 1); i > 0; --i) {
for (j = 0; j < 25; ++j)
if (lengths[j] >= i)
printf(" # ");
else
printf(" ");
putchar('\n');
}
for (i = 0; i < 25; ++i)
printf("---");
putchar('\n');
for (i = 0; i < 25; ++i)
printf("%2d ", i);
}


A couple of K&R exercises. They take word inputs and print histograms.
>>
>>52134770
WARNING.

It sends your Reddit cookie information to his server, he can then use that information to log into your account.
>>
>>52134785
>>52134740
This is the quality of fish in these threads. Not even worth eating.
>>
How do I stop writing C?
I want to write C++ but I can't stop writing C.
I'm reading yarn soup's "A tour of C++" but nothing seems to stick.
What do?
>>
>https://www.youtube.com/watch?v=r47IYcmSW1o

2030 super power genetics
>>
>>52134806
keep writing C
C++ a shit
>>
>>52134806
>What do?
at the least read ch27 of PPP2, and just keep after it anon. probably the 3 chapters on writing a good std::vector<> clone also. if that doens't help you lift up you're abstraction level, then you should probably just take this shithead's advice:
>>52134816
>>
>>52134794
That sounds like a pretty neat thing to do to someone.

You could install an extension on someone's computer that sends all the cookie information to your server.

Is this a common meme trick?
>>
>>52134794

$("#srDropdownContainer").click();

Click the drop down in the top left corner

datastr = ""; 
$("#srList").find(".RESshortcut").each(function (idx, item) {
datastr += $(this).attr("data-subreddit") + '%0A';
});

Initialise a string. For each subreddit shortcut in the drop down, find the name of the subreddit, and add it to the string with a newline on the end (that's what %0A is)

window.location = "data:text/plain;charset=utf-8," + datastr;

Browse to a data URI, where the data is encoded in the URI. In this case, it's the list of subreddits.
>>
>>52134485
Try calling it thousands of times per second, each opening, reading and closing. Using it as a seed is a better way of doing it.
>>
>>52134844
I was just funposting, anon.
>>
File: 1423646319084.jpg (1 MB, 1368x1850) Image search: [Google]
1423646319084.jpg
1 MB, 1368x1850
Quick question.

I've been trying to learn basic stuff, started with python and moved to java, after that C#. Recently I started web dev bootcamp where we learn javascript, so far so good, the concepts are not that hard to get. But I feel like I DO NOT know how to code at all, like I can do all the stuff in the exercises and stuff, but thats it.

Should I consider "re-learning" how to program with some other language. I want to get job for web dev since there is huge demand in my city and you can be employed even if you dont have any experience, but later on I want to learn how to code real stuff and get a new job after year or two where I am involved with more meaningful stuff.
>>
>>52134834
>Is this a common meme trick?
It's illegal.
>>
>>52134766
Yup.

A few tips:

4chan throttles you if you request too much too fast.

Also, there are a lot of threads to search through, so work out a decent away of dealing with that, be it using CSP-style threads, goroutines, or even the select() call.
>>
>>52134877
Ironic funposting is still funposting
>>
File: 1451272309116.png (491 KB, 1832x2366) Image search: [Google]
1451272309116.png
491 KB, 1832x2366
any depressed programmers here that have no motivation to program?
>>
>>52134883
Start doing custom projects. Stuff where you have to work out what is going on, rather than toy exercises.
>>
>>52134377
can you give me a challenge to try tomorrow?

i started learning c++ a few days ago and got as far as while and for loops. today i made a "guess the random number game"
>>
>>52134906
I've been thinking, could I join some open source project or something, where I probably wont contribute anything of value, but instead ppl in the said project will help me understand the stuff they are doing and ask me to do some small tasks that eventually will "grow me" as a programmer ?
>>
<?php
/* Details needed to connect to the database */
function connectDb() {
$db = new mysqli(SERVER, USERNAME, PASSWORD);
if ($db->connect_error) {
die('Could not connect to MySQL server');
}

if (!$db->select_db(DATABASE)) {
die('Could not select database');
}
return $db;
}

/* Gets an associative array of the results from the given database */
function getDbRowArray($db, $query)
{
$rowArray = array();
$result = $db->query($query);
if ($db->error) {
die("Query '$query' failed ({$db->error})");
}
while ($row = $result->fetch_assoc()) {
$rowArray[] = $row;
}
return $rowArray;
}

/* Creates a box on the webpage with which to run SQL queries in */
function createQueryBox()
{
echo "<form action=\"index.php\" method=\"POST\">";
echo "<p><label for=\"querybox\">Enter SQL: </label></p>";
echo "<p><input type=\"text\" name=\"querybox\" id=\"querybox\"></p>";
echo "<p><input type=\"submit\" name=\"submit\" value=\"Submit\"></p>";
echo "</form>";
}

/* Takes the string in the box and executes it as an SQL query */
function executeQuery()
{
$result = "";
if (isset($_POST['querybox']))
{
$db = connectDb();
$temp = $db->real_escape_string($_POST['querybox']);
$sql = stripslashes($temp);
$result = getDbRowArray($db, $sql);
if (!$result)
{
die("DB error ({$db->error})");
}
}

displayResult($result);
}

/* Displays the database results in a nice neat way */
function displayResult($result_array)
{
foreach ($result_array as $array) {
echo "<p>";
echo "<table border='1'>";
foreach($array as $key => $value) {
echo "<tr>";
echo "<th>$key</th>";
echo "<td>$value</td>";
echo "</tr>";
}
echo "</table>";
echo "</p>";
}
}
?>

Some PHP
>>
>>52134441
download all images, allow some time to gather database, check images against each other, rate frequency, rate deviency and start calling those dank new memes,also meme of the week etc
>>
>>52134377
Come join #/g/sicp on Rizon
>>
File: 1419276460727.jpg (61 KB, 500x539) Image search: [Google]
1419276460727.jpg
61 KB, 500x539
>>52134902
Right here
>>
Why does LLVM take so long to build?
>>
>>52134834
If you did this to someone how would you ensure it doesn't get back to you.

For example, if someone analyzed the code they'd be able to see which server the information was going to.

They can then find out where your server is and order the host to hand over your details, or even worse, arrest you if you're stupidly running the server yourself at your home.
>>
Behold, State in Haskell!
With Monads:
counter :: State Int ()  
-- A stateful computation that increments its internal state when it runs
-- has internal state Int
-- returns unit value ()
counter = do
-- get the current state
s <- get
-- put s + 1 into the new value of the state
put (s + 1)

-- use >> to sequence stateful computations
countFour = counter >> counter >> counter >> counter

-- use execState to run the sequence and get the final state
-- be sure to give it the initial state (0)
result = execState countFour 0

-- result = 4

Without Monads:
-- counter2 is a stateful computation that increments its internal state when it is called
-- takes in old state as an Int
-- gives us (new state , return value)
counter2 :: Int -> (Int, ())
counter2 a = (a + 1, ())

-- how it looks without >>
countFour2 x = fst (counter2 (fst (counter2 ((fst (counter2 (fst (counter2 x))))))))

-- still must supply initial state
result2 = countFour2 0
-- result2 = 4
>>
>>52134337
>MonadWriter [String]
>>
>>52134887
U wot m8, processing it all is fast even in python
>>
>>52135016
searching through every post of every thread on a board?
>>
>>52135014
and?
>>
>>52135005
I guess you could pay for a server anonymously with bitcoins or a prepaid credit card and only access it with a VPN that supposedly doesn't log your data or something.
>>
>>52134412
Rate my version:
extern crate rand;

use rand::Rng;

fn main() {
let n_dice = 5;
let n_sides = 6;
let n_attempts = 1000;

let mut rng = rand::thread_rng();

for i in 0..n_attempts {
let mut n: usize = 1;
let mut first;

while {
let mut roll = rng.gen_iter::<u32>()
.map(|n| n % n_sides + 1)
.take(n_dice);

first = roll.next().unwrap();

roll.any(|x| x != first)
} {
n += 1;
}

println!("{}: {} rolls. Yahtzee value {}", i, n, first);
}
}
>>
>>52135027
>every post
I assumed it was only thread subjects. I could definitely do posts too, it'll be a learning process for everything you mentioned
>>
>>52135042
it's utterly slow

>left-associated mappends (n^2)
>fully lazy, large number of useless thunks
>String = [Char] making things even worse
>>
>>52135063
Be gentle anon, I'm still very much a noob with Rust.
>>
>>52135069
Dang - what would you use?
>>
>tfw turbo autist math pro
>tfw too stupid to learn python

how is this possible
>>
>>52135066
I've been meaning to implement CSP style concurrency (basically, the style mentioned in this video https://www.youtube.com/watch?v=cN_DpYBzKso).

I also want to use Python's generators to reduce some overhead, so that things are lazy-evaluated where possible.

I'm using separate regex and json libraries which are both implemented in C. I'm also using some tricks from https://wiki.python.org/moin/PythonSpeed/PerformanceTips and https://www.python.org/doc/essays/list2str/

So, there's a python thread spawned for each page in the catalog, and each thread spawns a new thread for each 4chan thread on the catalog page.
>>
>>52134923
https://www.reddit.com/r/cscareerquestions/comments/20ahfq/heres_a_pretty_big_list_of_programming_interview/
>>
>not compiling C in your browser
step up /dpt/
>>
>>52135108
Unlike math, programming requires you to think.
>>
>>52135157
AGAGAHAHAGAAHAJA"ADAAJjklsa
oh lol
>>
>>52135089
never use MonadWriter at all

for logging, use MonadLogger (monad-logger package)
>>
Hi, /dpt/, I first learnt about you on /r/ProgrammerHumor.

I hope I will be welcome here.
>>
>>52135251
You must answer correctly:

Do you wear a skirt while programming?
>>
>>52135251
Welcome chum. /dpt/ is inclusive of all types of people.
>>
>>52135251
Hi Mike,

Happy to see you here.
Fuck you.

Yours truly,

Rob Pike.
>>
File: reddit.jpg (47 KB, 275x275) Image search: [Google]
reddit.jpg
47 KB, 275x275
>>52135251
Reinforcements have arrived. How many redditors strong are we now?
>>
>>52135275
here
>>
>>52135264
>Do you wear a skirt while programming?
No, but I don't mind people that do. Each to their own.

>>52135266
>/dpt/ is inclusive of all types of people
That's great to hear.
>>
soon I'll be 60 years old
>>
>>52135063
>>52135075
Now without modulo bias and less crap:
extern crate rand;

use rand::distributions::{IndependentSample, Range};

fn main() {
let n_dice = 5;
let n_sides = 6;
let n_attempts = 1000;

let mut rng = rand::thread_rng();
let between = Range::new(1, n_sides + 1);
let mut roll_die = || between.ind_sample(&mut rng);

for i in 0..n_attempts {
let mut n = 1;
let mut first;

while {
first = roll_die();
(1..n_dice).any(|_| roll_die() != first)
} {
n += 1;
}

println!("{}: {} rolls. Yahtzee value {}", i, n, first);
}
}
>>
File: 1396508799625.jpg (50 KB, 500x211) Image search: [Google]
1396508799625.jpg
50 KB, 500x211
Why aren't black people very good at programming?
>>
>>52135339
Good stuff. Are you retired?
>>
>>52135347
Ask OSGTP. He's leading expert in black culture.
Is that from Owarimonogatari? I cannot remember that scene.
>>
>>52135251
Reddit gold for you, sir!
>>
I also posted this in /sqt/. I wanna add libcurl to my libraries in devc++ but I have no idea how. Can someone help
>>
>>52135385
Dynamic link it. Does it use CMake?
>>
>>52135347
On average their IQ is lower than white and Asian people.

IQ may not be a good indicator for intelligence, but it is certainly a good indicator for your problem solving ability.

Programming requires good problem solving skills.

Why is this fact taboo?

I'm European and I accept that east Asians, on average, have a higher IQ than Europeans.
>>
>>52135353
yep
>>
>>52135408
Because it clashes with progressive propaganda that all people are inherently equal and race is a social construct, black people are dumb because they're poor, etc.
>>
>>52134883
Throw yourself into the wild, start something big and keep working on it for years.
>>
>>52135406
I don't know to be honest. I just wanna include files from libcurl.
>>
>>52135436
Can you edit the make flags? Add -lcurl.
>>
>>52135448
oh I found out why it wouldn't work. I added the wrong directory. Thanks though.
>>
>>52135428
I really want to into robotics and DIY stuff, I'm considering buying arduino or some replica and raspberry pi, or some sort of starter kit and making some simple crawling bot from scratch.
>>
>>52134806
As someone who can write both, write C you dont need classes and templates.
>>
How nice is Scala for Android dev?
>>
>>52135566
https://www.youtube.com/watch?v=uiJycy6dFSQ
>>
How nice is Clojure for Android dev?
>>
How nice is nim for Android dev?
>>
File: mems.jpg (216 KB, 1123x589) Image search: [Google]
mems.jpg
216 KB, 1123x589
Finished my meme image downloader "app"

run with the following, or just change the vars in code and run it normally:
file.py board threadNumber


import urllib,sys,requests,os

board,thread=sys.argv[1:]

url="https://a.4cdn.org/"+board+"/thread/"+thread+".json"

posts=requests.get(url).json()["posts"]

newDir=os.getcwd()+"\\"+board+"\\"+thread

if not os.path.exists(newDir):
os.makedirs(newDir)

for keys in posts:
if "tim" in keys:
urllib.urlretrieve("https://i.4cdn.org/"+board+"/"+str(keys["tim"])
+keys["ext"],newDir+"\\"+str(keys["tim"])+keys["ext"])
>>
>>52134951
>still using mysqli
>not using PDO
>>
How nice is COBOL for Android dev?
>>
How nice is Befunge for Android dev?
>>
How nice is Android for Android dev?
>>
How nice are memes for Android dev?
>>
File: aff.webm (1 MB, 902x582) Image search: [Google]
aff.webm
1 MB, 902x582
Ask your beloved programming literate anything.

>>52135251
Welcome on /dpt/, the best programming community.
>>
>>52135723
Should I document my hobby project?
>>
File: original_Port of Nice-France.jpg (849 KB, 1000x750) Image search: [Google]
original_Port of Nice-France.jpg
849 KB, 1000x750
How nice is Nice for Android dev?
>>
>>52135725
Documentation and tests
>>
File: ajGo6O4.gif (685 KB, 600x600) Image search: [Google]
ajGo6O4.gif
685 KB, 600x600
>>52135725
no or just a white paper.
>>
>>52135566
>>52135576
>>52135590

Anon, with all due respect, if you set about to do Android development in any language other than Java, you're going to find yourself entering some rather uncharted waters. There are some plugins to get Scala and Clojure up and running, and there are probably some small communities for working with these, but the vast majority of documentation, tutorials, etc... for Android development are Java only. The end result is that it's going to take a lot of time to get even a skeleton of a project going. Maybe the waters are fine once you get your feet wet, but honestly, I can't say much based on the lack of resources.
>>
>>52135777
How about nim?
>>
>>52135725
If you expect anyone else to work with it or see it, yes
Otherwise, no
>>
>>52135602
Of all the things you criticise it on, that was what you picked?

The whole concept of embedding a textbox that executes straight SQL is retarded.

Also, note that it even uses strip slashes right after the mysqli call.
>>
>>52135747
>>52135749
>>52135800
I noticed even the Linux kernel source isn't fully documented.
>>
>>52135890
Probably because it changes so often.
>>
Is it possible to run a videogame entirely on the GPU?
>>
>>52135847
He's obviously making some test, not-public app.
>>
>>52135968
No. Something has to give the GPU instructions, and also, GPUs are horrible at branching.
>>
>>52134520
Whoever wrote the bot threading fucked it up :v
>>
In the market for a laptop, you guys recommend a macbook or windows laptop?
>>
>>52135890
everything is in the documentation folder. ntos is much better documented.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation?id=refs/tags/v4.4-rc7
>>
File: You're welcome.png (14 KB, 173x248) Image search: [Google]
You're welcome.png
14 KB, 173x248
>>52134651
Here's one that actually works XD

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>

#define ROUNDS 1000000

int main()
{
uint_fast16_t attempts = 0, total_attempts = 0, dubs[ROUNDS] = {0}, i;
time_t t;

srand((unsigned int) time(&t));

for (i = 0; i < ROUNDS; i++) {
attempts = 1;
while ((dubs[i] = (rand() % 100)) % 11)
attempts++;
total_attempts += attempts;
}
printf("Average attempts: %2.43f\n", (float) total_attempts / ROUNDS);
}
>>
>>52136024
But mine works too. I tested it.

Did you just make yours portable?
>>
>>52134462
Rust
>>
>>52136015
a windows laptop you melt
>>
>>52136015
Macbook
>>
>>52136015
>>52136039

I would say get a thinkpad but with Lenovo's spyware incidents, I'm far less trusting of them.

Check out the /g/ wiki, n00b.

wiki.installgentoo.com

There are pages on laptops, including a laptop buying guide.
>>
>>52134204
Priority no. 1: languages that can get you a job without much effort. Java, C#, PHP, and such.
Once you have a job that puts food on the table and are gaining professional experience that you can leverage to find better jobs in the future you can freely experiment with any language you like.
>>
>>52134253
>C
>not weakly typed
choose one
>>
File: 1aFbX2v.png (62 KB, 679x778) Image search: [Google]
1aFbX2v.png
62 KB, 679x778
>>52135027
It's one json file that gives you the whole catalog sorted by current page. It's trivial to search for a key term in a thread subject/comment.

>>52134887
>4chan throttles you if you request too much too fast.
This is true. I ran into issues with this initially. Not sure best practice, I just ended up making a callback for the same data if I get a bad request, seems to work 99% now.

>>52134463
>word counter
pic related

/hpg/ was the most on-topic of all the boards yesterday.

I'm working on filtering out non-significant words.
>>
>>52136116
>/hpg/ was the most on-topic of all the boards yesterday.

Figures. hpg is the most boring fucking community I've ever visited.
>>
>>52134786
>thread number is hard coded
>>
>>52136116
Ah but you see anon, that's the difference.

My code searches through the catalog, and then opens every thread, and searches each post in every thread. It's a much bigger job than just searching the catalog.
>>
>>52136144
>and then opens every thread, and searches each post in every thread
Why?

What are you doing?
>>
>>52136153
It's a 4chan board searcher. See >>52134222

It will search every post on a board using a regex.
>>
>>52136169
Oh, I thought you were just looking for /dpt/, didn't realize you were shooting for any post that contains a keyword.

I'm keeping mine limited to generals for now. Going to make it so that when you click a word from the list, it shows you the posts that it was used in, maybe just a few words for context.
>>
Let's say I have a RSS Feed class in PHP:

class Feed
{
public $id;
public $title;
public $url;
[...]
public $articles; // an array with the list of Articles of this feed
}


And the Article class:

class Article
{
public $feed; // reference to the parent Feed
public $title;
public $pubDate;
public $description;
public $link;

[...]
}


Question is, should I use a weak reference in Article when referencing to the parent Feed class to avoid a memory leak or it adds unnecessary complexity? In iOS development, you use a weak ref in these kind of parent-child composition relationships to avoid a cycling reference that could prevent both from being freed from memory. Is it the same in PHP or the garbage collector is smart enough? Because it seems weird to me that PHP doesn't even include a weak ref built-in and you have to use an extension.
>>
>>52136020
Interesting.
I was actually expecting full Javadoc style comments for such a large project. Only bitmasks are documented.
Thinking about it, the white paper is a much better idea than writing stupid docs.
>>
>>52136242
almost all gced langs use stw gcs
>>
>>52135793

Well, it doesn't run on the JVM, so you're going to have a hard time.

>>52136015

I highly recommend not getting your hardware from Apple. They have problems with overheating; the chassis dents easily; and magsafe has problems with flimsy shielding, which is bad enough that Apple was sued back in 2009 for it being a fire hazard. Despite the fact that they have changed the cord, there are still reports of the shielding coming off too damn easily. Which brings me to another point -- they're shit at responding to consumer complaints about product defects.

As for the software to run on your laptop, I recommend using Linux. Based on the fact that you're asking this in DPT, I'm assuming you're a programmer. Unless you need Mac OS X for iOS development, you're better off not using it, because all package managers on Mac OS X are shit. As for Windows... it has no package managers, and if you try and get a third party library to work on Windows without pre-compiled binaries you're going to be in for a fucking ride.
>>
File: io.jpg (131 KB, 678x350) Image search: [Google]
io.jpg
131 KB, 678x350
Sometimes /dpt/ is fun, sometimes /dpt/ is slow.

Why can't it be fun 24/7?
>>
>>52136336
Wait until the burgers arrive and enjoy endless discussions about politics and muh guns.
>>
File: 1450356503040.jpg (106 KB, 749x826) Image search: [Google]
1450356503040.jpg
106 KB, 749x826
>>52136335
>I highly recommend not getting your hardware from Apple
>>
>>52136256
>stop-the-world GC
Mmmm, interesting. I guess GC prevents those kind of problems, I have to read more about it. Being used to not having GC is suffering.
>>
>>52136335
>try and get a third party library to work on Windows
Use a good language next time.
Literally a copy paste of the library file to the source folder for me.
>>
File: 2015-12-30_06-38-47.png (110 KB, 1080x1873) Image search: [Google]
2015-12-30_06-38-47.png
110 KB, 1080x1873
>>52136336
If you get moist from analyzing data, /dpt/ is always fun.

NSA here I come.
>>
>>52136407

Anon, first of all, you don't put libraries in your source folder, you put them in a folder your linker is going to look at. If it's a DLL, you put it in the same folder as the executable. Second of all, the problem I am describing is that the library is not available in binary form -- you can get the C or C++ source, and it's not going to compile right on Windows. The configure script will pass, and then somewhere along the line, Make is going to have a problem because either Bash is outdated (and there are no newer versions of Bash than what is available), or libtool isn't working. So the solution ends up being to either try and fix the auto-generated script, or to manually copy and paste each of the commands that Make was trying to run, that somehow failed, with maybe a tweak or two to get it to work.

And as for your notion that I should just use a better language, the library is written in C. If I want to get it working with any other language, I must first compile the C library, then compile the extensions, which are linked against the C library.
>>
>>52136568
Use a good library next time.
Literally a download from the library provider's website for me.
>>
>>52136242
Garbage collection handles that automatically.

Cyclical references are only an issue for languages which use reference counting instead of GC (e.g. Objective-C in retain-count mode, which is the only mode available on iOS).
>>
>>52136589

Okay then. What library would you recommend for raw/cbreak mode terminal I/O that is not ncurses?
>>
Or even better, recommend me a library for multi-precision arithmetic for Windows that is not libgmp, because that shit flat out won't compile on my machine.
>>
>>52136507
Sauce?
>>
>>52136144
If the board is slow enough,. you can get by with reloading the front page on a regular basis instead of checking every single thread. (the classic interface, not the new shiny json-powered catalog interface.)

If you miss a post in a thread, open it directly. If a thread goes over bump limit, open it directly. etc.
>>
http://lists.racket-lang.org/users/archive/2008-February/023033.html

Leftism is a mental illness.
>>
>>52136694
It's like a new kind of SJW. Even Racket is tainted.
>>
C or C++, /dpt/?
>>
>>52136781
What are you planning to do?
>>
>>52136790
I meant in general.
>>
>>52136694

To be fair, a .ss file extension is hardly descriptive for scheme. I'd guess it stands for "scheme source" or "scheme script", but the first s could stand for any programming language whose name starts with s. Better to use .scm for Scheme and .rkt for Racket.

That said, when people complain about this shit just because it makes them think of nazis, it makes me want to use an actual unicode swastika as a file extension for something. I mean, who wouldn't want to compile
main.卐
>>
>>52136646
MPIR.

It was forked from GMP, in large part because of the unwillingness of the GMP devs to even consider MSVC as a valid target.
>>
>>52136810
I'd say Go.
Seriously, there's not best language.
>>
>>52136810
nim is generally regarded as the best language.
>>
>>52136839
If there's no best language why does everyone use JavaScript the most?
>>
>>52136810
Generally it depends what you're going to do.
It's a stupid question.
>>
>>52136613
That's nice. I always though that weak/strong refs in iOS/OS X programming were annoying, but probably a GC in a mobile device isn't a good idea given the performance implications of things like stop-the-world GCs.
>>
>>52136873
Because bad developers tend to pick bad languages.
>>
>>52136873
I don't know if JavaScript is used the most, but if a language is used a lot, it's probably because it's best or easiest for what the most people do.
>>
>>52136873
Best for most web tasks
>>
>>52136781
>>52136810

C++ in general.
C for libraries/native extensions to other languages.

Other people's opinions may vary on this.

>>52136830

I will try this out. Although I will note that I do not use MSVC.
>>
File: 1451481618328.jpg (91 KB, 634x355) Image search: [Google]
1451481618328.jpg
91 KB, 634x355
>>
>>52136810
Programming languages are just tools and some of them are more suited than others depending of the task. If you were a carpenter you would use a sledgehammer for certain things and a claw hammer for other things.
>>
Now I've got to find a way to call (anonymous) Go functions from C.
#include "beat.h"

#include <aubio/aubio.h>
#include <stdlib.h>

static uint_t win_size = 1024;
static uint_t hop_size = 256; // win_size / 4
static uint_t samplerate = 0; // file sample rate
static uint_t out_size = 2;

static char* method = "hfc";
static smpl_t silence = -70.0;
static smpl_t threshold = 0.3;
static smpl_t minioi = 20.0;
static smpl_t delay = 1100.8; // 4.3 * hop_size

int beat(char *file)
{
aubio_source_t* source = new_aubio_source(
file,
samplerate,
hop_size
);
if (source == NULL) {
return BEAT_SOURCE;
}

smpl_t source_samplerate = aubio_source_get_samplerate(source);

aubio_onset_t* onset = new_aubio_onset(
method,
win_size,
hop_size,
source_samplerate
);
if (onset == NULL) {
return BEAT_ONSET;
}

// always returns AUBIO_OK
aubio_onset_set_silence(onset, silence);
aubio_onset_set_threshold(onset, threshold);
aubio_onset_set_minioi_ms(onset, minioi);
aubio_onset_set_delay_ms(onset, delay);

fvec_t* in = new_fvec(hop_size);
fvec_t* out = new_fvec(out_size);

while (1) {
uint_t read;
aubio_source_do(source, in, &read);
aubio_onset_do(onset, in, out);
if (read != hop_size) {
break;
}
}

del_aubio_source(source);
del_aubio_onset(onset);
del_fvec(in);
del_fvec(out);
aubio_cleanup();

return BEAT_OK;
}
>>
File: Lol.png (55 KB, 534x344) Image search: [Google]
Lol.png
55 KB, 534x344
>>52136924
Wrong pic

What do you guys think of this code?
>>
>>52136930
hey man could you hwlp me? i need to make the cat move
http://pastebin.com/i1ZaWXkY

[email protected]
>>
ProgrammingHumor should be called ProgrammingHumou?r so it's inclusive to British English speakers tbqh :^)

Am I doing it right?
>>
>>52136959
Why is there so much reddit discussion today?
>>
>>52136943
Assignment instead of comparison.
Not much else (although why period in first case and no period in other?).
Whoever wrote it does not program fora living.
>>
>>52136959
My mistake, the subreddit is called ProgrammerHumor.

It should be called ProgrammerHumou?r tbqh.
>>
>>52136966
Jealousy, obviously.
>>
>>52136943
It's wrong.

>=
>cout Block
>indentation
>>
>>52136943

It uses = in an if statement. Nothing further needs to be said.
>>
>>52137009
Assignment could very well productively used in if statement.

if((file=fopen(...))!=NULL){ ... }
>>
>>52136924
The difference is that moderate Christians aren't murdering innocents or people who badmouth Christianity, even if the book says to.
>>
>>52137030
>even if the book says to
I don't think it does.
>>
File: hitagi-san.png (132 KB, 624x694) Image search: [Google]
hitagi-san.png
132 KB, 624x694
What music do you listen to, /dpt/?
>>
>>52137039
I dunno I remember someone raised the point once that The Curry Nan or whatever it's called tells people to murder, and someone countered it by saying the bible does too.
>>
>>52137030
The new testament is hippy shit to be fair.
>>
>>52137042
Used to listen to black metal.
Now mostly r/a/dio.
>>
>>52136781
C++
>>
>>52136949
ncurses
>>
>>52136985
>Whoever wrote it does not program fora living.
oh but "she" does... with "her" parents and investors money
>>
>>52137028

It can be, but it shouldn't be used as she was using it. In fact, it would be better to restructure the tweet something like this:

auto tweeter = tweet.get_tweeter();
if (tweet.is_negative() || GAMER_GATER == tweeter.get_kind())
tweeter.block();
>>
>>52137091
Yeah, well, that would be sensible, and we wouldn't want that, would we?
>>
>>52136621
wincrt of course.
>>
>>52137091
>auto
this is what fegs that don't use IDEs actually believe
>>
>>52137042
Avril Lavigne, The Dirty Youth, Lacey Sturm, Icon For Hire
Wildcard, Celph Titled, Apathy, Action Bronson, Taylor Swift
Those on repeat for the last couple months.
>>
>>52137123
?
>>
>>52137125
>Avril Lavigne
I used to fancy her when I was a kid tbqh.
>>
>>52137132
auto saves having to change the name of tweeter's type if the return type of get_tweeter changes and that's about it
>>
>>52137155
It could save you from having to write something like QMap<QString,QList<String>>.
>>
>>52137141
She still looks like that, family
>>
File: expert coming through.jpg (368 KB, 1500x998) Image search: [Google]
expert coming through.jpg
368 KB, 1500x998
>>52137178
>writing code takes a significant amount of dev time
>>
>>52137218
It takes more time than not writing it. So unless you enjoy being inefficient on purpose...
>>
File: you_tried.png (78 KB, 1147x719) Image search: [Google]
you_tried.png
78 KB, 1147x719
Well, this is a new one! Usually, it's the build script that's fucked. This time, it's the source itself!

>>52137111

Not portable. I want it to work seamlessly on both Windows and Unix. That's kind of what the point of a fucking library is.

>>52137123

Well, this is supposed to be a tweet, so we want to keep the number of characters to a minimum, yes? Also, while I do not use an IDE for my own reasons, I can't see much harm in regular use of the auto keyword even if one does use an IDE. Case in point, consider that the IDE will tell you what type a variable is without you having to look up the actual method signature for whatever it was generated from. Thus, we end up doing less typing for zero cost.
>>
>>52137229
>not having explicit types
absolutely disgusting
>>
>>52136670
std:: always

using namespace std can be tolerated if it's scoped to within a small function
>>
File: Screenshot_2015-12-30_20-01-17.png (165 KB, 1920x1080) Image search: [Google]
Screenshot_2015-12-30_20-01-17.png
165 KB, 1920x1080
>>52137275
Works on my machine :^)

Get a better language.
Get a better library.
>>
>>52136651
I'll post source once I get it more fleshed out.

Currently only ~700 LOC, not much there.
>>
Should const correctness be enforced in C? I know it's heavily used in C++ libraries.
>>
>>52137275
>mingw/cygwin instead of gcc
>>
>>52137433
yes
>>
>>52136670
I prefer specific usings to maintain both clarity and conciseness.
using std::cin;
using std::cout;
using std::endl;
using std::string;
>>
>>52137409

Yeah, well, you're not running Windows. Getting shit to compile on Windows is a pain in the ass.

>>52137455

MinGW IS GCC, you fucking idiot. Most of the time, the problem isn't MinGW; it's Bash. This time, the problem is neither; it's the fucking library source code.
>>
>>52137528
No bully, keep this community healthy.
>>
This isn't programming related, but:

How do I convert an ext4 formatted hard drive to a Windows friendly format on Windows, /dpt/?
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.