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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 327
Thread images: 25

File: implementation is three lines.png (22KB, 584x313px) Image search: [Google]
implementation is three lines.png
22KB, 584x313px
Previous Thread: >>56418215


What are you working on, /g/?
>>
First for Swift
>>
Was writing a simple simulation for genetic drift in populations and took a break when I started to write a method that returns ArrayList<Pair<Locus, ArrayList<double>>> because I should probably do it a different way

Then I thought I could probably write this entire program in under 50 lines of Haskell if I knew Haskell better.
>>
>>56426820
in haskell that would be [(Locus, [Double])] or Vector (Locus, Vector Double)
>>
WYSIWYG website builder in angular2/typescript
>>
>>56426835
>typescript
mein nigger
>>
>>56426833
Yeah, that's not the issue with my lack of knowledge of haskell, it's just actually performing the operations that I need to; I'm not that great at Haskell to do it well
>>
How do I find active but unknow open source projects to contribute to? I wanna help some kid with hs videogame or something.
>>
>>56426873
post code?
>>
>>56426875
hey buddy

https://github.com/tgstation/tgstation
>>
>>56426849
Honestly I prefer plain ES2015 but angular2 kinda requires TS
>>
>join CS program
>first weedout class is 50% women because school is pushing the women in stem meme really hard
>only like half the class shows up for the final
>only 2 of them are women
>one of them was a tranny
I didn't even notice until they talked once and it was clear it was a guy.
>>
>>56426919

Did you have sex with him?
>>
>>56426913
Why do you prefer ES2015? Typescript is just a superset of es2015 right?
>>
>>56426899
>relatively unknown
>317 stars
>38K commits
C'mon man I need something smaller
>>
>it's a token woman who doesn't really add anything to the panel but redundant common knowledge

when will this women in tech gimmick end?
>>
>>56426936
No, and I only saw him once.
I think he was from the online segment, they had to show up in person to do the final.
>>
>>56426952
Mainly because I dont care for any of its static typesystem and the whole transpiling flow is not how I like to work. Plain old javascript just works and you can get working on a new project by just opening an editor and starting to type.
>>
>>56426881
It's Java, so it's bloated, so I'll just describe:

Population is a list of Organisms that have a list of Genotypes, which are two of X alleles from a Locus

Organism.mateWith(Organism mate) just picks two random alleles from each genotype to make a child:
for (int i = 0; i < genome.size(); i++) {
childGenome.add(genome.get(i).getRandomAllele() + mate.getGenotypeAt(i).getRandomAllele());
}


In Haskell, I would probably just do this with
mate :: [[Char]] -> [[Char]]


A population goes to the next generation by having each organism mate twice to make two children, replacing the parents.

Collections.shuffle(this);

for (int i = 0; i < size(); i += 2) {
set(i, get(i).mateWith(get(i + 1)));
set(i + 1, this.get(i + 1).matewith(get(i)));
}


In Haskell I would probably do something like this:
nextGeneration :: [[[Char]]] -> [[[Char]]]


The method I haven't written yet in my Java program is calculating the frequency of each allele. This is done by iterating over the organisms and keeping a running total of each allele in each of their genotypes, and then just dividing by the total number of alleles in that genotype (pop size * 2)
In haskell, I would do something like
alleleFrequencies :: [[[Char]]] -> [(Char, Double)]

where each allele is matched with a double (percentage)

I have it as [Locus, [Double]] in my Java program because a locus is just a collection of alleles, so each double will match to each allele in that locus, but I'll probably just make it so that alleles also have a frequency field so I can just use ArrayList<Allele>
(right now, alleles are just characters, genotypes and loci are strings)
>>
>>56426962
Do these people realize their job is completely redundant and meaningless or do they really believe their contributions actually matter in a company?
>>
>>56427025
>deliberately writing bloated Java code

Why are Haskellfags so stupid?
>>
>>56426875
Here: https://github.com/bakape/meguca
>>
>>56427048
I'm not a Haskellfag, I barely know Haskell.
I don't know how I'd make my Java code any less bloated.
>>
>>56427003
type safety gets comfy on large projects though
>>
>>56427045
they'll inevitably get replaced by traps who actually know their shit
>>
>>56427025
I'm not quite sure about this whole genotype/allele/locus thing

So a gene is a Char, an allele is a [Char] and a genotype is a [[Char]] ?
>>
>>56427091
Sorry, I wasn't sure if I was clear enough either

A genotype is a pair of Char, so [Char]
An organism is a list of genotypes, so [[Char]]
A population is a list of organisms, so [[[Char]]]

A locus is a list of possible alleles for a genotype, so also a [Char]

Example:

An organism is homozygous recessive for blue eyes
Their "Eyes" genotype is "bb"
the "Eyes" locus is "Bb", one Char for each type of allele
>>
What's a regex that'll show me all the blank lines in my code? All my attempts at writing one failed.
>>
>>56427127
>A genotype is a pair of Char
AKA a pair of alleles, which are Char

>>56427129
You don't ne
>>
>>56427129
^\s*$
>>
>>56427127
I don't really understand the scenario but I'll try to replicate the code in >>56427025
>>
>>56427127
>>56427143
Wait, a pair? So (Char, Char) rather than [Char]?
>>
>>56427161
That works too.
>>
Degenerates.
>>
>>56427196
are you scared that you wouldn't be cute enough if you actually did it?
>>
This would be it:

mate :: [(Char, Char)] -> [(Char, Char)] -> [(Char, Char)]

nexGeneration :: [[(Char, Char)]] -> [[(Char, Char)]]

