[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: 1467570941060.jpg (517 KB, 1521x1076) Image search: [Google]
1467570941060.jpg
517 KB, 1521x1076
What are you working on, /g/?


Previous thread: >>55414062
>>
File: 1467533384486.png (242 KB, 396x407) Image search: [Google]
1467533384486.png
242 KB, 396x407
If I have a table like this:
ID | Downloads
=============
A 1
B 2
B 2
A 1
C 5


What is an SQL query that will return
C, 5
B, 2
A, 2
(i.e. the ID and the sum of downloads, ordered by most downloaded)

I don't know what the IDs are, so I can't reference them directly. It seems like it should be easy, but I'm completely stumped.
>>
first for anime is pleb
>>
>>55425270
Why do you have copies in your database in the first place?

>>55425271
>is second
pottery
>>
>>55425271
Cum in my bum
>>
My grandmother found a bunch of her and my grandfather's writing from the vietnam war and before. In trying to get formattable versions of all of it, I've gotten really into OCR stuff.

I'm using other people's tools for the documents, but I've been working on a for fun project of using my phone's camera to recognize printed text and spit out a .txt file. It's not original, but it's interesting and I'm learning. And that's the whole point, right?
>>
>>55425257
what's UoAAMC?

scared to actually go to the site because virus
>>
>>55425270
Every fucking time I spend ages on a question, as soon as I ask for help I find the answer myself. Every fucking time.

The query I needed is:
select id, sum(downloads) as s from collections group by id order by s desc;


>>55425289
I'm writing an anime indexer. Each release that gets post has a ID referencing what anime series its from. I need this to create a banner at the top of the page with the most popular anime series for the last week.
>>
File: _20160705_114136.jpg (73 KB, 644x499) Image search: [Google]
_20160705_114136.jpg
73 KB, 644x499
Brandon? I knew you used 4chan, but i thought you only used /a/?
>>
>>55425324
Can you ask what the meaning of life is?
>>
>>55425270
use group by and sum the downloads then sort?
>>
My job is java.

I wanted it to not be as bad as I thought. It sucks.
>>
>>55425347
We fucking told you so Pajeet
>>
>>55425347
Is it because you're only payed 25 cents an hour, Pajeet?
>>
First for php
>>
File: cantonese cartoons.jpg (24 KB, 500x278) Image search: [Google]
cantonese cartoons.jpg
24 KB, 500x278
Reposting from last thread, this time with more info.

Made a 4chan image downloader in C++ using the nlohmann json library found here: https://github.com/nlohmann/json

It works fine for most threads, but for some it throws an error:

terminate called after throwing an instance of 'std::invalid_argument'
what(): parse error - unexpected '"'
Aborted


The error is not always the same but it seems to happen in threads with code tags. The json is valid though, so I don't know why it's causing errors.

The code is here: https://ghostbin.com/paste/xatce

Also, feel free to critique my bad C++ code since I'm still learning the language. Thanks /g/.
>>
>>55425270
Maybe you should learn basic SQL first?
>>
Writing a 3D cheese pizza MMORPG in WebGL
>>
>>55425350
>>55425352
It's just an internship (~15 euros per hour) during the summer, I will survive.

But never again. The one I had last summer was C.
>>
>>55425436
At least you're getting paid.
>>
working on a tmux guest project to let people watch my tmux sessions
https://github.com/mie00/tmux-guest
>>
>>55425324
Because asking the question forces you to write it out in detail.

https://en.wikipedia.org/wiki/Rubber_duck_debugging
>>
>>55425459
The only unpaid internships are pink collar memes like fashion, marketing, and media.
>>
>>55425347
what's so bad about it?
>>
>>55425401
Just tried it on this thread though, and it works... Here's a thread that it throws the error on: >>55405924
>>
>>55425578
I wish.
>>
Has anyone here been to a coding bootcamp to get into coding?

Thinking about biting the bullet and going to The Iron Yard.
>>
>>55425401
You should use snprintf instead of sprintf.
Make the get_page function return an std::string rather than writing to a file, all that file I/O is not needed at all you can just pass whatever get_page returns to the parse function.
Use string overloaded += operator instead of strncpy.
Use more descriptive variable names instead of j, o, b (i.e. data, posts, post).

As for your actual error, idk, maybe it's a bug in the library. You could try jsoncpp, I've been using it for a while and it's alright.
>>
>>55425644
>going to Meme Bootcampâ„¢
>>
>>55425644
No, that sounds stupid
>>
>>55425644
Just about finished with the Iron Yard. It is what you make out of it.
>>
File: malaysian funny pages.jpg (26 KB, 400x300) Image search: [Google]
malaysian funny pages.jpg
26 KB, 400x300
>>55425715
Thanks for the tips, anon. I'm starting to think it's a bug in the library since I've tried almost everything. I'll try jsoncpp and see if that fixes things.
>>
Asking again here: any good material to learn from as a total beginner to Haskell?
>>
>>55425800
What program were you in? And what were the hours like?
>>
>>55425807
It would roughly look like this with jsoncpp and more C++-ish approach.

static std::size_t WriteCallback(void *data, std::size_t size, std::size_t msize, void *ptr)
{
std::string *str = reinterpret_cast<std::string *>(ptr);
str->append(reinterpret_cast<char *>(data), size);
return size * msize;
}

static std::string GetPage(const std::string &url)
{
std::unique_ptr<CURL, [](CURL *ptr) {
curl_easy_cleanup(ptr);
}>(curl_easy_init());

std::string output{};

curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &output);

return std::move(output);
}

