[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: 40
File: dpt.png (717 KB, 1000x793) Image search: [Google]
dpt.png
717 KB, 1000x793
Last: >>53633479

What are you working on /g/?
>>
File: haskelel.jpg (99 KB, 529x598) Image search: [Google]
haskelel.jpg
99 KB, 529x598
>>
how should I name my structs/unions/enums in C?
CamelCase?
>>
File: 1449338205020.jpg (3 KB, 126x125) Image search: [Google]
1449338205020.jpg
3 KB, 126x125
>>53642857
>i can't read it so it's shit

>>53643060
Underscore_Title_Case
or if you wanna be a REAL hardcore Cfaggot, Shrtnme
>>
File: snake_case.gif (443 KB, 400x480) Image search: [Google]
snake_case.gif
443 KB, 400x480
>>53643060
>>
>>53643078
Bugs Bunny is great. I miss old cartoons.
>>
naming variables is the hardest part about programming
>>
File: 1455297682398.gif (4 MB, 444x250) Image search: [Google]
1455297682398.gif
4 MB, 444x250
>>53643180
The hardest part about programming for me is being sober. That's why I program at work, but even then it's hit and miss.
>>
File: Cd1xTGCWIAAo0wK.jpg large.jpg (105 KB, 864x629) Image search: [Google]
Cd1xTGCWIAAo0wK.jpg large.jpg
105 KB, 864x629
>>
>>53643180
g_rglpszStrings
>>
Post more programming maymays.
>>
File: doglang.jpg (410 KB, 876x2350) Image search: [Google]
doglang.jpg
410 KB, 876x2350
>>53643301
>>
Is there a portable command line program that scans C Sharp source files for comments and generates pretty HTML documentation pages? All the programs I found either require configuration files, are visual, run on Perl (what the fuck) or cost money.
>>
>>53643354
Just use Doxygen.
>>
>>53643354
Couldn't you just use something like doxygen
>>
>>53643354
Try Doxygen, anon!
>>
>>53643377
>>53643382
>>53643398
FUCK OFF I'M MAKING MY OWN IN ANSI C
>>
What do you guys think of doing ProjectEuler/HackerRank etc... In respect with the goal being to be able to put this on your resume. I know the answers are hovering around all over the place but I'm sure it still carries weight if you did 50-100 of them.
>>
>>53643377
>>53643382
>>53643398
>require configuration files
>>
If I'm a fucking faggot and i just want to learn programming languages for the sake of having them on my resume and hoping some HR fuck sees it or some fucking shit, are there any I should look into aside from HTML, CSS, JavaScript and SQL?
>>
>>53643484
Eh.
Maybe if you have them all in your github or something.
>>
>>53643484
it wouldn't carry as much weight as an impressive project
>>
>>53643516
java
python (it's SHIT but it's the hottest meme for HR fucks)
>>
I know python, javascript, powershell. And C#, all for work. Should I learn C or Haskell next as a hobby language?
>>
>>53643570
C.
Haskell a shit.
>>
File: 1458750610808.jpg (4 MB, 1494x2656) Image search: [Google]
1458750610808.jpg
4 MB, 1494x2656
Putting EmulationStation on my new Raspberry Pi 3 Model B to play some old Playstation and NES games. Not really programming, but I program as a job.
>>
>>53643570
C or C++
fuck haskell
>>
Covariant return types
>>
>>53643593
Not sure what's the thing you're building but since it seems to be C++ is there any reason why they (you?) are using pthread as opposed to std::thread?
>>
File: Capture.png (31 KB, 215x788) Image search: [Google]
Capture.png
31 KB, 215x788
>>53643517
I am not deleting them so I could do that.

>>53643527

My problem with this approach is I don't think I know enough and I don't know what the minimum is to begin approaching a project in the first place, nor do I know of any projects worth doing.

In green is what I would say I know the basics of as to not be afraid to expand upon.
>>
>>53642250
Go is actually one of the few languages that has been promoting dependency hygiene.
>>
File: prog.png (4 KB, 378x102) Image search: [Google]
prog.png
4 KB, 378x102
Get ready to get rekt, the truth is in pic related, if you have weak heart then don't open it or you will get heart attack and depression! See ya!
>>
>>53643996
Sweet opinion you got there.
>>
>>53642808
I want to learn java what software (needs to be lightweight) do I use on arch linux?
>>
>>53644055
you use Intellij IDEA
>>
>>53644055
Why java? If that's your first language, learn something hackable.
>>
>>53644118
too cpu intensive
>>53644152
I want something that runs on linux mac and windows IIRC java outputs a .jar
>>
>>53644180
>too cpu intensive
I have pentium 4 and runs smooth as fuck, the fuck you have? an IBM with floppy discs station? gtfo
>>
>>53644180
>Java
>IDE
>Lightweight

Barking up the wrong tree, mate.
>>
>>53644191
x220
>>
>>53644196
Nigger, that has an i5 in it.
>>
>>53644055
vim
javac
>>
>>53644180
>I want something that runs on linux mac and windows IIRC java outputs a .jar
That has nothing to do with being hackable.
>>
>>53644196
>>53644191
How about a piece of paper with pencil? This will be 0% cpu intense
>>
I would appreciate some help /g/. I cannot for the life of me get the number from an imported text file to actually become a usable variable throughout my code.

the .txt file
Doe, John K.
93.2
Andrews, Susan S.
84.7
Monroe, Marylin
75.1
Gaston, Arthur C.
62.8


It needs to print out like
Doe, John K. 93.2 A
Andrews, Susan S. 84.7 B
Monroe, Marylin 75.1 C
Gaston, Arthur C. 62.8 D


Here is the code I have currently


#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

using namespace std;

enum letter_grade { A, B, C, D, F };

int main()
{
string lastName, firstName, middleName, fullName, line;
int average, i = 0, line_number = 0;
string total;
int dicks = 0;

ifstream transferSchoolFile;
transferSchoolFile.open("student_status.txt");

std::ifstream input("student_status.txt");

while (input && std::getline(input, line))
{
if (dicks > 0)
{
total.append(" ");
}

total.append(line);

if (dicks > 0)
{
total.append(" ");
total.append("RELATE SIZE OF GRADE HERE");
total.append(" ");
total.append("\n");
dicks = 0;
}
else
{
dicks++;
}

}

cout << total;

transferSchoolFile.close();
return 0;
}
>>
File: heart-attack.jpg (23 KB, 600x478) Image search: [Google]
heart-attack.jpg
23 KB, 600x478
>>53643996
>>
>>53642808
What do you think of Cello to teach programming basics?

https://www.youtube.com/watch?v=bVxfwsgO00o

>inb4 teach original C
>>
>>53644248
Still? Jesus dude. Didn't you post this about a week ago?
>>
Please do not use an anime image next time. Thanks.
>>
File: itaots alternative album cover.png (317 KB, 618x622) Image search: [Google]
itaots alternative album cover.png
317 KB, 618x622
>>53644297
>FUCK THE POLICE
>>
>>53644248
I have no idea why you have and input and an open. Just use
ifstream input("student_status.txt");
while (getline(input, line) { /* ... */}


You may want to keep track of the line number and check if it's odd or even. If it's even, then you have a grade and you can do something like
double average;
average << atoi(line.c_str());
>>
>>53644245
he's saying he doesn't care about hackability. he is rejecting your statement that he should be using something hackable, because he instead values something that runs of linux mac and windows
>>
File: 1448783347938.gif (2 MB, 320x240) Image search: [Google]
1448783347938.gif
2 MB, 320x240
>>53644277
I also plan using this since seems pretty straight forward to me

http://c.learncodethehardway.org/book/
>>
File: thinkdifferent.png (422 KB, 632x720) Image search: [Google]
thinkdifferent.png
422 KB, 632x720
>input
>>53644055
>>53644180
>>53644196
>key words: cpu, poorfag, linux, neckbeard, poor, x220
>output
I recommend Javascript
>>
Any interesting interview-esque programming questions/prompts?
>>
>>53644731
Average two fizzbuzzes in C
>>
Do live usb's use virtualization ?
>>
File: 1458702711671.jpg (93 KB, 600x850) Image search: [Google]
1458702711671.jpg
93 KB, 600x850
Working on my file server with torrent support. Got a file system monitor running which keeps the database in sync with the stored files. Too bad the lazy niggers haven't implemented recursive monitoring yet. Next up is to create a simple web front end that displays all files. Than I'll tag the code as version 0.1.
I didn't know SQLite was that much slower than PostgreSQL. Inserts are 30x as slow, but SQLite is comfy as fuck and requires no setup so I'll use that for now.
>>
>>53644412
>Learn C the hard way
No, just no
>>
>>53644802
Nice blog
>>
>>53644731
I got asked to reverse a string using pseudocode

I can't imagine how bad the average applicant must be for those questions to be necessary.
>>
File: fgsfd.jpg (32 KB, 335x352) Image search: [Google]
fgsfd.jpg
32 KB, 335x352
>>53644731
Fizzbuzz part 2:
From 1 to 100:
If a number is evenly divisible by 3, print Fizz.
If a number is evenly divisible by 5, print Buzz.
If a number is evenly divisible by 7, print Baz.
If a number is evenly divisible by 8, print Norf.
If a number satisfies more than 1 of these rules, concatenate them
i.e. 15 says FizzBuzz, 24 says FizzNorf
>>
>>53644489
>JavaScript
Unironically a better language than Java
>>
>>53644843
s[::-1]

Checkmate, atheists.
>>
>>53644802
>I didn't know SQLite was that much slower than PostgreSQL.
SQLite isn't really meant for high I/O on a server.

How does PostgreSQL compare to MySQL?
>>
>>53644846
That seems too easy to be asked on an interview, right?
>>
>>53644906
If it's so easy then do it. Think of it as practice for your interview
If you do a long if-elseif chain I'm throwing your resume in the garbage.
>>


#!/usr/bin/python

#!/usr/bin/env python

#!$(which env) python



which one
>>
>>53644916
I'm not even that guy, I was just wondering
>>
>>53644894
I understand SQLite being slow, but I didn't think it would be that slow. Apparently there are some tricks to really speed that shit up: http://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite. I'll look into that when all the must haves have been implemented.
I'm not really into databases, but AFAIK PostgreSQL performs better than MariaDB/MySQL. The only reason MySQL is so popular, is because of muh LAMP stack.
>>
>>53644966
Interviewers always start off with easy questions to make sure you aren't a helplessly-bad tier programmer.
If you get past those without trouble ,then they bring out the big guns.
>>
File: db_file_img_4587_autoxauto.jpg (58 KB, 1140x1092) Image search: [Google]
db_file_img_4587_autoxauto.jpg
58 KB, 1140x1092
>>53644961
>>
>ctrl+f: algorithm
>0 results
code monkeys pls go code an indian version of 4chan
>>
>>53644879
>>53644843
print reverse(s);
>>
>>53644916
>if-elseif chain
No Anon, just an if chain.
>>
>>53644984
alright, nice
>>
>>53645043
That's bad too.
>>
>>53644916
>>53645059
What about a case/switch?
>>
>>53645059
Why is it bad? It's easy to understand.
If you respond with "it takes longer to compute" I will destroy you.
>>
>>53645078
It doesn't satisfy his autism.
>>
>>53645078
Don't be simple, anon.
>>
>>53645105
No interviewer would say that.
In fact, it's great if you can solve things in a simple but still efficient way. It makes your code easier to understand for your co-workers.
>>
So, if I download c++ and start typing a bunch of random shit, I will create a video game?
>>
>>53645117
It means you aren't special. Pajeet lives behind the McDonalds a couple blocks away and he can chain if statements, too. Why should we hire you instead of him?
>>
>>53645136
Given an infinite amount of time, yes
>>
>>53644916
String fizz;

for (int i = 1; i <= 100; i++) {
fizz = "";
if (i % 3 == 0) {
fizz += "Fizz";
}
if (i % 5 == 0) {
fizz += "Buzz";
}
if (i % 7 == 0) {
fizz += "Baz";
}
if (i % 8 == 0) {
fizz += "Norf";
}
if (fizz != "") {
System.out.println(fizz);
} else {
System.out.println(i);
}
}

;^D
>>
>>53645136
Download Unity and start clicking random shit.
>>
File: 1439880804657.png (285 KB, 1263x2526) Image search: [Google]
1439880804657.png
285 KB, 1263x2526
Why aren't you in on four dimensional programming?
>>
>>53645137
"I have a folder of cute anime girls I'll happily share with you"
>>
>>53645137
You shouldn't because I wouldn't apply for a shitty coding job anyway. You're implying they look for special people, but they don't.
>>
>>53645144
this still uses a 5th comparison, any way to do this with only 4 comparisons AND string concatenation ?
>>
>>53644846
Took me a second to work out what the fuck you meant by evenly divisible (could have meant is the result of division even).

>>53645070
The only advantage to using a switch is if you want to drop down into other cases without breaking, but there's no point because you'd need to check conditions again anyway.
Given the number of permutations, it's most efficient to just check each of the 4 modulo results.
>>
What are the benefits of functional programming?
Actually benefits. No academic reasoning. Immutability implies a need for more memory, and "easier to reason about" still means absolutely fuck all, when you're trying to find an argument error in a 8+ function callstack.
>>
>>53645157
>Many times I have thought that to myself that computers would work better if you could just "add a two" in binary code
#relatable
>>
>>53645194
Some code looks cleaner when written functionally.
>>
>>53645183
How are you confused by 'evenly divisible' anon? This is elementary tier math. I thought programmers nowadays had to know at least calculus?
Let me put your resume in a special folder I like to call 'the trash can.'
>>
>>53644846
def fizz():
divDict = {3: 'Fizz', 5: 'Buzz', 7: 'Baz', 8: 'Norf'}
for i in range(1, 101):
s = ""
for key in divDict:
if i % key == 0:
s += divDict[key]
print s
>>
>>53645180
None that I can think off
>>
>>53645277
It's more compact, but is it really more efficient than something as simple as >>53645144?
>>
>>53645297
>but is it really more efficient than something as simple as >>53645144
no
>>
>>53645194
Absolutely none. Mainstream functional languages (like Haskell) tend to use less code for certain tasks than mainstream OOP languages (like Java). That's about it.

They're not comparing the functional paradigm, just the implementations of certain languages.

The way people talked about OOP in the early 90s, functional programming was an outdated and failed meme. OOP subsumed functional programming: pure functions are just one kind of object. Then Java came along and the functional programming community pretended it's the epitome of OOP. Java explicitly avoided things like multiple inheritance. How can it be the epitome of OOP if some things aren't even objects?

In the past, they would compare their language to C. Not even C++ or Ada, plain C (before C89, too). Some parts of their language are worse than a language that was called "portable assembly" since the 70s. What an accomplishment!
>>
>>53645160
"I'm sorry, hiring you would be against labor laws, as we are not allowed to hire children under the age of 16"
>>
NPM EXPOSED AS INHERENTLY INSECURE

https://medium.com/@azerbike/i-ve-just-liberated-my-modules-9045c06be67c

If you use NPM to manage your Node packages, stop building NOW. Massive security exploits are possible with namespace attacks.

nodefags BTFO
>>
people fucking suck at agar.io

fucking minecraft-playing shitkids
>>
File: dance.gif (531 KB, 176x275) Image search: [Google]
dance.gif
531 KB, 176x275
>>53645355
are there children above the age of 16 then? :3
>>
>>53645363
>node
kindly fuck off to >>>/g/wdg
>>
>>53645194
it's just fun
the code won't be magically cleaner and it definitely won't run faster
try it, maybe you'll like it
>>
>>53645382
Until you're 18 you're still a child.
>>
>>53645194
none, really. of course you can have "pure" functions and immutable variables, but basing the entirety of your program around it is fucking retarded
>>
>>53645256
"Evenly divisible" is meaningless without context.
If you mean "divides to an integer with no remainder", then why don't you say what you mean?

Yes, it's elementary tier, so is explaining yourself without being ambiguous.
>>
>>53645471
Child generally means pre-pubescent, not below 18.
>>
>>53645611
Until you're able to be independent, you're a child.
"Dependent Adult" is still a child in my books.
>>
>>53642808
this thread is being monitored! TAKE CARE!
>>
>>53645626
But that's more of an expletive using the word child, rather than using the word child in its commonly understood meaning.

Nerd.
>>
>>53645611
you're still a minor until the age of majority, which is 18 basically everywhere
>>
>>53645638
Bitch, you're not getting the job.
I SAID GOOD DAY, CHILD.
>>
>>53645626
>tfw you can't afford to become an adult
life is suffering
>>
>>53645611
ok kid
>>
>>53645656
What job? I just walked in here and people are yelling dumb things.

Why is there 17 forms of FizzBuzz on that whiteboard?

Is that...Brainfuck?
>>
>>53645676
You're in the wrong place. This is the general where everyone is still waiting for their medication but the handlers abandoned a LONG time ago.
>>
>le pure FP means everything has to be immutable meme
No SIDE effects. Effects are fine.
>>
>>53643060
No, camelCase.
>>
>spergs arguing the meaning of the word 'child' as if there is one true definition that applies in all contexts and as if it even matters in the first place
niggas pls
>>
>>53645626
>>53645643
>I'll use my own shitty definitions instead of the actual definitions!
Why though
>>53645669
>Implying I'm not a balding 23 year old
life is suffering
>>
>>53645194
Concurrency, shorter code and lazy evaluation
>>
>>53645705
A side effect is any effect that isn't the result of a function.
>>
>>53645735
My definition is the only one which matters.
Also, 26, dog bites kinda, been greying since i was 19. the goatee part of my beard is all grey. thinking of dyeing it.
>>
>>53645747
I love FP but in all practicality lazy evaluation is rarely a benefit.

>>53645755
Exactly. FP models effects as results of functions.
>>
>>53643272
girls like dolls though
>>
>>53645194
Immutability also means that programs can be better tested because variables can't be changed by other parts of the program
>>
I have a C++ related question:

I have a character array with the value of nullptr that needs to be printed to the console. How can I make this happen, if at all possible?
>>
>>53645832
That has nothing to do with functional programming though.
>>
>>53645815
B-Boys do too ;_;
>>
>>53645194
>"easier to reason about" still means absolutely fuck all, when you're trying to find an argument error in a 8+ function callstack
Can you expand on this because "argument error" is a pretty vague expression.
>>
>Tfw you all suck at programming and none of you have ever made an application that makes money
>>
>>53645194
>Immutability implies a need for more memory
No, it does not.
>>
>>53645889
>projecting hard
i'm good af, haven't released my game yet but i'm gonna, and i'm gonna make good af games
>>
>>53645921
Until you make money from it you are a noprogrammer all no programmers need to leave
>>
>>53645889
Wow Anon, your projection level is off the charts. Did you just get your first $.69 paycheck from Google Play Store?
>>
>>53645858
you're not a boy anymore anon
>>
Functional programming is pretty shit for systems programming (where verification is actually really useful) without linear types, I'll concede that much. And given that there's only a few properly linearly-typed languages out there, and they're all academic wankery, it probably looks pretty bad to anyone who isn't more interested in the development of languages rather than the usage of languages.
>>
>>53645973
I am, I try to be!
>>
>>53645986
Systems programming is all about access to particular memory addresses for memory management and hardware devices. The important part is the specific addresses, not the fact that they are accessed once (presumably to remove the need for GC). There's no reason why an operating system can't have a GC once the memory management parts are implemented. There were OSes with GC in the 70s and some OSes like Singularity depend on GC for all programs as part of the security model.
>>
>>53645986
>linearly-typed languages
What's that?
>>
File: 03-23-21-28-47.png (18 KB, 782x203) Image search: [Google]
03-23-21-28-47.png
18 KB, 782x203
>>53644846
I know, I've "optimized" the string concatenation but not the amount of checks, it's very clean like this though.
>>
File: h8rsgotoh8.webm (674 KB, 628x426) Image search: [Google]
h8rsgotoh8.webm
674 KB, 628x426
I've been posting my progress on a spacey crafting game. I'm using webgl which g seems to have a bit of apprehension for. Anyway, I'm working on some positional lighting code which I don't understand very well, so I'm creating some tools to help me debug the situation. I've made the classic mistake of copy and pasting code but not actually making sure I completely understand it, so I'm going through it all line by line to learn exactly what everything is for. The attached video is a basic cube with axis placeholders so I can still see my objects positions if my lighting code blows prick. This is just test code, so now I have to go back into my engine and create a shader manager so I can switch shaders from the ones that draw those simple lines to the dysfunctional lighting shader.

If you think you can't do much with webgl check out this site:

http://goocreate.com/gallery

That site has a lot of interesting programs people have made from the goo webgl engine. My guess is a lot of you haven't looked at webgl since the early days and imHo you should take another look at it. If you have the time, sign up and create a new project out of the spaceship demo.

To be honest, whether the opengl "window" is attached to your browser or a gui window shouldn't really matter, and I know the real issue is that the code is running in the browser which is going to be much slower than native code, but I still think it's neat.

If you guys want me to post my code somewhere let me know. Does github offer free public repos?
>>
>>53646150
Linearity with regard to memory management doesn't mean you only get to access memory once and then it's thrown away (although that could be the semantics if you really wanted...), it's that you can make types that ensure that there's exactly one point at any given time where a piece of memory can be mutated OR many points where it can only be read.

And I understand that certain forms of garbage collection like regions can be faster than allocating and freeing everything individually, but they're not suitable for all use cases. And even if an OS has a GC available for software to use, it's not part of the language used to write it. To write an OS you need something with little to no runtime - something with a good GC built in won't fit the bill. And of course for real-time software you don't want a built in GC either.

>>53646215
If a variable has a linear type, it must be used exactly once. Kind of like noncopyable objects in C++ or Rust, but those are uniqueness (affine) types which means that they can be used 0 or 1 times. Linearity is good for modeling effects and especially for memory management, like monads, but it's more primitive and generally more flexible.

This is a good paper on the subject:
http://homepages.inf.ed.ac.uk/wadler/papers/linear/linear.ps.gz
>>
>>53646249
JS sucks. Running GL applications in the browser is stupid and slow.

Use a decent language and regular OpenGL.

Yes, github has free repos. So does bitbucket
>>
>>53646249
lighting isn't too hard, i mean if you're bad at math you're going to struggle with the more advanced lighting models, but you had lambert diffuse shading working the last time you posted, right?
>>
>>53646281
>it must be used exactly once
Isn't this like https://en.wikipedia.org/wiki/Uniqueness_type?
>>
>>53646281
>it's that you can make types that ensure that there's exactly one point at any given time where a piece of memory can be mutated OR many points where it can only be read
Those are useless when writing an OS.
>>
>>53646307
Yes, I did, but I didn't really understand it, I had just copied the code.
>>
>>53646336
Yeah, uniqueness types are a bit weaker though because you can implicitly "drop" a unique variable.

>>53646337
I don't know about that.
>>
>>53646367
What do you mean by drop? Just stop using it?
>>
>>53646356
these might help

https://www.youtube.com/watch?v=IyUgHPs86XM
simonstechblog.blogspot.com/2011/12/microfacet-brdf.html
>>
>>53646384
You don't use it and it's destructed. Fine in most cases for issues of memory management and ownership, but certainly not for modeling effects (you don't want to drop the world!) or what are called "borrowed references" in Rust (they're truly linear while objects are only affine).
>>
>>53646367
>I don't know about that.
>In the linear system, each operation that introduces (and allocates) a value is paired with exactly one operation that eliminates (and deallocates) that value.
>Hence, after an application the storage occupied by the function may be reclaimed, and after a case analysis the storage occupied by the node analysed may be reclaimed. No reference counting or garbage collection is required.
There is no storage to be "reclaimed" in an OS. There are just addresses in a finite state machine. All of the storage already exists.
>>
File: 1457556235385.jpg (121 KB, 337x450) Image search: [Google]
1457556235385.jpg
121 KB, 337x450
I spent two days getting reddit set up on a server (it would've been way easier if I wasn't such a retard), thinking I could jump into the source code, make a bunch of contributions and become a super programmer, but now that I have it working, I'm stuck. My laziness is kicking in again, and I'm not quite sure what the fuck to do.

I want to be able to get a programming job by the middle of the year, but I'm stuck in this mediocre gross NEET purgatory. I'm also trying to work on a command line email client, but that's not going very well either. I'm having a hard time getting into the GMail API (I need to figure out how to "agnostically" access it, like with just OAuth and the standard Python imap/smtp libraries).

My life is hell.
>>
>>53646430
Yes, but you need some way to know that the storage is safe to reclaim in the first place. God forbid you suggest using a garbage collector for that.
>>
>>53646440
>I spent two days getting reddit set up on a server

That's definitely a bad sign. It should take an hour tops. (unless it has changed dramatically since the last time I contributed.)

> I'm also trying to work on a command line email client, but that's not going very well either. I'm having a hard time getting into the GMail API

You're a lost cause as far as getting a job this summer.

>My life is hell.

Try working 8 hours a day
>>
public class Base64 {
private final String[] CHARS = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"};
private String plaintext;


public Base64(String p) {
plaintext = p;
}

public void pad() {
while (plaintext.length() % 3 != 0)
plaintext += 0;
}

public String encrypt() {
String output = "";

for (int i = 0; i < plaintext.length(); i += 3) {
output += CHARS[plaintext.charAt(i) >> 2];
output += CHARS[((plaintext.charAt(i + 1) & 0x00F0) >> 4) | ((plaintext.charAt(i) & 0x0003) << 4)];
output += CHARS[((plaintext.charAt(i + 1) & 0x000F) << 2) | ((plaintext.charAt(i) & 0x00C0) >> 6)];
output += CHARS[plaintext.charAt(i + 2) & 0x003F];
}
return output;
}
}


how likely am I getting hired?
>>
Do any of you guys code for a living without a degree? Just wondering if it's possible. I don't care if I won't get paid much--I just want to get a foot in the door and earn a livable wage and go to school later on.
>>
>>53646529
>base64
>encrypt()
>>
>>53646531
No, but I had an internship at a coding company a while ago and I can confirm that you don't necessarily need a degree if you're good. Met quite a few people who didn't have one.
>>
greetings senpaitachi, I was logged into the ol' 4chan yesterday and I posted some code and asked for a critique and some nice anon posted his superior implementation.

Prompt:
    You are given a string s composed of letters and numbers, which was compressed with some algorithm. Every letter in s is followed by a number (possibly with leading zeros), which represents the number of times this letter occurs consecutively. For example, "aaaaaaaabbbbbbcc" would be given as "a8b6c2".

Decompress s, sort its letters and return the kth (1-based) letter of the obtained string.


Here's my code:

def Expand_It(s, k):
import re
length = 0
count = 0

s = filter(None, (re.split('(\d+)', s))) # parse s, store as list, remove empty strings with filter
t = {}
for i in range(0, len(s), 2): # consolidate s into dict, {letter:count}
if s[i] not in t:
t[s[i]] = int(s[i+1])
else:
t[s[i]] += int(s[i+1])
for key in sorted(t):
length += t[key] # calculate total decompressed length
if count < k:
count += int(t[key])
letter = key # keep track of letter at position 'k'
else:
break
if k > length:
return -1
else:
return letter


Here's his implementation:
import re
from collections import defaultdict
def decompress(s, k):
partsList = re.split('(\d+)', s)
#print partsList
letters = defaultdict(int)
for letter, number in zip(partsList[::2], partsList[1::2]):
letters[letter] += int(number)
result = ''
for letter in sorted(letters.keys()):
result += letter * letters[letter]
#print result
return result[k-1]


basically, I wrote my implementation the way that I did because that is the limit of my knowledge right now. Can anyone explain what's going on in anon's implementation for me, tell me what I should look up/learn, etc.? I'd appreciate it
>>
>>53643662
What course is this in the screencap?
>>
>>53646695
Looks like an intro to programming in Java course. Recursion and Data Structures are usually covered in a A&DS class.
>>
Java and C# and dynamically typed languages should be illegal
>>
>>53646910
>muh algorithms
>muh data structures

>>53646926
No one gives a fuck about your opinions.
>>
Any data scientists here?
>>
>>53646984
Data scientist is code for excel monkey
>>
>>53646932
Learn to only post when your post isn't shit.
>>
Other day I was trying to finding a software for joining images so I could post a series of screenshots as only one image, but I couldn't find any. Then, I making my own. Is there demand for that or it's something seldom people use? If there is, I could post it on the store.
>>
>>53647086
i'm pretty sure you can do that in one imagemagick command
>>
>>53647007
Because spouting your retarded subjective opinions is such a contributing post. Fuck off back to your anime where you belong.
>>
Working on a meme form. Basically a Windows form application written in C# full of the edgiest things.

I'm bored as fuck. Kill me.
>>
If I know opengl v3+, can I write webgl, or is it just a pile of shit?
>>
>>53646993
Who would do this shit in excel?
>>
>>53647160
Yes>>53647162
>>
>With 4 moves per stone, the branching factor could be well over 100!
What did he mean by this?
Did he mean the factorial or was he getting excited because 100 is a large number?
WHICH IS IT?
Fuck that notation
>>
>writing documentation
fuck everything
>>
>>53647258
For what?
>>
>>53647102
Windows Phone user. Only things I found are for making collages and other limiting stuff with weird borders and no control.
>>
>>53647274
write an app that uses imagemagick

just realize that literally nobody but you will install your app
>>
>>53647263
classified atm
>>
>>53647288
Come on, Anon. I can keep a secret. You don't need to go into detail.
>>
>>53646660
import re                            #import regex
s = "a2b3c2a1" #here be a string
r = "" #holder thing
i = 6 #Target index
l = re.split('(\d+)', s) #split string into list
l.pop() #there'll be a blank at the end, remove that
for i in range(0, len(l), 2): #increment by 2
for j in range(0, int(l[i+1])): #Repeat operation by number of times specified in string
r += l[i] #add letters to result
r = ''.join(sorted(r)) #Sort that shit and smash it all together
print(r[i-1]) #print result

This is a similar version with comments. In his version anon is basically using a dict instead of sorting.
>>
>>53646453
I think garbage collection in OSes is the future. Desktop OSes already have enough things that aren't real-time that they might as well have GC.

Intel, Xerox, Symbolics, Bell Labs, and Microsoft (still experimental) have all built computers or OSes that use a GC, and garbage collected languages like Smalltalk, Java, Haskell, Oberon, Cedar, Algol 68, and Lisp each had at least a couple OSes.
>>
>>53643078
>Shrtnme
That's not how us C faggots name things fucktard.
We name them like_this
>>
File: autism.gif (2 MB, 400x286) Image search: [Google]
autism.gif
2 MB, 400x286
>>53647116
Nice temper tantrum, kid
>>
>>53647470
>strcat
>atoi
>malloc

if your function name is longer than 6 characters that's bloat
>>
>>53647488
Says the kid who needs to have his opinions heard from afar.
>>
>>53647422
>using the variable name "i" twice with overlapping scope
>>
>>53647434
>I think garbage collection in OSes is the future.
Linear types enable the guarantees of GC without the overhead.

The core problem is: how do we prevent unreachable leaked memory, and how do we prevent dangling pointers from being used?
A GC modifies the run time semantics to make the concept of a dangling pointer or truly unreachable (from the GC's perspective) memory absurdity.
Linear types modify the type checker to make the program not compile if it's not provably respecting these laws.

I don't know about you, but I'd rather my OS doesn't fritter away all of my hardware resources.
>>
File: 1339826969858.jpg (44 KB, 500x334) Image search: [Google]
1339826969858.jpg
44 KB, 500x334
>>53647525
Yes. Now please, keep on crying.
>>
>>53643652

std::thread is typically using pthreads under the hood. Even on Windows with MinGW-w64, winpthreads is used.
>>
In python 3 how do I check for duplicates?
>>
>>53647675
duplicates.check()
>>
>>53647675
import duplicates
>>
>>53647814
>>53647783
it says there's no module called duplicates
>>
Just met N.J Sloane. Talked about an integer sequence I was studying (he didn't seem too interested) and working with Aho. unfortunately I missed the lecture, I'm not CS and wasn't informed.
>>
>>53647876
import module.
>>
>>53647876
>joke


>your head
>>
>>53647900
>joke


>your head


>me & ur mum
>>
>>53647917
>joke


>your head


>me & ur mum


>python
>>
Ask your favorite programming literate anything (IAMA).

>>53642808
>What are you working on /g/?
r/dailyprogrammer #237 [Intermediate].
made an one pass, streamable, solution.

>>53647604
>Even on Windows with MinGW-w64, winpthreads is used.
there are two distributions of MinGW-w64, one that uses pthread and one that uses winapi.

>>53647675
you could automatically avoid duplicates by using a set object

In [1]: set([1, 1, 2, 1, 3, 2, 3, 4, 4])
Out[1]: {1, 2, 3, 4}
>>
>>53647936
I'm seriously depressed every single time I see you post because I realize you still haven't offed yourself. My birthday is coming up in August, do me this solid.
>>
>>53647936

And I'm pretty sure winpthreads is using the WinAPI behind the scenes.
>>
>>53647936
For my program I need to have the user enter a list, then the program has to spit back the list with all the duplicates removed. When I use set it gives everything in a jumbled order
>>
>>53647884
Turns out the sequence I was studying he had already characterized.

>>53647936
>you could automatically avoid duplicates by using a set object
>>53647675
Alternatively, if you simply want to detect them:
all(map(lambda x: x > 1, collections.Counter(seq).values()))
>>
>>53647983
set(list).sort()
>>
>>53647986
hurrrrr, I'm dumb
max(Counter(seq).values()) > 1
>>
>>53648002
He probably means he wants to remove duplicates, and preserve order. Probably remove all but the first occurence.
>>
>>53648044
yeah that's what I mean
>>
>>53648044
>>53648055
sorry bud, using prefab libraries and built in meme functions is all python ""should"" be used for
>>
>>53647675
import doyourownhomeworkfag
>>
>>53648055
Well think about it. Iterate through the list and if a value has been encountered before, remove it. Or doesn't that make sense?
>>
>>53644961
None. Always use versioned python command, so either python2 or python3. Don't assume that default python implementation on any computer is the same you use.
>>
File: 1429227480929.png (38 KB, 1234x319) Image search: [Google]
1429227480929.png
38 KB, 1234x319
>>53648094
inb4
>>
>>53648125

What did I miss?
>>
>>53648132
>remove vowels from "treehouse"
>trhuse
>>
Whoops, didn't mean to quote. I am ashamed.
>>
File: tumblr_n691fyTO4z1tuv1u6o1_400.jpg (72 KB, 400x336) Image search: [Google]
tumblr_n691fyTO4z1tuv1u6o1_400.jpg
72 KB, 400x336
>>53647952
Please, don't bully.

>>53647978
yes, you can't bypass winapi on windows since microsoft never documented the system calls.

>>53647983
>>53648044
set(list) preserves the order and a set object doesn't have a sorting operation. if you want a sorted set, you must pass a already sorted list.

l.sort() # in place
foo = set(l)
>>
How do I become Payet?
>>
>>53648125
>modifying string as you iterate over it.
Lol?
>>
>>53646984
machine learning and data scientist, wo bist hier.
>>
>>53648177
with a normal for loop it would be fine
>>
>>53648164
https://www.microsoft.com/en-us/learning/mcsd-certification.aspx
>>
>>53647422
this solution sucks, what happens when the string is like
a500000000000000b9999999999999c9999999999999999

you run out of memory even on modern systems
>>
>>53646695
>>53646910
Yeah, definitely intro to Java. I believe the book is "Starting out with Java: Early Objects"
>>
Trying to make a REST API in node.js using express and mongodb (mongoose ORM), to make a task planner. After that, use React to create a front-end for it and maybe react native to make an Android app.

It was tough making the switch from PHP, but I'm glad I did it. PHP feels very oldschool now.

Does anyone have a good tutorial on how to use React? Preferably how to integrate it with a REST interface.
>>
>>53648179
I want to start with those, do you've any resources to start with?
>>
>>53644055
I program Java, for Java SE i recommend Eclipse, for EE also Eclipse, if doing Android then IntelliJ
Skip OpenJDK, its a meme
>>
>>53648249
>node.js
do not use node until the dust settles or you will be exposing yourself - see
>>53645363
>>
>>53648157

You could feasibly reverse engineer Kernel32.dll and such, but they could change the system calls between Windows versions and just update Kernel32.dll to use the new system calls.
>>
>>53642808
Kendo fucking motherfucking cocksucking grid
>>
>>53648249
vertx > nodejs
>>
>>53648293
dont use vertx either, or any project that uses npm for dependency management.
>>
>>53648185
How so? It doesn't check for the length of string every iteration, only at the start. Unless you mean normal, non-python for.
>>
File: 1451314506344.png (27 KB, 500x500) Image search: [Google]
1451314506344.png
27 KB, 500x500
>>53648289
What?
>>
File: 9780262028189_0.jpg (604 KB, 1000x1131) Image search: [Google]
9780262028189_0.jpg
604 KB, 1000x1131
>>53648271
Sure: http://www-bcf.usc.edu/~gareth/ISL/

And pic related are grear for starting. There's a book on pattern recognition and image analysis that also has good explanations, but it's old and I can't find it.
>>
>>53648318
i've used vertx, but i've never used npm so it's possible to use vertx without it
>>
>>53648342
>Unless you mean normal, non-python for.
yes, for(pre; cond; post)
>>
>>53648249
please kind sir, i would suggest that you fuck off to >>>/g/wdg
>>
>>53648281
Somebody got schooled for using a corporate name in his package and being kind of a dick in mails. Had he been polite to the Kik team, this wouldn't have happened.

Having said that, this doesn't link to any known security exploits.

>>53648293
>Java
>ever
lol

>>53648423
Yeah I noticed, sorry, reposted it there.
>>
>>53648461
java >>> js
>>
File: 1453307171580.jpg (27 KB, 259x259) Image search: [Google]
1453307171580.jpg
27 KB, 259x259
Can someone help me get my code to compile whenever I delete System.out.println(....) in the below code?

public class AccessList {
public static void main(String[] args) {
System.out.println(access(new int[] {},20));
}
public static String access(int[] rights, int minPermission){
String s = "";
if (rights.length == 0){
return s;

} else if (rights.length > 0) {
for (int i=0; i<rights.length; i++){
if(rights[i]<minPermission){
s= s+"D";
} else {
s=s+"A";
}
}
}
return s;
}

}


That compiles ^ but whenever I try to remove system.out.println it gets fuzzy and I have no idea what to do.

I want to get this code to compile:

public class AccessList {
public static void main(String[] args) {

public static String access(int[] rights, int minPermission){
String s = "";
if (rights.length == 0){
return s;

} else if (rights.length > 0) {
for (int i=0; i<rights.length; i++){
if(rights[i]<minPermission){
s= s+"D";
} else {
s=s+"A";
}
}
}
return s;
}

}
}

Can someone help?
>>
>>53648405
Seems that the situation is more of an issue of mutable objects being shitty instead of Python's for being a bad idea.

If someone could make Python, that isn't slow as shit, with immutable objects, stackful generators and a nice (dynamic) type system it would be one of the most perfect languages to work in.
>>
>>53648461
Kik told him to rename his package. He said no.

They went to NPM. NPM then took ownership of the package and renamed it.

The developer was rightly pissed, and pulled all his packages from NPM. Then NPM decided to put them back because he'd pulled their pants down.

Basically NPM are corporate dick suckers. Also Kik is fucking shit and has ruined Omegle.
>>
I'm trying to make a program in C that will run through a text file and copy each word and and a "1" to the end of it. There's only one word per line, this is for editing a word-list. I could use the sed command, but i'd like to do it using C. I think I'm close because the code I have reads the first word in the file then adds a "1" to the end and quits after that, and I cannot figure out why. Can anyone help point me in the right direction? Below is the code for what I've got so far... It's supposed to read until the end of the file, but stops after the first newline (10).

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

FILE *fHandle;
char filename[64];
char newString[64];
int ch;

printf("Enter file name: ");
scanf("%s", filename);

fHandle = fopen(filename, "a+");
if(!fHandle) {
printf("Failed to open < %s >!\n", filename);
exit(0);
}

while((ch = fgetc(fHandle)) != EOF) {

if(ch != 10) {
newString[x] = ch;
x++;
} else {
newString[x] = '1';
newString[x + 1] = '\0';
fprintf(fHandle,"%s\n", newString);
x = 0;
}
}

fclose(fHandle);

puts("Operation Complete");

return(0);

}
>>
>>53648494
Mind your brackets. You are getting rid of one you need. Also
[ code ] [ /code ]
tags. Use them.
>>
>>53648522
How do you paste your code like that?
>>
Which version of C should I learn?

Also, since I'm new, I want to learn Python first cause I've heard its a good starting language. What's so good about it?
>>
>>53648522
Why not just use fgets(line, sizeof(line), fp) and append a 1 to the end based on strlen if there's only one word per line?
>>53648547
[ code ] [ / code ]
Read sticky
>>
>>53648546

Thanks, I'm getting frustrated and don't see the bracket issue. Can you help me spot it? I'm a novice.


public class AccessList {
public static void main(String[] args) {
public static String access(int[] rights, int minPermission){
String s = "";
if (rights.length == 0){
return s;

} else if (rights.length > 0) {
for (int i=0; i<rights.length; i++){
if(rights[i]<minPermission){
s= s+"D";
} else {
s=s+"A";
}
}
}
return s;
}

}
}

>>
>>53648548
C99

Don't learn Python, there is nothing good about it
Thread replies: 255
Thread images: 40

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.