alleleFrequencies :: [[(Char, Char)]] -> [((Char, Double), (Char, Double)]
>>
>>56427289
You can't just do arbitrary side effects, and random numbers are a side effect, so you should take random numbers as a parameter (or return a monadic result)
>>
>>56427228
I know I wouldn't be, so I just try to not think about it too much.
>>
>>56427289
something like this

at (a,b) 0 = a
at (a,b) 1 = b
at _ _ = undefined

mate = zipWith3 (\g m (r1,r2) -> (g `at` r1, b `at` r2))
-- mate genome mate rs, rs is a list of random pairs of bits


pairs (x:y:ys) = (x,y) : pairs ys
pairs _ = []

nextGeneration pop' rs1 rs2 =
let pop = shuffle rs1 pop' in
(map concat) $ zipWith (\(a,b) r -> [mate a b r, mate b a r]) (pairs pop) rs2
-- define a shuffle function that randomly shuffles based on a list of random numbers


you should define allele / organism / population / etc as data types first
>>
>>56427361
Neat!
>>
File: Screenshot_2016-09-05_00-51-40.png (417KB, 770x556px) Image search: [Google]
Screenshot_2016-09-05_00-51-40.png
417KB, 770x556px
Now with toggleable image search.
>>
Frogger or snake?
Which one should I do?
>>
Learning Git. Not really sure why since we use svn at work, but whatever, gotta get that nawwledge.
>>
>>56427440
Frogger is far more fun.
>>
>>56427446
You can use git-svn to use git's powers on your company's svn repo
>>
>>56427127
>>56427361
e.g.

type Pair a = (a, a)
type Allele = Char
type AlleleFreq = (Allele, Double)
type Genotype = Pair Allele
type Organism = [Genotype]
type Population = [Organism]

mate :: (RandomGen g) => Organism -> Organism -> Rand g Organism
nextGeneration :: (RandomGen g) => Generation -> Rand g Generation
alleleFrequencies :: Population -> [Pair AlleleFreq]

--Rand is from MonadRandom
>>
>/agdg/ is filled with tranny shitposting
>/dpt/ is filled with tranny shitposting

I just want to talk about games and programming, can you faggots just fuck off and kill yourselves.
>>
>>56427527
I propose the banning of hasklel to stop this menace.
>>
>>56427553
Nah, we need Hiro replaced with someone who actually knows what they're doing.
>>
ty janny
>>
>>56426875
https://github.com/ez3chi3l/eternity
Bring your C legs.
>>
>>56427588
You really need a better readme if you want anyone to contribute at all. What the heck is your project?
>>
>>56427588

Well, it's an image viewer.
>>
>>56427692
We can C that
>>
>>56427588
Your configure script does not check for glew even though it requires it, only glfw.
>>
>>56427588
As far as I can tell, your entire program is just riding on 3rd party libraries.
Did you even write any of it yourself?
>>
>>56427897
My entire life has just been riding on 3rd parties
I don't think I did any of it myself
>>
Anyone read any of the proposals for C2X? I like several of them so far.

http://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm

"A Closure for C" is nice. "Attributes in C" and the other documents are a nice idea but the killer is importing C++ syntax with the "[[ ]]" to implement them, which is horrible and should be redone to use GNU syntax which fits C's existing syntax. All of Gustedt's proposals are nice as usual, especially with "The Register Overhall" which finally lets C define true constants and constant expressions with something like "register int const sig_const = 0x408", and changes something in the language that is rarely used. The only problem is that C++17 is planning to remove register after deprecating it but screw that language anyways.
>>
I'm working through a book on C++ and some code which works in the book causes a linker error when I attempt to compile.
Context: I've made a class called Point; the purpose of this class is to store x and y coords for a 2-D point. I am writing function so that if you have a point, say (0,0) assigned to X, the code:
cout<<X<<endl;

prints (1,1). However, as stated above, code which compiles for the author causes a linker error for me.

point.hpp:
#ifndef POINT_H_
#define POINT_H_
#include <iostream>

class Point {
// Irrelevant declarations
};

std::ostream& operator<<(std::ostream& out, const Point& P);


The above function is defined in point.cpp
#include "point.hpp"
std::ostream& operator<<(std::ostream& out, const Point& P) {
out << '(' <<P.get_x() << ',' << P.get_y() << ')';
return out;
}


and finally main.cpp:
#include "point.hpp"
#include <iostream>

int main() {
Point X; // Initialises X as the point (0,0)
std::cout << X << std::endl;
return 0;
}


The terminal error:
Invoking: GCC C++ Linker
g++ -o "points" ./main.o ./point.o
./main.o: In function `main':
main.cpp:6: undefined reference to `operator<<(std::ostream&, Point)'
makefile:44: recipe for target 'points' failed
collect2: error: ld returned 1 exit status
make: *** [points] Error 1


Similar SO posts just have replies of "it's a linker error" but that doesn't really help me when I'm aware of that already. How does this code compile and execute for the author but cause a linker error for me? This is copied verbatim from a book.
>>
>>56427897
Why would you reinvent the wheel?
>>
File: Comb_sort_demo.gif (788KB, 269x257px) Image search: [Google]
Comb_sort_demo.gif
788KB, 269x257px
>>56426714
>Try out comb sort and compare it to quick/merge/bubble/insertion sort
>Holy fucking shit is it fast
void combsort(int[] input, int size){
const double factor=1.247330950103979; //real programs all use black magic numbers
int gap = (int)(size/factor);
while(gap>1){
for(int i = 0; i < size - gap; ++i) {
if(input[i]>input[i+gap]){
swap(input[i], input[i+gap]);
}
}
gap = (int)(gap/scaling);
}
bubblesort(input, size);
}


Someone explain this magical shit.
>>
>>56428119
you see it yet m8?
starting using #pragma once
>>
>>56428119
Supplementary information:
Within the class declaration are two methods: bool operator==(const Point& Q) and bool operator!=(const Point& Q), which as you can guess tests the equality or inequality respectively of two points.
These two methods are working as intended so the issue is linked to the operator<< function.
>>
>>56428357
start*
>>
>>56428364

Note: Listen to what >>56428357 says. It's a very simple error.
>>
I have trouble doing pic related in c
here's my solution in haskell though
{-# LANGUAGE ViewPatterns #-}
import Data.Char

tri = reverse . padd . make
where padd = zipWith space [0..]
space = \s b -> replicate s ' ' ++ b

make 'a' = ["a"]
make (toLower -> c)
= (h ++ [c] ++ reverse h) : make p
where h = ['a'..p]
p = chr (ord c - 1)

halp?
>>
>>56428470
>>56428357
Well fuck me. That took me far too long. Thanks.
>>
>>56428508
Yep, be very cautious of "C with classes" style coding.
>>
>>56428504
Glad you're moving into C dude.

Problems like this are done iteratively, usually with nested loops of some kind. Here's a hint:

int main(void) {
char ch = 'u';

for (char inner = 'a'; inner <= ch; inner++) {
// loop to print spaces
// loop to print characters before the middle one
// loop to print characters after the middle one
// print newline
}
return 0;
}
>>
File: haskell.png (292KB, 960x800px) Image search: [Google]
haskell.png
292KB, 960x800px
Haskell is CUTE!
Haskell is PURE!
>>
>>56428624
Is there literally any reason for me to learn haskell? Is there any task I will every think to myself
>Haskell would be great for this
?

Honestly, apart from the fact that carmack seems to like it, I really just don't get it. side effects seem easy enough to avoid by just writing code properly.
>>
>>56428535
Yeah, that's my problem with this book. The aim of the author is to provide a basic knowledge of C++ to mathematicians with the aim of aiding mathematical research and the entire book is C with classes. I'm already familiar with C but I thought I should start with some basic C++ book with a particular aim before picking up a book on data structures, but I find myself at once trying to copy code and avoiding things which the author does that I know are bad such as "using namespace std;" in header files.
>>
>>56428504
void gaytriangle(int gayness){
for(int dicks = 0; dicks<gayness; ++dicks){
for(int everywhere = dicks+1; everywhere<gayness; ++everywhere){
std::cout << " ";
}
for(int homos = 0; homos<dicks+1; ++homos){
std::cout << (char)('a'+homos);
}
for(int homos = dicks-1; homos>=0; --homos){
std::cout << (char)('a'+homos);
}
std::cout<<"\n";
}
}
>>
>>56428676
The problem is that all useful properties of a programming language involve state and autistic math tards want none of it.

Simply implementing stateful programming in haskell is a giant fucking ordeal.
Last month, someone in here asked how you would do some bit flipping with haskell and they answered with a whole essay on "simulating" a state machine in haskell to do it.
>>
>>56428696
Don't spoil it, asshat.
>>
>>56428713
>bit flipping
Data.Bits
>>
>>56428676
Nope. There might be use cases where a functional language would seem very appropriate, but never Haskell specifically.
>>
>>56428504
I don't care about C but your Haskell sorta sucks. Why are you recurring over a list? That's why map exists.

main   = mapM_ putStrLn (tri 'k')
tri = reverse . pad . make
pad = zipWith (++) (iterate (' ':) [])
make c = map row (down c)
row c = up (pred c) ++ down c
up c = ['a'..c]
down c = [c, pred c..'a']
>>
>>56428713
>Last month, someone in here asked how you would do some bit flipping with haskell and they answered with a whole essay on "simulating" a state machine in haskell to do it.
That person just sounds like an idiot.
>>
>>56428676
If you want to write code properly as you put it, I find that Haskell just encourages it a lot more. There have been plenty of times where I've wished that I could just be lazy and do things the bad way with a global variable, but being forced to do it right ends up being worth it in the long run.

There are a lot of interesting concepts that come out of "everything is immutable" that are useful even outside of that context. Here's an example of a command line argument library I wrote using monads. It automatically generates all the documentation and handles choosing which branch depending on the command line arguments. The type of each command line argument is automatically inferred based on usage. Commands can also be nested. Not sure how you would do this in another language without it being awkward.

cli "Description of my program." $ do

command "add" $ do
thing <- argument "thing-to-add"
otherThing <- option 't' "some optional value"

let thing2 = case otherThing of
Nothing -> 0
Just x -> x

run (addThing thing thing2)

command "delete" $ do
id <- argument "id"

run (deleteThing id)

command "edit" $ do
id <- argument "id
thing <- argument "thing"

run (editThing id thing)
>>
>>56428732
Help me out, can you give me some? I've looked into it before, but none of it's ever stuck.
>>
>>56428722
snap kills dumbadoor
>>
>>56428832
>There have been plenty of times where I've wished that I could just be lazy and do things the bad way with a global variable, but being forced to do it right ends up being worth it in the long run.

Stateful programming doesn't mean making everything global, you stupid haskell autist.
>>
>>56428832
>thing2
Prelude.maybe n j x = case x of
Nothing -> n
Just y -> j y

Data.Maybe.fromMaybe n = maybe n id
>>
>>56428769
i recursed because the next item depended on the previous
I guess I coudl've foldrd, but recursing was simpler
>>
>>56428920
No it doesn't. Each row can be defined independently, and simply. Did you read the code there?

row c = ['a'..c] ++ [c, pred c..'a']


You're still too busy thinking imperatively of process instead of result value.
>>
>>56428504
#include <stdio.h>
#include <stdlib.h>

int main() {
int i, j, w = 20;
for (i = 1; i < w; i += 2) {
for (j = 0; j < w; j++)
putc(abs(j-(w-1)/2)>i/2?' ':'a'+(i/2-abs(j-(w-1)/2)), stdout);
putc('\n', stdout);
}
}
>>
>>56428769
Couldn't you just do
up c = ['a'..c]
down c = reverse $ up c

?
I'm not too familiar with hasklel
>>
>>56429024
Well yeah, but reverse is O(n) in time and memory.
>>
>>56429038
And what is [c, pred c..'a']?
>>
>>56429018
Pajeet, nobody wants to have to grab a notebook to understand your poocode.
>>
Hey, I need some work done on a periscope live stream downloader to add some features. Who needs the work? I know fuck-all about using command-lines but the script has a github page:
https://github.com/nikisby/periscope.tv
As you can see, no updates for a long time.
>>
>>56426875
https://github.com/lehitoskin/ivy
>>
original fag with the triangle question here
#include <stdio.h>

int main () {
printf("alphabet letter: ");
char limit, padding; scanf("%c", &limit);
char a = (limit<'A') ? 'a' : 'A'; padding = limit-a;

for (char row=0, c=a; c != limit; row++, padding--, c++)
{
for(char space=0; space<padding; space++) putchar(' ');
for(char left=0; left<row; left++) putchar(a+left);
putchar(c);
for(char right=row-1; right>=0; right--) putchar(a+right);
printf("\n");
}
return 0;
}

Is there any way to make it more concise and pretty?
>>
>>56429174
Here's mine:
#include <stdio.h>

int main(int argc, char **argv) {

char ch = argv[1][0];

for (char inner = 'a'; inner <= ch; inner++) {
for (char space = ch; space > inner; space--)
putchar(' ');
for (char start = 'a'; start < inner; start++)
putchar(start);
for (char end = inner; end >= 'a'; end--)
putchar(end);
putchar('\n');
}

return 0;
}
>>
If I'm using HttpWebRequest/Response to get links from a website (e.x., nyaa) in C#, how would I actually end up allowing the user to access the links within?

            string userInput = "jojo"; //Console.ReadLine();

string pageContent = null;
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create($"http://www.nyaa.se/?page=rss&term= + {userInput} + &user=64513");
HttpWebResponse myres = (HttpWebResponse)myReq.GetResponse();

using (StreamReader sr = new StreamReader(myres.GetResponseStream()))
{
pageContent = sr.ReadToEnd();
}

Console.WriteLine(pageContent);
Console.ReadKey();


This returns all the items within the nyaa RSS search results page related to Jojo (i.e. Part 4). I can make out tags like <title> and <link> in the terminal; how do I get at all of that? Regex? There's apparently something called the "HTML Agility Pack" that looks like a whole other can of worms.
>>
>>56426714
Currency exchanger using some web api, don't abuse the key pls only 1000 calls per month/

Either run it like
exchange.py usd aud
which gives exchange rate from usd to aud, or like
exchange.py 5 usd aud
which exchanges 5 usd to aud.
#!/usr/bin/python3
import sys
import urllib.request

# API from: https://www.exchangerate-api.com/
# Supported currencies: https://www.exchangerate-api.com/supported-currencies
API_KEY = 'c2d78d1aa8ab7c2cbad2339f'
URL = 'https://www.exchangerate-api.com/%s/%s/%f?k=' + API_KEY

def main(args):
invalid_input = False
from_cur, to_cur = '', ''
amount = 1.0
result = 0.0

if len(args) == 2:
if not args[0].isalpha() or not args[1].isalpha():
invalid_input = True
else:
from_cur, to_cur = args[0], args[1]
result = rate(args[0], args[1])
elif len(args) == 3:
if not args[1].isalpha() or not args[2].isalpha():
invalid_input = True
else:
amount, from_cur, to_cur = float(args[0]), args[1], args[2]
result = exchange(amount, args[1], args[2])
else:
invalid_input = True

if (result > 0.0) and not invalid_input:
print(str(amount) + ' ' + from_cur + ' = ' + str(result) + ' ' + to_cur)
else:
print('Invalid input')

def rate(from_cur, to_cur):
response = urllib.request.urlopen(URL%(from_cur, to_cur, 1.0))
return float(response.read())

def exchange(amount, from_cur, to_cur):
return rate(from_cur, to_cur) * amount

if __name__ == "__main__":
main(sys.argv[1:])
>>
>>56429210
use python tb,h
>>
>>56428769
the lower half of this is unreadable though
it isn't clear how row and down work together with the mutual recursion
>>
>>56428305
Is this not a O(n^2) algorithm? How is this faster than quicksort? Especially randomized quicksort.
>>
>>56429141
Anyone?
>>
>>56428676
Because fun things are fun
>>
>>56429227
>don't abuse the ky pls only 1000 calls per month/
Just don't post the API key you retard.
>>
>>56429227
>giving out your api keys on the internet
you're really new to this, huh
>>
>>56429207
>argv[1]
why not [0]?
and does it have to have the names argc and argv everytime

can I do
main (char c; char **left)

?
>>
>>56429246
$ ./a.out u;

argv[0] <- "./a.out"
argv[1] <- "u"


Also, argc and argv are just conventional names, they can be anything
>>
>>56429227
delete this
>>
>>56429231
What? There is no mutual recursion. How is this difficult to understand?

make 'd' 
= map row (down 'd')
= map row "dcba"
= [row 'd', row 'c', row 'b', row 'a']
= ["abcdcba", "abcba", "aba", "a"]
>>
>>56429273
yeah, I realized when I posted there's no mutual recursion

but even then, its hard to visuzlie
>>
anyone here use Dvorak keyboard? does it help with programming at all?
>>
>>56429273
And I may as well expand row.

row 'f'
= up (pred 'f') ++ down 'f'
= up 'e' ++ down 'f'
= ['a'..'e'] ++ ['f', 'e'..'a']
= "abcdefedcba"


Just apply the functions bruh.
>>
>>56429243
>>56429245
>>56429270

The program won't work without the API key, you can literally sign up for the site with any email instantly and get a free 1000 calls per month, the link is in the code. If somebody really did for some reason want to waste all my API calls I would just make a new account.
>>
Is it possible to print only the first 2 digits after comma of a floating point value. e.g.
double f = 0.352833;
printf("%magixf", f);

so as to output 35 instead of 0.35.
>>
File: 1363397541605.png (706KB, 810x608px) Image search: [Google]
1363397541605.png
706KB, 810x608px
>>56429141
What kind of compensation do I need to give for someone to be interested?
>>
>>56429332
$12
>>
>>56429229
Well I'd like to have this utilize a GUI that's going to be part of a somewhat larger program and that's a pain and a half in the ass in Python; if it was just going to retrieve a link, I'd use Python and make it a CLI
>>
>>56429346
Are you serious or just taking a piss out of me?
>>
>>56429367
what kinda features you need
>>
>>56429367
Takin the piss, ain't no way in hell I'm going near a windows batch file project.
>>
File: 1459143271599.png (2KB, 91x30px)
1459143271599.png
2KB, 91x30px
What do you call this part?
It's programming related because I need to give the variable a meaningful name.
>>
>>56429390
call it
meridiem


AM stands for ante meridiem and PM stands for post meridiem
>>
>>56429390
As for the actual meanings of AM/PM, they come from the Latin "ante meridiem" ("before noon") and "post meridiem" ("after noon").
>>
>>56429331
%.2f ?
>>
>>56429377
1. Auto-refresher to check if there's a stream going on
2. Automatically begin recording/downloading stream when available

See, the streamers that I want to record from stream when I usually sleep or I'm not home so I want to be able to download their streams even while away. This wouldn't be a problem but the particular streamers ALWAYS delete their broadcasts.
>>56429380
What's wrong with batches? Again, no idea concerning scripts.
>>
>>56429421
>>56429434
Interesting, thanks.
I've always wondered the actual meanings.
>>
>>56429443
Nothing inherently wrong with batch scripts, I just hate the syntax and working with them. I'm sure some people love it.
>>
>>56429469
Ah ok, so it's just the platform being used that you dislike and not it being more difficult to work on?
>>
>>56429238
With 100,000 random ints
>std::sort 0.0190s
>std::sort_heap 0.0180s
>quick sort 0.0205s
>merge sort 0.0250s
>comb sort 0.0285s
>insertion sort 9.384s
>bubble sort 28.957s

With 10,000,000 random ints
>std::sort 2.509s
>std::sort_heap 11.049s
>quick sort 2.379s
>merge sort 3.695s
>comb sort 4.325s

With ±3% variation in time from run to run.
>>
>>56429480
Well the issue for me is that the times when using batch scripts is the ideal solution are fewer than it would take to make me care about learning the syntax and all that. It's just pretty limited compared to something simple like python and just doesn't seem worth the time to learn.
>>
>>56429499
Mostly as expected then. Not terrible performance considering it's basically bubble sort though.
>>
Working my way through programming exercises of chapter 11, C Primer Plus 6th edition.
Comfy as fuck.
>>
>>56426714
What are you guy's thoughts about microsofts new experimental F-star language? It's like F# but with less .net baggage and with HKT's.
>>
>>56429576
I remember those days, yes very comfy.
>>
>>56429586
What are you doing now?
>>
>>56429440
>>56429405
No stipp prints the 0. in front. I got a workaround
char temp[6];
sprintf(temp, "%.2f", f);
printf("%.2s", temp+2);

But it isn't that pretty.
>>
>>56429577
it's pretty nice, but it's not really supposed to replace F# in any way. it's very much an experiment, and at that point Idris would be a much better option.
>>
>>56429576
im in chapter 6, good luck senpai
>>
How do I learn webgl? Everything I read is too simple or too complex. I only want basic 2D stuff.
>>
>Trying to one-man an MMORPG in JavaScript
Just kill me now.

>Inb4 Sepples
Fuck off with your meme language.
>>
>>56429600
I've done some projects, currently working on a simulation of genetic drift in populations (just pop size vs allele fixation rate) as a warm-up to a simulation of bacteria evolution. I've also done a simple toy language and a 2D platformer in C

Mind you I finished C Primer Plus only two years ago.
>>
>>56429577
Using SMT as a technique for automated theorem proving is a neat idea.
>>
File: Capture.png (35KB, 698x681px) Image search: [Google]
Capture.png
35KB, 698x681px
>>56428504
Fun problem
>>
>>56429614
Thanks, same to you.
Chapter 10, Pointers and Arrays, can get a little difficult but don't give up, make sure you understand most of the chapter after going into the programming exercises. I had to slowly reread the entire chapter before I could complete the exercises.

>>56429655
Impressive. Can I see your 2D platformer or something? What library did you use?
>>
>>56429689
What is this?

Also, I remember doing this problem as an exercise from C Primer Plus a couple years ago; literally couldn't finish it and got upset. Wrote it in under 2 minutes this time. Hooray.
>>
>>56429604
ah, that's what you want

something like this would work, don't think you can do it with formatting
printf("%d", (int)(f * 100) % 100);    
>>
>>56429707
Mathematica
>>
It seems that C-with-classes is the most sane and sensible way to use C++.
>>
File: Capture.png (26KB, 697x662px) Image search: [Google]
Capture.png
26KB, 697x662px
>>56429689
Realized there were some serious missed opportunities with this
>>
File: shittygame.webm (2MB, 640x360px) Image search: [Google]
shittygame.webm
2MB, 640x360px
>>56429704
Here's an old webm I found, it's pretty much it though
>>
>>56429782
You could also use it like it's Java ;)
>>
>>56429782
It seems that not using C++ is the most sane and sensible way to use C++.
>>
>>56429790
Also, I used SDL
>>
>>56429822
Is SDL with C good, or should I wait until learning C++?
>>
>>56429813
No, vectors, classes (protip: classes doesn't always mean OOP), and templates are still a very useful feature of C++ that can be used to augment and improve conventional C code.

>>56429855
SDL and SDL2 are C only.
Yes it's good.
>>
>>56429855
SDL with C is fine. My game was pretty darn OOP though, but there is no need to learn a new language just for that. I wouldn't wait until learning C++, but I would wait until being fairly darn comfortable with C.

>>56429873
>C only
You can use SDL/2 with C++, nerd.
But yeah, I pretty much rewrote std::vector very simply for this game, although it wasn't hard at all.
>>
>>56429886
How did you do OOP in C?
Pointers to structs?
Sorry if I sound retarded, I'm still learning.
>>
>>56429886
>You can use SDL/2 with C++, nerd.
I know, I meant that although you can use SDL/2 with C++, it's still purely a C library, so you interact with it in the C way. You'd have to write a wrapper for it otherwise.
>>
>>56429600
Did K&R plus C Primer Plus
Still didn't really understand what was going on until I read this: http://csapp.cs.cmu.edu/ which shows you how C exactly works at the assembly level (plus other info on compiler,VM/CPUs/Cache/Processes/Hyperthreading ect.

Libgen.io only has the 32bit version (all versions before 3/e (3rd version)) but you can go on Abe Books, and buy the international 3rd version for only 10% of the cost of CS:APP on Amazon.

Also currently doing TAOSSA (The Art of Software Security Assessment) which is all done in C. Comfy
>>
>>56429141
>>56429443
I'm gonna just post a listing for this on Freelancer. With those features and it being used in Windows Batch in mind, what would be a good deadline amount, price range (based on Freelancer's terms, i.e. micro project, simple project, etc.), and what time of work would this be called?
>>
>>56429480
>https://github.com/nikisby/periscope.tv
seems interesting enough. Looks easy to do with Python. The downloader.bat that parsing is odd though and not sure what you're doing there.
>>
>>56429941
lol it isn't my project; it's some Ruskies that hasn't updated in 10 months. Unless you feel interested in the project of adding (>>56429443), can you reply to >>56429933 so I know how to structure the listing?
>>
If I learn Javascript will I be able to get a job and make some money?
>>
>>56429907
It's alright.
It's pretty simple, and easier to explain if I water it down some.
Here's an example "class":
typedef struct _dog {
char *name;
int size;
int type;
} Dog;

Dog * new_Dog(const char *name, int size, int type) {
Dog *d = malloc(sizeof(Dog));
d->name = malloc(strlen(name));
strcpy(d->name, name);
d->size = size;
d->type = type;
return d;
}
void Dog_free(Dog *d) {
free(d->name);
free(d);
}
void Dog_bark(Dog *d) {
printf("%s: %s\n", d->name, d->size > 10 ? "bark" : "BARK!");
}


If you want late binding, you can use pointers-to-functions in your struct, but I had no need for that.

For "Inheritance", I included a pointer to the "parent class" in the child's struct.

typedef struct _point {int x; int y;} Point;

typedef struct _shape {
Point location;
} Shape;

typedef struct _square {
Shape* shape;
int side_length;
} Square;

void Shape_PrintLocation(Shape *s);
#define Square_PrintLocation(S) Shape_PrintLocatoin((S)->shape)

void Square_Draw(Square *s); //etc etc
>>
>>56429920
Writing a wrapper isn't much trouble. I have something like this in one of my projects, plus code for automatic null-checking. Doing things the C way seems pretty painful.

struct SDL_Deleter {
void operator()(SDL_Surface* ptr) { if (ptr) SDL_FreeSurface(ptr); }
void operator()(SDL_Texture* ptr) { if (ptr) SDL_DestroyTexture(ptr); }
void operator()(SDL_Renderer* ptr) { if (ptr) SDL_DestroyRenderer(ptr); }
void operator()(SDL_Window* ptr) { if (ptr) SDL_DestroyWindow(ptr); }
void operator()(TTF_Font* ptr) { if (ptr) TTF_CloseFont(ptr); }
};

using SurfacePtr = std::unique_ptr<SDL_Surface, SDL_Deleter>;
using TexturePtr = std::unique_ptr<SDL_Texture, SDL_Deleter>;
using RendererPtr = std::unique_ptr<SDL_Renderer, SDL_Deleter>;
using WindowPtr = std::unique_ptr<SDL_Window, SDL_Deleter>;
using FontPtr = std::unique_ptr<TTF_Font, SDL_Deleter>;
>>
>>56429986
Your ability to get a job and make money is limited by the amount of languages you can learn.
>>
>>56429997
meant
 size < 10 
, i.e. big dogs BARK!, little dogs bark
>>
>>56429986
Namedropping languages on a resume with no other accomplishments doesn't impress anyone.
>>
>>56429986
Yes

Though learning React.js and plain javascript will pay the most in the whole js field. Go on libgen.io and download every react book you can find.

Regular java however has the most cachet, since projects like Elastic Search are all programmed in java and they hire all the time REMOTE support engineers and pay them $100k+/year (though supporting java would be a fucking nightmare that never ends).
>>
>>56429997
Where's the inheritance and polymorphism?
>>
>>56429997
With my current knowledge I understand the first block of code but not the second one.
>>
>>56430056
Download K&R, flip to structs page and understand it in about 10 minutes of reading.
>>
um, is this right, if feel like its not
#include <stdio.h>

int main () {
printf("evaluate s1 = 1 + 1/2 + 1/3 + 1/4 + 1/5 .. 1/n\n"
"and s2 = 1 - 1/2 + 1/3 - 1/4 + 1/5 .. 1/n\nwhere n equals: ");
unsigned short n; scanf("%hd", &n); double s1 = 0.0, s2 = 0.0; _Bool sign=1;
for(short j=1; j<=n; j++)
{
s1 += 1.0/j;
s2 += sign ? 1.0/j : -1.0/j;
sign = sign ? 0 : 1;
}
printf("s1 = %f\ns2 = %f\n", s1, s2);
return 0;
}


$ ./a.out 
evaluate s1 = 1 + 1/2 + 1/3 + 1/4 + 1/5 .. 1/n
and s2 = 1 - 1/2 + 1/3 - 1/4 + 1/5 .. 1/n
where n equals: 4000
s1 = 8.871390
s2 = 0.693022
$ ./a.out
evaluate s1 = 1 + 1/2 + 1/3 + 1/4 + 1/5 .. 1/n
and s2 = 1 - 1/2 + 1/3 - 1/4 + 1/5 .. 1/n
where n equals: 30000
s1 = 10.886185
s2 = 0.693131
>>
>>56430034
I briefly showed some "inheritance", if you want polymorphism, as I said, you need to use function pointers in the structs, and that is a bit more work.
typedef struct _animal {
void (*speak)(void);
} Animal;

typedef Animal Dog;
typedef Animal Cal;

void Dog_speak(void) {
puts("Bark!");
}

void Cat_speak(void) {
puts("Meow!");
}

Dog * new_Dog(void) {
Dog *ret = malloc(sizeof(Dog));
ret->speak = Dog_speak;

return ret;
}

Cat * new_Cat(void) {
Cat *ret = malloc(sizeof(Cat));
ret->speak = Cat_speak;
return ret;
}

You can go further with this of course, you'll always pass the point where you might as well be using a language that just supports OOP in the first place, though.
>>
File: 1410502059246.gif (448KB, 748x341px) Image search: [Google]
1410502059246.gif
448KB, 748x341px
>>56429933
Anyone?
>>
>>56429782
C-with-templates and classes desu. Data being bound to data is good for data structures at the very least, because iterators and such can abstract away the data structure and data structures are indeed things which are sensible to own functions.

The java stuff like "ExecutionManager" where classes are made simply to execute a single function is extremely stupid and doens't need to plague software. Indeed, objects and message passing are useful, it's object-oriented programming that's bad, the style of programming doesn't need to be oriented around objects for one to use objects.

Let's face it, structs with functions that take pointers to them (like for a hashtable or linked list) are pretty much objects anyways. The functions are just syntatically seperate.
>>
I posted this in wdg, but might be better here.


If I create an application that can push data to Salesforce, can it work with Salesforce Marketing Cloud to create leads?

I dont know a thing about their Marketing Cloud product.

Is it the same API? How can I push data to Marketing Cloud?
>>
>>56430139
>it's object-oriented programming that's bad, the style of programming doesn't need to be oriented around objects for one to use objects.
THANK YOU
>>
>>56430139
>tfw classes with just a constructor and one method that just uses the fields of the instance
My OOP professor literally does this.
I don't get how they don't see it as this:
public class Addition {
private int x;
private int y;

public Addition(int x, int y) {
this.x = x;
this.y = y;
}

public int sum() {
return x + y;
}
}
>>
>>56430139
Yes I forgot to mention templates.
I pretty much agree with you on everything. procedural programming with objects is possible.
>>
File: untitled.png (7KB, 858x70px) Image search: [Google]
untitled.png
7KB, 858x70px
is this true
>>
>>56430189
On this topic, is it wrong to make "free-floating functions" in Java like this?
public class MyFunction {
public static int call(int arg1, int arg2) { /* ... */}
}

?
You never have to instantiate it so it's pretty much the same as a free-floating function, right?
>>
>>56430220
You'll never be tested on using vim or emacs. You will be tested on writing code by hand on a whiteboard without autocomplete.
>>
>>56430220
The part of git is true, I don't know about the editors since I've never used them.
But having strong opinions about what people should use or not is concerning.
>>
>>56430220
TE vs IDEA is strictly preference.
Don't listen to vim/emacs cultists, nor VS drones.
>>
What a good resource to learn SDL for C?
>>
>>56430288
LazyFoo.
>>
File: 2016-09-05.png (27KB, 562x682px) Image search: [Google]
2016-09-05.png
27KB, 562x682px
>>56429789
Mine just used a for loop.
>>
>>56430288
The official website is a good resource. By all means, avoid the LazyFoo tutorial, it is all kinds of backwards. Very bad design choices on his part.
>>
>>56430311
LF uses C++ actually. Although you can easily convert it to plain C.
>>
File: progress.png (125KB, 1688x1172px) Image search: [Google]
progress.png
125KB, 1688x1172px
Working on a small finance tool to max my savings + get as much possible cash-back on my credit cards
>>
>>56430320
>>56430311
LazyFoo or Official Website?
>>
>>56430353
http://lazyfoo.net/tutorials/SDL/16_true_type_fonts/index.php
Check out his code. It's atrocious.
>>
>>56430220
The part about the VCS is true, but vim and emacs are holy.
>>
thing = getThing();
if (thing == NULL) {
puts("error");
}
else {
otherThing = getOtherThing();
if (otherThing == NULL) {
puts("error2");
}
else {
lastThing = getLastThing();
if (lastThing == null) {
puts("something is wrong with that guy to code like this");
}
}
}
>>
>>56426714
Best tips before going to an interview? (Aiming for a C#, WPF position.) I haven't send any CVs but gonna prepare well.
>>
Anybody got an idea how to use clang-cl in Microsofts Visual Studio Team Services?
>>
>>56430383
>>56430320
I have some experience with PyGame.
I'll go with the official website.
>>
>>56430432
Learn some Haskell, it works wonders.
source: personal experience
>>
>>56430432
Write code on whiteboard, solve interview problems
>>
>>56430478
>Write code on whiteboard
That's actually a very good tip, Intellisense babies me too much.
>>
>>56430314
I wish Mathematica wasn't behind a super expensive paywall. It is one of the few things which are good in this world.

I mean, it supports both procedural and functional programming styles really well, while being the best symbolic programming language in existence and giving access to awesome libraries for anything mathy. And despite having a lot of innovation from a language design perspective, it's easy enough to pick up that you can just use it without realizing how powerful the framework under the hood is.
>>
someone post the tweet convo of the guy saying that OOP's problems is trying to fit data into types instead of writing functions that operate between types
>>
just put ads up on facebook and craigslist

here goes nothing!
>>
>>56430651
>Wait! I'll do the work!!!
It's not gonna happen here dude.
>>
>>56430343
Neat-o
>>
>>56430657
what do you mean?
>>
>>56426714
>What are you working on, /g/?
This noose if I can't get this program down pat.
>>
My productivity has doubled ever since I started writing C in Linux.
>>
File: 1469215377252.png (272KB, 480x434px) Image search: [Google]
1469215377252.png
272KB, 480x434px
>Haskell shills are here.
>>
>>56430684
what do you mean?
>>
>>56430664
Thanks! I've always had a bit of a problem saving so I figure that programming out the logic of it will help.

I don't get shit for interest at my bank so I need to absolutely max my cash-back bonuses and divert 10-20% into Vanguard
>>
is it autistic to make a constant have the smallest type ever?
like, if I have a constant FREEZING, which has value 0, is it really that bad to make it a _Bool?

I assume when they're compared against, they're promotedand used.
does it really matter?
>>
>>56430711
What are you planning to use for persistence of data? Or are you just working on the logic right now?
>>
File: 1469158814143.jpg (224KB, 600x800px) Image search: [Google]
1469158814143.jpg
224KB, 600x800px
>>56430711
Applied Autism in action.
>>
>>56430727
I'd make it the type that it's going to be compared to.
>>
>tfw can't stop thinking about that lolcow that goes on every /dpt/ thread and bashes haskell for no reason
>can't stop thinking about why someone would do that, just be hostile and have really bad comebacks such as "KILL YOURSELF"

why would anyone do that
he even has his own oc pics of things vommiting in the background with a screenshot of "hasklel" code

is it a mental illness, is he the same faggot that brings in /pol/ topics
>>
>>56430731
Logic for now, yeah
What I usually do for saving data in Racket is just write out a hash of everything important to a file, then read it back in on load. Not a very creative solution, but it works

>>56430735
It's a powerful force anon
>>
>>56430782
>defending hasklel
>>
>>56427143
I don't wh
>>
File: 1466478227112.jpg (45KB, 523x476px) Image search: [Google]
1466478227112.jpg
45KB, 523x476px
>>56430782
>>
>>56430795
there he is
seriously, can you tell me why you go to such lenghts to talk shit about haskell
>>
>>56430801
Had the POST button on auto, lol
I was going to say you don't need to use a regex for that, but it doesn't really matter
>>
>>56427144
thank you very much
>>
>>56430227
that's perfectly fine. no point instantiating an object just to execute a function, it decreases code readability.
>>
>>56430832
Why do people complain about there being no such functions, then?
>>
File: 1468882928057.png (199KB, 439x392px)
1468882928057.png
199KB, 439x392px
Employed Haskell programmer reporting in!
>>
Could I code a program that rings a buzzer every time someone shitposts in this general.
>>
>>56430872
Sure, either hardcode a filter list or get into Natural Language Processing and train a neural network with recognizing shitposts.
I think some social network did the latter recently.
>>
>>56430872
>code a program
Holy fuck, how normie can you get jesus christ
But yeah, you could, with some advanced (or not so much) learning, your favorite http library and html parser, and your favorite microcontroller equipped with a buzzer. I imagine you'd use Python for the former two and C for the last.
>>
>>56430901
>not coding apps
Get a load on this nerd.
>>
>>56430901
"to code a program" is perfectly valid and correct English.
>>
>>56430901
Ok how about a I shit a program. Would that be more appropriate?
>>
>>56430867
cool
what language do you code in for your job?
>>
*Buzzz*
>>
im in chapter 7 of c primer plus
when does it get good
>>
>>56430220
Version control is really useful if you ever work with one or more people. I don't see how you could collaborate without it.
I used to beleive the shit about ancient text editors being dumb, but then one time I had to ssh into a server at work and yeah, had to use vim or nano. I use atom for everything else but knowing how to use them for when they are indeed the only thing on a system you should know them. You don't lose anything not knowing them.

>>56430846
Java's boilerplate of functions having to be owned by a class is kind of a nuance, but hey at least it can act like a pseudo-namespace (which packages are anyway).
>>
>>56430961
14 is where it got great, gets good before that probably
>>
File: 1401750602409.jpg (86KB, 584x601px)
1401750602409.jpg
86KB, 584x601px
>>56430934
>>
>>56430934
fucking top HASKLEL
>>
>>56431006
*buzzzzzzzz*
>>
>>56431006
there he is again
why do you hate haskell so much
tell us
>>
>>56430793
Usually I use read-json / write-json, since it's all hashes anyway.
>>
>>56430969
>but then one time I had to ssh into a server at work and yeah, had to use vim or nano

Or you could have just scp/SFTP the files, edited them, and uploaded them back.
>>
when doing shit in visualstudio and using controls to connect to a DB.

is it better to have datasets for each control or a global dataset with all the info in the DB?
>>
>>56431015
I'm not that guy. I am >>56430795 though. I like Haskell a lot though. Haven't put enough time in to learn it well enough to do much in it though. I wish I did, would be useful right now.
>>
arraylist.get(index).setAttribute(5);

Does this actually change the item in the arraylist, or does .get() return a copy and .setAttribute() set something in that copy, leaving the original unmodified?
>>
>>56430934
HASKLEL SHILLS BTFO
>>
>>56431111
It's getting boring, and I don't even use Haskell.
>>
>>56431049
I thought you really hated haskell
It made me mad that someone would do something like unironically.

Safe travels.
>>
>>56430961
At 10 shit will slowly start to rise up
>>
>>56431120
Someone does, he just isn't me. Actually, more than one person does.
>>
Serious and honest question to everybody out here who has learned Haskell.
Why did you do it?
>>
>>56431153
I didn't learn Haskell but I did learn functional programming with LISP, first because I had to for University, and then because I saw how much clearer and more reliable functional thinking can make your programs.
>>
File: haskelllogo.png (49KB, 1000x716px) Image search: [Google]
haskelllogo.png
49KB, 1000x716px
Haskellfags,

How did you learn Haskell?

I'm thinking of going through Thinking Functionally With Haskell by Bird. I've read some LYAHFGG but it was pretty bad. I read through two lectures in a Haskell course as well. So I've got a decent foundation but I want to really learn the language. Recommendations?
>>
>>56431153
I heard it was super hard and wanted to challenge myself.
Turns out, haskell is the most logical and easy programming language I've ever learned, and I know python.

I also like that a typical program is super short.
take a look at xmonad, its only 1000 lines (including comments)
i'd say 600 lines of actual code in haskell can make a god tier tiling wm
>>
>>56431179
in this order
>learn you a haskell for the greater good
>real world haskell
>parallel and concurrent programming in haskell
after that, you can do thinking functionally, but it won't matter that much
maybe try functional data structures
>>
>>56431184
How long did it take you to learn it?
Also, how did you learn it?
>>
>>56431153

Freshman CS course was taught using that language.
>>
>>56431202
Will get started on Real World Haskell, thanks a bunch, it looks great.
>>
>>56431234
LYAHFTGG is short and concise
you can get it done pretty fast

>how di dyou learn
by reading the book and doing my own short projects

if you want excersices, just do any excersises from any book like c primer plus
>>
>>56431278
learn you a haskell is much better though
>>
>>56431295
I wasn't keen on it. Felt too much like an online tutorial than a real book.
>>
>>56431317
real world haskell isn't very good imo
lyah at least is very logical and almost everything makes sens (except mayb the monad parts)
but then again, does anybody understand monads by reading about it
>>
I'm using Single File PHP Gallery (https://sye.dk/sfpg/) on a website. My problem is, that I have directories named "2012 xyz", "2012 something" and "2014 abc". Currently, the gallery is ordered alphabetically, but I'd like to order them based on last modification date, aka newest files/directories first.

Any ideas?
>>
How can I order an array of strings based on the length of the first word of each?
This is in C btw.

This is what I have so far:

void ShowIncreasingFirstWordLen(char stringArr[][64], int n)
{
char words[n][32];
int i;
for (i = 0; i < n; i++)
words[i] = GetWord(stringArr[i]);
qsort(words, n, 32, compare);


}
>>
I'm just trying to reverse a string, but it doesn't work on strings with lengths that are even.
#include <stdio.h>

void reverse(char s[], int begin, int end)
{
int toSwap;

while(begin < end)
{
toSwap = s[begin];
s[begin] = s[end];
s[end] = toSwap;

--end;
++begin;
}
}

int main()
{
char s[] = {'p', 'i', 'n', 'o'};
reverse(s, 0, 3);
printf("%s\n", s);
}


I did it on a piece of paper, and it seems fine to me but I get this from console:
>onip�

Piano works good, though.
>>
I'm working on a bot that posts a new /dpt/ whenever the old one reaches 300 posts
>>
>>56431465
How does it solve captcha?
>>
>>56431439
Turns out I was overcomplicating my existance.
nvm fixed it :^)
>>
File: Oh no cirno frog.jpg (19KB, 193x187px)
Oh no cirno frog.jpg
19KB, 193x187px
>>56431465
That's before the bumplimit, bwaaaka.
>>56426714
>tfw one of your classes almost hit 1kLOC
This slowly is becaming harder to manage.
>>
>>56431537
What does your program do?
What lang?
>>
>>56431451
You're missing the null terminator, newbie.
>>
File: CrH9WtTUEAAnJcw.jpg (250KB, 1280x1920px)
CrH9WtTUEAAnJcw.jpg
250KB, 1280x1920px
>>56431556
It's just a simple CRUD for managing Employees, C# + WPF.
>>
>>56431451
char s[] = "pino"; // {'p', 'i', 'n', 'o', '\0'};
>>
>>56431575
Post screenshots.
Also, who is that qt?
>>
>>56431567
>>56431582

Wew. As someone who learned Java and C++ in school, I'm glad I'm going through all these exercises in K&R. Thanks, Anons.
>>
>>56431451

You've got some undefined behavior there. You're using printf on s, which is not null terminated, whether you use 4 characters or 5. Try with something like this:

char s[5] = "pino";


Note: It is important here that the string variable be stored as an array, rather than as a pointer to a string literal. Otherwise, GCC will store the string in read only memory, rather than on the stack. But nonetheless, the use of a string literal in either scenario ensures that the string will be null terminated, rather than using the { array, syntax } that is prone to user error with regards to null termination.
>>
>>56431655
>It is important here that the string variable be stored as an array, rather than as a pointer to a string literal.

What is this distinction? Like, I know what you are saying but what would the syntax be for making an array vs. a pointer to a string literal?
>>
File: 81da268b06.png (26KB, 815x498px)
81da268b06.png
26KB, 815x498px
>>56431588
I kinda want to re-design the list view.
>Also, who is that qt?
Just a random cosplayer from twitter.
>>
>>56431690
Se ve muy bien senpai desu.
¿Cuánto tiempo llevas trabajando en ese programa?
¿Cuántos años llevas programando?

looks good senpai desu
How much time have you spent working on it?
How many years have you been programming?
>>
>>56431499
Outsourced to the Chinese

There's services where you pay half a cent for a solved CAPTCHA
>>
Why do so many people say PHP is a bad language? I used it to make a 3d game once and it turned out pretty good.
>>
>>56431537

Try 4k or more. Still small compared to the real world, but nonetheless at the point of becoming difficult to manage.

>>56431682

char s[5] = "pino"; // This is stored on the stack
char *r = "pino"; // This is stored in .rodata, and really should be declared const
>>
>>56431779
prove it
>>
>>56431779
it's a poorly designed language that draws novice programmers into bad thinking
>>
>>56431750
Gracias amigo.
3 months, and I''ve programming since 4 years ago (though just taked programming seriously until recently.)
>>56431794
>Try 4k or more. Still small compared to the real world
I've seen some C projects with 4k uncommented LOC, I wonder how they manage that kind of length.
>>
>>56431779

PHP might not be the worst language you could use, but it is the worst language people use today. Its standard library has no consistent naming structure, its syntax is a mess, and confusing when coming from any other language (i.e. it has the wrong associativity for ternary, == is unusable like in JavaScript, etc...), and in general, every other language is a better choice for any given task, even web development. It is by far the least pleasant language I have ever worked with.

>I used it to make a 3d game
That sounds like a terrible idea. Your game might not have turned out terrible, but you made it with a terrible handicap.
>>
>>56431779
The language is a shitshow

but it's a powerful shitshow.
>>
>>56431807
You prove it

>>56431817
It's a really good language trust me, I've seen countless forum posts saying it's good

>>56431849
It's not a mess, it's a really good language. See above

>>56431873
Powerful means good right?
>>
>>56426875
I'm open to new ideas and recommendations
https://github.com/enigma424242/RPG/blob/master/textbasedrpgtest.py
>>
>>56431906
>Powerful means good right?
Means you can get shit done with it. It doesn't imply that you can get shit done nicely though.
>>
>>56431941
suddenly glad I never learned python
>>
>>56432055
His is pretty bad code, Python isn't that bad.
>>
How can I know fgets() received EOF?
>>
>>56432162
You can't. But, you can check if a file has reached EOF:
if (feof(filepointer)) {
puts("File is done!");
}


A common use:
while (!feof(fp)) {
fget(buffer, 80, fp);
//...
}
>>
Anyone have a nice clean font they like to use? I've been using Tewi for years but I'm growing tired of the pixely-font meme. Something like OP pic would be great.
>>
>>56432260
Papyrus
>>
>coding a compass-like application in Android
>trying to make my compass image rotate relative to north
>I.E, if I'm facing north. North is the top of the screen, if I'm facing south, north is bottom of screen.
>Copy/pasting code from stack overflow
>doesn't fucking work properly
>Using a guys github code for the azimuth
>doesn't fucking work properly

Dunno what to do m8's. My app is complete except for this one part. I swear, no one actually knows how to do this in an open-source way. Seems there's only one good app that does it properly...
>>
>>56431846
you should ask your mom
lame jokes aside, if you build it all yourself, or even like 3/4 of it, you have a feel for where everything is and what everything looks like
the bigger problem is getting there-- if it gets to the point where the fastest method is [^F, name-of-function, hit Enter a few times], you know your codebase is getting fat
>captcha: black politico
bluh?
>>
>>56432337
>not writing your own code
>expecting for it to work properly
kys mate
>>
>>56432356

Nigger please. I'd love for you to make an algorithm that does this on your own based from the unfiltered numbers that the android sensors give you. There are three of them, and each one pollutes the other.
>>
if char is signed, then is it really a bad idea to compare it against EOF?
>>
>>56432387
all you need is to mangle the sensor numbers into an image rotation factor. surely there's a warehouse of pajeets that have done such a thing
>>
>>56431906

>I've seen countless forum posts saying it's good
And I've seen countless that would argue the opposite. I've also seen this well-written argument:

https://eev .ee/blog/2012/04/09/php-a-fractal-of-bad-design/

(remove the space. 4chan's spam filters suck)

I would highly recommend any PHP developer read this, and then try to make a reasonable argument for why PHP is better than even regular old JavaScript.
>>
I have a class called Item, and it has a virtual destructor that's empty:
>virtual ~Item(){};
There are a bunch of classes that inherit from Item, and they all have their own unique destructor.
Sometimes the program crashes, and I think it has something to do with that destructor. I'm pretty sure the crash happens when I'm looping through all of the children of Item and deleting them. Am I doing something wrong?
It may be worth mentioning, the Item class has 1 pure virtual function in it.
>>
if I defined a function before main, then that will also serve as a function prototype?
>>
>>56432472
Yes.
>>
File: 1454980081516.jpg (47KB, 508x524px) Image search: [Google]
1454980081516.jpg
47KB, 508x524px
>>56432337
>coding a compass-like application in Android
>My app is complete except for this one part.
>My compass app is complete except for the compass
>>
>>56432093
How do you think I can improve it? I'm working on an engine for it.
>>
>>56432459
What happens when you remove the destructor?
>>
>>56432459

You're doing virtual destructors right, but it might be possible that you are having other issues related to destructors. I would check for use after free issues if your bug is related to destructors.
>>
>>56430782
it's a yank shitposter from /brit/, same guy who jerks off about lisp
>>
New thread: >>56432690
>>
>>56432472

Well.. it's not so much that it needs to be declared before main, so much as it needs to be declared before it is used. Defining a function counts as a declaration, so you often don't need to forward declare helper functions in the same file, unless they have some sort of circular dependency.
>>
>>56432576

Lul. Compass-like.

I have it working, but not really. It only seems to work if the compass is flat on a table. If I'm holding it in my hand flat, it's off. The actual compass points somewhere else, it's just I need it calibrated towards north so that where it points is accurate relative to the way you're facing.
>>
>>56431690
>Nachi
Mah nigga.
>>
>>56432780
https://www.youtube.com/watch?v=y5rDgwhLkEE
:3
>>
>>56427897
That's what boilerplate is you fucking donkey.
Who would write an image loading library and graphics subsystem from scratch?
Once I implement interpolation you'll eat those words.
>>
>>56432808
https://www.youtube.com/watch?v=R2khevJXqqo
:3 :3
>>
>>56432944
Superb taste senpai.
>>
>>56433016
You too.
>>
>What are you working on, /g/?

Writing a shitty webserver in python.
>>
>>56426714
>What are you working on, /g/?
Porting my profitable cryptocoin trading application from Python 3 to a new language.

Probably Scala or Java or Go.
Anything type-safe. I just can't stomach dynamic typing for anything but small projects and prototypes.
>>
>>56433307
>Writing a shitty webserver in python.

> using Python for anything.
>>
File: come_at_me.png (36KB, 1389x445px) Image search: [Google]
come_at_me.png
36KB, 1389x445px
>>56428504
>>56429689

Sorry for being late to the party, guys..

def pyramid(h)
puts (o = (c = 97).chr).center(2*h-1)
(h-1).times { o << (c+=1).chr; puts (o+o.reverse[1..-1]).center(2*h-1)}
end

pyramid 24
>>
how do i format a float to show no decimals and no rounding in C#?
>>
>>56434728
nvm i fix'd it
Thread posts: 327
Thread images: 25


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.