int main(int n, const char **v)
{
if(n != 3)
{
fprintf(stderr, "Usage: %s <board> <thread>\n", v[0]);
return 1;
}

std::string url{"http://a.4cdn.org/"};
url += v[1];
url += "/thread/";
url += v[2];
url += ".json";

const std::string &data = GetPage(url);
Json::Value root{};
Json::Reader reader{};

if(!reader.parse(data, root))
{
fprintf(stderr, "Failed to parse the page: %s\n", reader.getFormatedErrorMessages().c_str());
return 1;
}

uint64_t tim = 0;
std::string ext{};

for(const auto &node: root)
{
try {
tim = node.get("tim", 0).asUInt64();
ext = node.get("ext", "").asString();

// download image
}
catch(...) {
// handle
}
}

return 0;
}
>>
>>55425931
Obviously the unique ptr should be named curl and the first curl param shoulda been curl as well, kinda sloppy with the qr box.
>>
>>55425931
>return std::move(output);

Unnecessary with return value optimization. It'll be moved by default.
>>
>>55425875
>>55425875
I'm learning Javascript and spend at least 6-7 hours on the daily assignments, plus there is a 3 hour lecture Monday through Thursday. If you do it expect to have no life on the weekends.
>>
>>55425526
Reminds me of a story posted on /g/ a few years back about an autist that literally pulled out a rubber ducky and explained the problem to it. It was 2014 I think.
>>
>>55425822
"Learn you a haskell" is pretty good if I remember correctly.
>>
>>55425257
I need to make a function on haskell that shows if x mod 3 == 0, but with cycle.
This is what I have so far
esMultiploDeTres x = 3 mod (take x (cycle +1)) == 0
but it doesn't Work. Why?
>>
>>55426082
That's where the name comes from. It didn't originate on /g/.
>>
>>55426174
> cycle +1
surely you're just creating an infinite list consisting of the function "+1"
>>
>>55426261
I have to iterate with the function cycle, x +1 times, but i don't know how to do that.
>>
>>55426353
What do you mean?
What are you actually trying to do?
>>
Thinking of doing a simple DSL interpreter in C, something like:
PEN-DOWN
UP 10
LEFT 10

Should I use a hashtable, or a lisp-like assoc list for variable lookup?
It'll only have 10-50 values most of the time, so even a simple hashtable might be overkill?
>>
>>55426386
User enters a number
haskell tells you if it's muktipke of 3, with a boolean
instead of x mod 3 == 0
I have to use cycles, to produce that x that the user gives
>>
>>55426454
you can use a tree as well, but 10-50 values isn't really much.
>>
I'm working on a small AI that will hack shit for me.

Decrypting wireless traffic using wifi key ; fake AP ; WEP/WPS-PIN cracking ; payload generator (ty msfvenom) ; and some vuln i got for facebook and soundcloud.

The project work with an "actions" system (you add an action as a c file for example actions/wepcracking.c) Like that I can add as much stuff I want for the IA to do.

The whole thing is sync with a "human readable" database that way we can add AI response pretty fast.
>>
>>55426017
thanks m8. I'm actually interested in the mobile dev course but I think I'm sold.

>If you do it expect to have no life on the weekends.

one step ahead of you.
>>
I tried to implement a ring/circular buffer in Java. I want some comments/criticism on it. Is there a situation that I have not accounted for, or am I doing something in an inefficient way?

public class Ringbuffer {

static int[] buffer = new int[4];
static int read = 3;
static int write = 3;

public static void main(String[] args) {

push(1);
push(2);
pop();
pop();
push(3);
pop();
push(4);
pop();

print();
}

public static void print() {
for(int i = 0; i != buffer.length; i++) {
System.out.print(i + ":" + buffer[i]);
if(read == i) {
System.out.print("R");
}
if(write == i) {
System.out.print("W");
}
System.out.println("");
}
}

public static void push(int x) {
write++;
if(write == buffer.length) {
write = 0;
}
if(write == read) {
throw new UnsupportedOperationException("Cannot write there");
}
buffer[write] = x;
}

public static void pop() {
read++;
if(read == buffer.length) {
read = 0;
}
if(read > write) {
throw new UnsupportedOperationException("Cannot read there");
}
}
}

>>
>>55426689
looks pretty stupid desu, doesn't java have Stack?
>>
>>55425931
Thanks, I've reformatted my code using jsoncpp and your suggestions and it is running great.
>>
do you guys do anything like listen to podcasts while programming? i think i would not really listen to the podcast and not really program if i tried this
>>
>>55425337
If your going to print a full page image, at least have the decency to trim those white margins. Baka.
>>
>>55426786
I listen to moosic cuz i'm too adhd to concentrate on programming alone. if i listen to radio or whatever i dont remember shit from it even tho i react to what they say etc
>>
>>55426786
music podcasts? i do
>>
>>55426719
What exactly is stupid here? Be more specific.
>>
i'm starting my first real project and i have no idea what i'm doing

it's an API to manage Localized Strings, so it should be able to add strings to files for example, or modify certain attributes of some strings in some files (the strings have a certain defined structure)

my question is, should the program have an internal database of some sort to keep track of the strings that exist in the different files in different directories? i'm not sure what the structure of my code should be, if i should define an interface to access the files or what
>>
>>55425644
No don't be a fucking retard
>>
>>55426877
it's best if all the content is in memory and not read from disk, and if that's done it's better to fetch it from a certain memory region than to create a new region with similar data (for ex: a database) you can go nuts with the rest of the things tho
>>
>>55426852
well first, the int[4], why make a limited buffer? that'll only limit the capabilities of the object. second, why recreate the Stack object from java? find something more complex to do lol
>>
Anyone here worked as a software developer? Is it stressful? Did you feel like the demands of the job were fair?
>>
>>55426256
Did anything of value ever originated from /g/?
Serious question.
>>
>want to implement an ADB host
>need to encode RSA keys in Android's custom format, fiddling with bignums and shit

welp
>>
Why is there so much dogma and ideology in programming these days?

>this has to have C syntax
>this has to have Lisp syntax
>this has to look like Haskell
>muh macros
>muh monads
>muh closures
>this isn't good OOP
>this isn't good FP

What ever happened to using features and ideas that are good for writing a program that solves your problem?
>>
>>55427186
People are afraid of wasting the time they invested in learning a technology that might disappear, which happens very often. That's why they defend them with such a zeal.
>>
File: monad-id-law.png (20 KB, 358x260) Image search: [Google]
monad-id-law.png
20 KB, 358x260
>>55427186
monads aren't dogma or ideology
that's like calling tuples an ideology
>>

if(condition
{

}
else
{

}

or

if(condition){

}
else{

}

>>
>>55427186
>What ever happened to using features and ideas that are good for writing a program that solves your problem?
Such as macros, monads and closures?
>>
>>55427275
condition ? /**/ : /**/
>>
>>55427186
It's mostly for others interacting with your code.
>>
>>55427275
x if condition else y
>>
>>55427313
if statements or switch statements. Which is better?
>>
>>55427342
goto
>>
>>55427342
>>55427275

it really doesn't matter, stupid. You obviously don't have anything thought provoking to post.
>>
>>55427409
i++ or ++i
>>
>>55426689
First of all, push and pop are stack operations.

Secondly, you're over complicating this.

public class Ringbuffer {

Integer[] buffer;
int tail, head;

public Ringbuffer(int size) {
buffer = new Integer[size];
tail = head = 0;
}

public boolean put(int element) {
if (tail - head >= buffer.length) {
return false;
}

buffer[tail++ % buffer.length] = element;
return true;
}

public Integer get() {
if (tail == head) {
return null;
}

int element = buffer[head++ % buffer.length];
return element;
}

public static void main(String[] args) {
Ringbuffer buffer = new Ringbuffer(4);

assert( buffer.put(1) == true );
assert( buffer.put(2) == true );
assert( buffer.put(3) == true );
assert( buffer.put(4) == true );

assert( buffer.put(3) == false );

assert( buffer.get() == 1 );
assert( buffer.get() == 2 );

assert( buffer.put(-1) == true );
assert( buffer.put(-1) == true );

assert( buffer.put(-1) == false );

assert( buffer.get() == 3 );
assert( buffer.get() == 4 );
assert( buffer.get() == -1 );
assert( buffer.get() == -1 );

assert( buffer.get() == null );
}
}
>>
>>55427256
Friendly reminder that the IO monad is a stateful container and that it's inherently impure because it has side-effects.

Friendly reminder that Haskellfags will defend this, performing mental gymnastics such as "no, it is pure, it only returns impure code tainting the runtime, not Haskell".
>>
File: 1443287313792.png (387 KB, 424x600) Image search: [Google]
1443287313792.png
387 KB, 424x600
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2030.pdf

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2044.htm
>>
>>55427459
>runtime
Runtime is not real.
>>
File: <3.jpg (127 KB, 500x733) Image search: [Google]
<3.jpg
127 KB, 500x733
>>55425931
>>55425401 (You)

Been working on my 4chan image downloader. Copied most of your code but made it work fully. Now it downloads images from any thread which is great. Still feel like I'm using a bunch of shitty programming practices.

Anybody good at C++ please take a look at my code and let me know what I can improve on: https://ghostbin.com/paste/esnaj

Thanks /g/ <3

(forgot my image)
>>
>>55427489
>those tiny tits
muh dik
>>
File: Immagine.png (105 KB, 1920x1036) Image search: [Google]
Immagine.png
105 KB, 1920x1036
Hello there buddies.
I started learning C++ following some helpful advice and links found here, but due to university shit I didn't practice in about 6 months. Should I go back from the start with all my reading material or pick up where I left? Is there any article avaiable on how to improve the readability of my code? I remember someone referring to my style of writing code as newbie code. Pic provided is an example. Huge-ass comments are there so you know what it's supposed to be, as well.
>>
>>55427583
you should learn java
>>
>>55427583
please name your variables

also fucking ignore this guy:
>>55427606
>>
>>55427088
It depends on the company pretty much.
>>
>>55427583
Too many comments in damageCalc, rename your variables and do a quick blurb about the function above it
>>
>>55425257
Reminder that C is the master programming language and if you don't know C, you cannot call yourself a programmer.
>>
>>55427583
int damageCalc(int damage, int penetration, int armour, int toughness);
>>
>>55427634
Java is much better
>>
>>55427544
pedo
>>
>>55427489
Just use Python :^)
BS4 and requests make this trivial anon
>>
>>55427583
>windows
>VS
>C++
Kill yourself
>>
>>55427634
>I'm learning C so that people who masturbate to Chinese cartoons will let me call myself a programmer
>>
>>55427693
There is literally nothing wrong with any of those things (provided you are beyond 3 years of age)
>>
>>55427678
queer
>>
File: 1467708475174.jpg (58 KB, 474x604) Image search: [Google]
1467708475174.jpg
58 KB, 474x604
>>55427658
Good joke anon

>>55427708
There is literally nothing wrong with C.
>>
>>55427709
You are an ignorant, a tool and probably a miserable shill as well.
>>
What is a "wrapper"?
Something that disguises a program to operate with another language?
Help please.
>>
>>55427583
Are you me 6 months ago?

Does everybody start by making a shitty RPG in c++?

I have a job in tech now lol, good luck
>>
>>55427717
It's not a joke. Do you actually want a career and want to build useful applications? Learn Java,

Do you want to learn a hipster language that isn't one of the main languages then go learn your hipster language.
>>
File: 1438175443776.png (884 KB, 865x807) Image search: [Google]
1438175443776.png
884 KB, 865x807
>>55427751
>Do you want to learn a hipster language that isn't one of the main languages then go learn your hipster language.
>>
>>55427772
>Cshitter is a weebfag
No one is surprised.
>>
>>55427658
>>55427751
Epic meem
>>
>>55427791
>hipster code monkey hates anything that requires imagination and creativity
why am i not surprised
>>
>>55427791
As a Java programmer I don't watch anime but I enjoy to go hiking, cook, play sports, and anything outdoors
>>
File: 1440449816950.jpg (66 KB, 477x324) Image search: [Google]
1440449816950.jpg
66 KB, 477x324
>>55427791
>Unironically disliking anime on an anime website
>>
>>55427816
I also like to have plenty of sex with my girlfriend that is definitely real and not a character in some anime.
>>
File: 1403101451615.png (1006 KB, 940x719) Image search: [Google]
1403101451615.png
1006 KB, 940x719
>interview at company
>feel I did well
>mfw get email saying they are looking into other candidates

god damn that's depressing to have that happen. How the fuck do you guys cope with this?
>>
>>55427489
Looks good enough, if you're bored, you could wrap that cURL stuff into a class to use RAII.
>>
>>55427845
Easy, by not going to any interviews at all.
>>
>>55427816
>>55427836
That post was truly awful. It is painfully obvious that you do not belong here, but that is ok, there is a positive solution. Rather than trying to fit in you should strongly consider going to a site more suitable for posters like you such as reddit, tumblr, or maybe even gaia. you have plenty of options. You will be happy and we will be happy. Best of luck, but don't come back. Bye!
>>
>>55427845
was the interviewer a man or a woman?
>>
>>55427845
This happened to me once in the middle of a round of golf

Put me off for the back nine holes, I could barely hit the ball

But seriously just keep plugging lad, there will be somebody who is stupid enough to hire you
>>
>>55427845
Drinking followed by a motivation to do better
Drinking is the important part though
>>
File: 1440348968950.png (103 KB, 1437x908) Image search: [Google]
1440348968950.png
103 KB, 1437x908
>>55427845
Join the good fight.
>>
>>55427489
Looking fine although I'd still use unique ptr to init/cleanup curl as I initially shown in my post. Also there's no need to use the temporary stringstream to convert the number to a string, you can just do:
something += std::to_string(integer);


Which will be way faster than constructing stringstream with each iteration.
>>
>>55427684
I know. I've already done it in PHP and Python, like 4 years ago. I'm trying to advance my knowledge.
>>
File: 4QvA1xc - Imgur.gif (3 MB, 300x300) Image search: [Google]
4QvA1xc - Imgur.gif
3 MB, 300x300
>>55425257
Writing a genetic algorithm to find optimal lineups for shady online daily fantasy betting right now.

Still need to scrape a bunch of historical data, but it's a little bit of a pain in the ass, so I've been putting it off.

Why haven't you joined the Brogrammer master race yet?
>>
>>55426174
Por que pones espannol en tu codigo
>>
>>55427860
I browse both reddit and here atleast the discussions in r/programming reddit has interesting discussions
>>
>>55427924
I highly recommending going back and never returning.
>>
>>55427883
I couldn't get the unique_ptr working, otherwise I would have. I couldn't figure out what I was doing wrong. And thanks on the string conversion, I thought that stringstream was the only way to convert uint64 but that is definitely easier.
>>
>>55427924
Please leave
>>
File: 1461181725702.jpg (152 KB, 960x718) Image search: [Google]
1461181725702.jpg
152 KB, 960x718
>>55427924
wow
awful post
>>
>>55427865

2 senior engineers, 1 director, 2 HR

1 woman 4 men.

I even got a tour of the place. Was really nice which made me want to join them even more.
>>
>>55425822
You should really try Haskell Programming from first principles by Cristopher Allen and Julie Moronuki from http://haskellbook.com/, it is the best I have ever seen for beiginers, then you can move to Real World Haskell and some algorithms book
>>
>>55427967
>first principles
this is code for "arbitrary dogma"
>>
>>55427930
>>55427945
>>55427947
I highly recommend we start having interesting programming discussions

Such as should Objects or imperative programming taught first?
>>
How the HELL do continuations work anyway?
>>
How do I stop wasting time focusing on the little things when writing code?
>>
If I in java 10 million times add the value 10000 to an arraylist of integers then on my shitty laptop it takes 5500 msec. If I instead add a value like 5 it takes only 280 msec.

Explain.
>>
>>55428020
Java
>>
>>55427995
You pass the function the next step (the 'cobtinuation'), and it runs that with its return value instead of returning its return value.

type Cont a = forall r. (a -> r) -> r
>>
>>55428020
Autism.
>>
>>55428020
do it with bignumber
>>
>>55428020
Since numbers in Java are objects, Java caches low numbers as internal objects that are available at all times, with a large number the object is created every time it's used. Java is garbage like that, you can even override the internal objects so that stuff like 2 + 2 will not result in 4.

>>55427931
What was the problem with unique_ptr? You couldn't get the custom deleter to work?
>>
>>55428020
Use Array instead
>>
>>55427993
Neither, non-imperative functional from the getgo
>>
>>55427993
Neither, functional programming should be taught first.
>>
I'm currently learning Clojure, and going through a few 4clojure exercises. Recursion is fun..!

Here is a little snippet from my Org file for the two most recent things I solved:

#+BEGIN_SRC clojure
(#(loop [seq (rest %)
acc [(first %)]
res []]
(if (empty? seq)
(if (> (count acc) (count res)) acc res)
(if (= (+ 1 (last acc)) (first seq))
(recur (rest seq) (conj acc (first seq)) res)
(recur (rest seq) [(first seq)]
(if (> (count acc) 1 (count res)) acc res)))))
[2 3 3 4 5])
#+END_SRC

#+RESULTS:
| 3 | 4 | 5 |

#+BEGIN_SRC clojure
(#(loop [seq %2
acc []
res []]
(if (empty? seq)
(if (= %1 (count acc))
(conj res acc)
res)
(if (< (count acc) %1)
(recur (rest seq) (conj acc (first seq)) res)
(recur (rest seq) [(first seq)] (conj res acc)))))
3 (range 8))
#+END_SRC

#+RESULTS:
| 0 | 1 | 2 |
| 3 | 4 | 5 |


>>55428020
Numbers below a certain point are constant memory addresses IIRC. Bigger numbers are objects, so after you hit a certain number (Someone?), things slow down.

It's basically just a heuristic
>>
>>55428057
Here are the errors I get when I try to compile.

test.c: In function ‘std::string GetPage(const string&)’:
test.c:21:5: error: type/value mismatch at argument 2 in template parameter list for ‘template<class _Tp, class _Dp> class std::unique_ptr’
}> curl(curl_easy_init());
^
test.c:21:5: error: expected a type, got ‘<lambda closure object>GetPage(const string&)::<lambda(CURL*)>{}’
test.c:21:11: error: invalid type in declaration before ‘(’ token
}> curl(curl_easy_init());
^
test.c:21:27: error: invalid conversion from ‘CURL* {aka void*}’ to ‘int’ [-fpermissive]
}> curl(curl_easy_init());
>>
>>55428020
in java integers are stored as an object somewhere in memory.

http://codegolf.stackexchange.com/questions/28786/write-a-program-that-makes-2-2-5
>>
>>55428101
>Bigger numbers are objects
Pardon, "new objects".
>>
>>55428130
auto curl = std::unique_ptr<void, void (*) (CURL*)>
{
curl_easy_init(),
[] (CURL* ptr) { curl_easy_cleanup(ptr); }
};


Should just work, didn't compile it, tho.
>>
>>55427955
either they found you underqualified or the guy that came after you sucked up more
>>
>>55428262
At first it wouldn't compile, then I added .get() to the end of each time the variable curl was used and that compiled, but now it is giving

*** Error in `./test': double free or corruption (!prev): 0x0000000000f915d0 ***
Aborted


When I run it. What is the source of my retardation?
>>
>>55428262
nice idea tho
>>
>>55427955
That's standard procedure. they don't like to give anything away
>>
>people use languages other than C++
>they intentionally use less powerful languages
example, only in C++ you can make compilers for other languages
>>
>>55428379
Did you remove the original curl_easy_cleanup call that you had at the very end of the functions?
>>
File: afsdfadf.png (432 KB, 495x636) Image search: [Google]
afsdfadf.png
432 KB, 495x636
>>55428377

>either they found you underqualified or the guy that came after you sucked up more

yeah I emailed them asking what I needed to improve on and they said the only reason was my lack of experience.

>mfw lack of experience has been the core issue for me getting a fucking job so far

I have 1 job offer so far out of hundreds of applications. Just kill me now.
>>
>>55428447
You found the source of my retardation. I really should get one of those protective helmets with the chin strap.
>>
>>55428442
My sides
>>
>>55428442
I'll bite.

You can make compilers in almost any language.
You just need to be able to write arbitrary files.
>>
>>55428480
no, you need to be able to write in machine code, you can't do that in any language.
>>
>>55428442
(you)
>>
>>55428480
No, virtually all compilers are written in English
>>
>>55425257
There was a page with a big table and each column was dedicated to a certain skill level for software engineers (leftmost was noob and rightmost was expert), and each row was a particular skillset.

Anyone has a link?

Also I just started working at cambridge in a bioinformatics lab doing data science and damn, these people really make me appreciate my CS degree more
>>
>>55428504
>>55428442
>tyronelaughingfor20aeons.jpg
>this_is_bait.png
>disappointedpepe.tiff
>>
>>55428508
lol, you are stupid compilers are written in C++, english is not C++.
>>
>>55427416
+i+
>>
>>55428530
I wrote a compiler in Haskell once
>>
>>55428453
well here's the thing, if there was a list of technologies they asked for, and you explained to them that you were involved in em, and they didnt ask you technical questions about those technologies then they arent very qualified themselves anyway, what you need to do is build a portofolio with bullshit meme examples of functioning code in those technologies, and either present to your potential employers or make up some bullshit past client you did the examples for.
>>
>>55428550
wtf is this?
>>
File: 1420605111401.gif (2 MB, 479x349) Image search: [Google]
1420605111401.gif
2 MB, 479x349
>>55428480
>I chose, poorly
>>
>>55428550
Did you create your own monad?
>>
>>55428514
Nvm found it: http://sijinjoseph.com/programmer-competency-matrix/
>>
>>55428514
Where you living lad?
>>
>>55428579
Well I moved to cambridge for the summer cause I'm working here. Starting a MSc in machine learning in autumn so I'll move to london then
>>
>>55428571
>object-oriented
Dropped like a fucking bomb
>>
>>55428596
Didn't really answer my question desu
>>
>>55428618
I'm living in Cambridge. I lived in York for the past few years cause I did my BEng there
>>
>>55428628
Where in Cambridge?
>>
>>55428639
Oh. Queen's college (I'm working for university of cambridge)
>>
File: 1305578342879.jpg (22 KB, 400x400) Image search: [Google]
1305578342879.jpg
22 KB, 400x400
>>55427464
>and closures were introduced by Guy Steele in SCHEME
http://www.cs.cmu.edu/afs/cs/user/jcr/ftp/gedanken.pdf
http://archive.computerhistory.org/resources/text/algol/algol_bulletin/A33/P33.HTM
>>
>>55428570
No
>>
>>55428088
this tbqh senpai
>>
>>55428658
Consider informing the committee please, they tend to do bullshit nowadays.
>>
>>55428571
Pure bullshit, full of outdated memes.
>>
>>55428658
>reddit.jpg
why?
>>
File: 1450081174833.png (48 KB, 372x343) Image search: [Google]
1450081174833.png
48 KB, 372x343
>>55428065
>>55428088
>>55428684
>tfw uni focuses heavily on functional programming
Feels great, makes me erect.
>>
>>55428698
Yeah it's an old thing and it shows in places. I don't know of any more up to date version though
>>
>>55428711
With the amount by which things have moved on since then? Nobody can even be a jack of all trades any more, let alone a master.
>>
Pay close attention if you are in the UK.

>Go on eBay or Gumtree.
>Look for any listings for a PCWORLD/CURRYS Gift Card or Voucher.
>Most listings will include pictures
>Scan the barcode
>the last 5 digits on the code is the FUCKING PIN
>I reached out to DIXONS RETAIL to tell them about their shitty security
>They don't care

I was going to go to the news, but this is much more fun.

Check it out if you don't believe me. Should take less than 2mins.

Happy jewing guys. Fuck those cunts.
>>
File: why.png (3 KB, 645x303) Image search: [Google]
why.png
3 KB, 645x303
>>55425257

Why am I getting this output with this program? What did I do wrong?

 #include <stdio.h>

int main()
{
int i, n;
char c, word[50] = {'\0'};

i = 0;
while(c = getchar() != EOF){

word[i] = c;
++i;
}

for(n = 0; n < i; ++n){

printf("%c", word[n]);
}
}
>>
>>55428700
Reddit stole that image from 4chan and people today think it came from them. Kind of like Scheme and closures.
>>
>>55428730
Consider posting it on other boards/threads, /b/ for example.
>>
>>55428771
>c = getchar() != EOF
Look at the precedence of = vs !=
>>
>>55428771
why are you initializing an array with null chars
>>
>>55428776
/sci/ was always reddit
>>
>>55428571
>Can setup a script to build the system and also documentation, installers, generate release notes and tag the code in source control
>Understands and is able to setup automated functional, load/performance and UI tests
>Has his own library to help with defensive coding, writes unit tests that simulate faults
>Codes to detect possible exception before, maintain consistent exception handling strategy in all layers of code, come up with guidelines on exception handling for entire system.
>Author of framework
>Has written tools to enhance or provide information on platform internals. For e.g. disassemblers, decompilers, debuggers etc.

I wish
>>
>>55428468
For the sake of clarity, the same could be done with fopen & fclose:
auto file = std::unique_ptr<std::FILE, decltype(std::fclose)*> 
{
std::fopen("filename.txt", "w"), std::fclose
};


And, I forgot you can further simpify the previous unique_ptr like this:

auto curl = std::unique_ptr<void, decltype(curl_easy_cleanup)*>
{
curl_easy_init(), curl_easy_cleanup
};


Now that's probably as far as you can get with your current program.
>>
>>55428872
The guy basically has no clue.
>>
>>55425324
Hey, Anime indexer anon, where did ya get the release info from?
>>
What Linux audio libraries do you guys recommend?

I want something similar to the way you work with Alsa - to just send raw frames but with Alsa alone I can't figure out how to get sound without stuttering so I think it's time to give up
>>
So I was reading the 4chan api because I'm just looking for stupid things to do in python and this made me curious
>Use If-Modified-Since when doing your requests.
I've read about what it is but how would I do this practically using urllib.request?
>>
>>55428906
>>55428872

I had classmates who could do all that
>>
>>55428771
#include <stdio.h>

int main()
{
int i, n;
char c, word[50] = {'\0'};

i = 0;
while((c = getchar())){

word[i] = c;
++i;

if(c == '0'){
break;
}
}

for(n = 0; n < i - 1; ++n){

printf("%c", word[n]);
}
}
>>
>>55428992
Firstly,

pip3 install requests
>>
>>55429017
I've always tried to stay with standard libraries but if this is the direction I have to take I'll look into it
>>
>>55425257
writing a kernel. fun shit.
>>
>>55428872
does anyone else think writing unit tests is overrated?
It seems like it would only catch the most obvious bugs and just makes you take twice as long to write your code. and anytime you refactor or change anything you have to update your tests. some of your tests will become worthless and you'll have to rewrite them.
Also there are just so many situations where it's difficult to test your cases without a lot of effort.

i mean all that "defensive coding" & testing sounds good in theory but realistically do people actually do that? how do they even ship any working code if they spend all their time doing theoretical shit
>>
>>55429045
requests is more standard than urllib in the python community though
>>
>>55429049
Language? (I'd assume C, but Rust is entirely possible too)
>>
>>55429078
You went to a bad school, kid.
>>
>>55429105
u wot
>>
>>55429078
yes, C

>>55429105
why? you can write an OS in rust (I wouldn't recommend it, and of course you still need some assembler in there.)
>>
>>55429160
Oh cool, how far are you? I got to handling keyboard interrupts, but lost steam.
>>
>>55429206
I'm still trying to make the keyboard work on x86_64

I still double fault after STI, so I'm not sure what I've done wrong with the PIC
>>
>>55429053
Unit tests are not all that useful when you are basically duplicating your work with them... However if written in a way to use the API, and not just make sure 1=1, they can catch some pretty nasty regressions.

I don't really like it though.

TDD however, is fantastic. The trick is to write your tests before you write the features. That way they act as a specification, they act like "kinda documentation", and often force you to design systems better in general since it forces you to think about how you would actually use an API before you build it. It even helps keep complicated features straight in your head.

It is also very easy to hit a button to say "HAAAY! JUNIT! DID I DO GOOD YET?".
>>
>>55425337
What's the first letter of Brandon's last name?
>>
>>55429273
Do you use TDD for all your projects?
>>
>>55428048
Continuations have nothing to do with functions. Schools keep getting dumber and dumber.

I bet companies hire Indians because Indians actually learn more than Americans and British do.
>>
Reminder /g/ that if you don't use vim you'll never be a good programmer.
>>
>>55429273
>>55429348
I'm pretty sure TDD is dead by now?
>>
>>55429273
but the problem with that is designs are always evolving. unless you're doing a really small project you don't know what the end design is going to be.

also how do you test things like changes to file systems or databases? I don't actually want to modify the DB or file system and I don't have a separate one just lying around.
>>
>>55429348
No. I am too lazy and I often just hack away at something without really thinking about it much.

The ones that do use it are easier to develop and maintain though.
>>
>>55429427
isn't that what everyone says though? It's "best practice" but not good enough for you to use it because it's too much overhead and you'll never get anything done
>>
>>55425257
>startup crashed
>have to look for a new job
>evicted because living in a shit tier country where your job gives a cert that says "this man can rent a place", so no job = no place
>start looking for jobs
>webdev
>webdev
>webdev
>webdev senior
>webdev
>webdev
>webdev
What the fuck
What happened to actual development jobs?
I spent years learning C/C++ and many libraries for database handling and all sorts of other crap only to learn that it's worthless in this market?
Was I memed into disemployment?
>>
>anything else than systems testing
Is this 2010?
>>
>>55429078
Python
>>
>>55429449
Webdev today just means development engineer with a web interface
>>
>>55429449
I feel you man.
Every day I continue working in web development I can feel my soul slowly crushing down and withering away. Yet when I look for jobs it's like 55% front-end webdev, 44% back-end webdev, and the 1% of embedded/systems development want you to have at least 5 years in experience with the stuff.
>>
>>55429493
>development engineer
>>
>>55429512
software development engineer/ programmer/ developer/ whatever
>>
>>55429449
>Failed to adapt
>>
>>55429063
So If I use something like
requests.get("http://a.4cdn.org/g/1.json").headers["Last-modified"]

or
urllib.request.urlopen("http://a.4cdn.org/g/1.json").info()["Last-modified"]

And if the header has changed then from last request then I'll do another full request. Is that how "If-Modified-Since" is done?
>>
>>55427634
Of course, if you actually want to make something useful you should learn C and then learn C++.
>>
>>55429537
>
requests.get

You're supposed to make a HEAD requests not GET i.e.
requests.head()
>>
>>55429420
Nope. Particularly in libraries and frameworks, you'll often see lots of TDD.

TDD is actually being used more and more these days, people even compare the improvements to type wars: https://medium.com/javascript-scene/the-shocking-secret-about-static-types-514d39bf30a3 (Ignore the Buzzfeedish title)

>>55429423
Aye. Though well-designed APIs make refactoring not too big of a deal with tests. And actually, if you want to refactor something huge, it actually gives you a measurable "Yep!" if you didn't break anything.

If you change your APIs however, you will need to delete some tests. But since good tests are isolated, that's as far as the problems actually go in practice.

>>55429445
This isn't entirely true, since it actually saves a lot more time in the long run than it takes up, but it's kinda boring writing tests first, so I don't really want to spend my free time doing that.
>>
>>55425257
I'm using the vimtutor and wondering why the movement keys couldn't have been jkl;
>>
Thoughts?

https://github.com/eriksvedang/Carp
>>
>>55429605
Probably cause keyboards back when Vi was a thing didn't have ; there
>>
>>55429531
That's a pretty poor justification. It's like going from neuroscience to dentistry because there was no market on your preferred field.
This kinda justifies the libarts students but it's stupid to think that you should do something you loathe just to stay on the field.
Is actual development dead?
>>
>>55429693
No, it evolved. Stay dated
>>
>>55429449
>>evicted because living in a shit tier country where your job gives a cert that says "this man can rent a place", so no job = no place

What the fuck?
>>
Is anybody here good with WPF?
Any good, comprehensive tutorials?
All the ones I come across are either scatterbrained as fuck or conveniently leave out huge chunks of the program that they made no mention of that are required by what they're doing.
>>
I was sent a programming challenge by a company I applied to through e-mail

I sent them the solution, but not before admitting I already knew the "trick" to the problem from solving challenges as a hobby

Did I do well? Or was that retarded and I should have kept my mouth shut
>>
>>55429761

Probably fine.
>>
>>55429761
You were honest so you did the right thing

The company might consider your honesty a +
>>
>>55429761
As someone who hires people, I like knowing programmers enjoy solving problems as a hobby since they are usually better developers overall and they like the job more.
>>
how should i go for documenting an undocumented API? it's a web service. i never documented before and this is challenging to format it properly
>>
>>55429702
You heard it.
After your first year working in a company you get to apply for a warranty (that's the cert), and the gubmint studies your expenses and validates whether or not you can rent a place.
Basically they determine whether or not you're homeless (or living in a dorm, don't know which one is worse).
Bonus points if you guess the country.
>>
>>55429449
It's dead because it's easier to make a single product that runs in a web browser than it is to make standalone applications.

Also most frameworks will literally write all the hard bits for you, and magically take care of the rest (See: Rails, Django, Node.js)
>>
How do people do integration/system testing in Python?
>>
>>55429583
Thank you, I'm reading more about http head requests now
>>
>>55429831
Bulgaria
>>
>>55429865
>Testing
>Python
If you're writing anything large enough to warrant integration and blackbox testing, you should not be writing it in python.
>>
>>55429804
auto generate it from code
>>
>>55429799
Well I hope that doesn't make them think I'm any good at doing puzzles with a short time limit under pressure
>>
What is good music to listen to while programming?
>>
>>55428836
>>55429013

Got it thanks.

>>55428839

I was searching solutions on the internet and came to some post where some people initialized their arrays to null chars for some reason.

I have no idea why.
>>
File: tumblr_nyt5immDdT1qze3hdo1_500.gif (405 KB, 500x288) Image search: [Google]
tumblr_nyt5immDdT1qze3hdo1_500.gif
405 KB, 500x288
>work unbearable this week (business analyst in meme startup)
>schizo founder fucking up all our processes because muh change and innovation, shouting at me regularly for trying to put some order on it
>need to get out ASAP
>caught because my python is okay but not good enough for Data Analysis or Django dev yet, and don't have a CS degree to back it up

Help me /g/, how do I improve so I get gtfo of here, get a decent job using python, and earn some proper money instead of meme startup wages?
>>
>>55429831

I honestly haven't got a clue.
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.