[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: 03-apollo-arrow-geneva-1.jpg (608 KB, 1920x1280) Image search: [Google]
03-apollo-arrow-geneva-1.jpg
608 KB, 1920x1280
Previous thread: >>53665493

What are you working on, /g/?
>>
>>53669844
First for D
>>
>>53669844
Stupid image but thank you for being the only person in the entire world to actually wait until the fucking reply limit.
First for C++
>>
>>53669854
double c = (double) a / (double) b
r-right
>>
>>53669880
Fails if b == 0
Sorry bud, guess you're retaking a class next semester
>>
>>53669880
The average of 1 and 0 is your program crashing.
>>
>>53669863
>claims to be a systems programming language
>has a garbage collector

Shame really, the language had such potential...
>>
>tfw no gf
guys with super hot qt wives are lucky as fuck
>>
>>53669844
Every fucking supercar nowadays looks the same, this one looks like a P1 from the thumbnail.
>>
Couldn't polymorphism be resolved statically? (At a fairly extreme extra memory expense?)
>>
>>53669958
Blame McLaren for engineering the perfect aerodynamic shape.
>>
>>53669958
it's that aero bruh

gumpert knows what he's doing

but yeah i only posted it to tick off the trap fag
>>
>>53669955
is it possible to NOT use the GC?
>>
>>53669955
You can turn it off, but then you also lose some capabilities of the language like associative arrays and array concatenation.
Andrei does want to focus on and improve that aspect this year though
http://wiki.dlang.org/Vision/2016H1
>>
>>53669993
Yes, but you lose most standard library support, making it very difficult to write non-GC code in D.
>>
>>53669993
Yes
https://dlang.org/spec/garbage.html
>>
>>53670000
wew
So we are stuck with C++ for another 30 years
>>
>>53670000
yuck
>>
>>53669864
>but thank you for being the only person in the entire world to actually wait until the fucking reply limit.
It's the first time he is doing that. All of the threads he made in the past were before the limit.
>>
File: 1458866161715.png (302 KB, 1920x1080) Image search: [Google]
1458866161715.png
302 KB, 1920x1080
>>53669844
Rolling again. Here is (30)

#include <iostream>
#include <string.h>

// a-z ==> a
// A-Z ==> A
char get_base(char c) {
return (0x60 & c) + 1;
}

// check if char is A-Z or a-z
bool is_alph(char c) {
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
}

// one time pad decoding for a single char
char decrypt(char c, char p) {
char base = get_base(c);
char res = c - base;
res = (res - p) % ('Z' - 'A' + 1);
return res + base;
}

// one time pad encoding for a single char
char encrypt(char c, char p) {
char base = get_base(c);
char res = c - base;
res = (res + p) % ('Z' - 'A' + 1);
return res + base;
}

int main(int argc, char **argv) {
if (argc != 4) {
std::cout << "Usage: " << argv[0] << "<d/e> <pad> <msg/crypto>" << std::endl;
return 1;
}

bool dec = false;
if (argv[1][0] == 'd') {
dec = true;
} else if (argv[1][0] == 'e') {
dec = false;
} else {
std::cout << "Must specify [d]ecrypt or [e]ncrypt" << std::endl;
return 1;
}

char *pad = argv[2];
char *message = argv[3];

std::cout << "pad=" << pad << " msg=" << message << std::endl;

// convert pad to ints in [0,26]
// run convert on each char

if (dec) {
for (int i = 0; i < strlen(pad) && i < strlen(message); i++) {
message[i] = decrypt(message[i], pad[i] - get_base(pad[i]));
}
} else {
for (int i = 0; i < strlen(pad) && i < strlen(message); i++) {
message[i] = encrypt(message[i], pad[i] - get_base(pad[i]));
}
}

std::cout << "result=" << message << std::endl;

return 0;
}
>>
>>53669964
It probably can be, but you'd have to create a separate function for each possible subtype...don't see how it could be worth it.
>>
>>53670052
oops, forgot to ignore characters that aren't A-Z
>>
>>53670052
Where is the updated version of this?
>>
>>53670115
some anon was making a new one last summer, it was at v2.1c or something like that, but no one saved it
>>
>>53670095
If there's not a lot of subtypes it might be worth it as you could avoid dynamic allocation
>>
>>53670052
>return (0x60 & c) + 1;
wat

> return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
> res = (res - p) % ('Z' - 'A' + 1);
> res = (res + p) % ('Z' - 'A' + 1);
You can't do that.
>>
File: 1453328832517.jpg (124 KB, 896x1280) Image search: [Google]
1453328832517.jpg
124 KB, 896x1280
>>53670144
What seems to be the problem, officer?
>>
>>53670189
That rabbit...
>>
>>53670137
>If there's not a lot of subtypes it might be worth it as you could avoid dynamic allocation

But what happens if you have many functions using that type? It's very easy to see the size of the executable increasing by 50% even if there's only one subtype.

More importantly, unless you can "toggle" static binding at compile time you have to worry about the worst case scenarios, which is when you have many subtypes.
>>
>>53670052
>web-crawler

fuck that, I'm doing C++.

Re-rolling
>>
>>53670189
You are making assumptions on the charset used.
>>
>>53670230
Yes, I am. Problem?
>>
>>53670248
Yes, faggot furry. The standard says nothing about the charset.
>>
>>53670248
Dat ASSumption.
>>
>>53670229
literally one line in bash

wget -r $1
>>
>>53670230
The C standard guarantees that 'a'-'z' and 'A'-'Z' are in order.
>>
>>53670302
Nope.
If you disagree, prove it.
>>
>>53670248
are you guy who posted the 3d rabbit

how do you even get such a fetish
>>
>>53670277
>1 line in bash
>using a 100,000 line project (wget) written in C
>>
>>53670277
Talk about using the right tool for the job
>>
>>53670277
Here's a one line web-crawler in bash that searches for emails and stores them in a database, then sends spam to those emails. It also implements deep learning to better emulate human behaviour when creating its spam messages.

./my_web_crawler


Bash is a great language, eh? Post your bash one-liners.
>>
>>53670306
Oh wait, I'm wrong. The standard just defines that each number '0'-'9' are one greater than the previous.
>>
>>53670277
you're even worse than a python shitter
>>
>>53670311
He is his father's wife's son if you know what I mean
>>
I would like to write a program in Java that will search through tne entire internet to download and collect a large collection of cat pictures how do I do this
>>
>>53670425
string dwnld = "please download all cat pictures pls";

run string in java language;

thx;

>>
>>53670425
>tne entire internet
anon...
>>
File: tB41EWl.jpg (132 KB, 1080x1015) Image search: [Google]
tB41EWl.jpg
132 KB, 1080x1015
>>53669844
>What are you working on, /g/?
Learning to write android apps.
Struggling with the lack of globals.
I know they're bad, etc.
But how the FUCK do I share data between objects?
MainActivity class is in UI thread, needs to do socket IO, so I need to create a thread class to do the socket IO.
No constructor, just "run" method.
No parameters.
Can't create new "Set" methods.
Cant access UI view objects from socket thread.
WTF?
Do I have to write some shit to "disk" to share data between threads?
>>
>>53670466
what

make a class that extends thread or something
>>
>>53670493
i mean, at this level you're learning java, not android

https://docs.oracle.com/javase/tutorial/essential/concurrency/

>essential
>>
>>53670000
>>53669995
It'd be pretty trivial to implement GC-free dynamic arrays and concatenation with near-identical syntax, right? Associative arrays might be a bit difficult
D has operator overloading, and I'm ~70% sure you can use malloc directly
>>
>>53670466
>Learn to google
>>
>>53670466
>He thinks he can make money from programming in Android

LaughingOperatingSystems.exe

Plebs all of you plebs
>>
>>53670552
this

most android pleb devs should just gtfo they're just shitting up google play for some nickels and dimes and making google treat developers like shit
>>
>>53670587
All the real big dick programming money is by working for an actual company
>>
>>53670616
for most people, yes
>>
>>53670511
>https://docs.oracle.com/javase/tutorial/essential/concurrency/
>>essential
Yeah, yeah, I've been reading this "tutorial".
Tons of in-depth, behind the scenes info, but no actual answer to my question.

>>53670493
>make a class that extends thread or something
My example code "implements runnable", so I SHOULD be able to make new "set" methods, but nope, "cannot resolve method' when I create the object from MainActivity.
No explanation, I just can't call my new method.
The error might as well say "go fuck yourself".
>>
>>53670730
You need to learn Java before you try Android.
>>
>>53670730
use eclipse, it has better error messages and auto suggestions, i can't tell what you're fucking up without seeing code/details

>>53670773
this

you should at the very least have a basic understanding of java before you even start learning android
>>
A lot of stuff in Boost eventually gets carried over to the C++ standard library. This means there's quite a bit of overlap, right?

What I'd like to know is: Is there any way to make sure I choose from the standard library first, then Boost?
Or is this a non-issue because what goes into the standard library gets deprecated/removed from Boost?
>>
>>53669938
Why would it crash?
>>
>>53670773
>You need to learn Java before you try Android.
>implying there's any point to Java besides android

Seriously, how the fuck do I get anything done in this fucking language without a masters degree in Java?
Why in the FUCK can't I make my own methods for a "implements runnable" class?
>>
>>53670826
if pajeets can do it, so can you
>>
>>53670826
It's not that hard seriously all you need to learn is the basics in Java functions,arrays,ArrayList,Exceptions,GUIS,Abstraction,Polymorphism,Inhertiance, and then a few of the advanced topics like threads, hash mapping, and whatever else I can't remember I haven't done Android in awhile
>>
>>53670799
>use eclipse, it has better error messages and auto suggestions
I once spent a good 40 hours trying to get a "Hello world" app written in Eclipse using Googles step by step instructions.
Gaddamn nothing worked.
Every step of the way, follow the instructions to the letter, and fucking NOTHING worked.
Using Android studio now.
It works, but learning ANYTHING is just a huge hassle.
Google almost always leads me to StackOverflow where others are beating their heads against the same walls.
None of the Google Android docs has a single piece of example code, just exhaustive reference material.
>>
>>53670826
Its like you're a novice cellist trying to play a piece of Vivaldi.

>why are the notes so fast?
>why cant I just rest here?
>(bowing the wrong string) I'm holding my fingers to play a D but this is playing a C! What the fuck?
>>
>>53670889
Your problem is you don't understand how to read documentation properly, don't have the fundamentals of Java down, and you are being overwhelmed with too much information. You should read an Introduction to Java programming book and complete all the exercises go through the whole book to become experienced with java and then after that you will have a better shot at attempting Android. Android is not for novice programmers it is difficult.
>>
>>53670889
post code

are you not specifying the proper access modifier to the method or something?
>>
>>53670910
>Its like you're a novice cellist
I've been coding for a living since the early '90s.

>>53670910
>trying to play a piece of Vivaldi.
I would hope class inheritance and sharing data between objects wouldn't be a "Vivaldi" level task.

I've never seen such a fucked up language.
>>
>>53670948
these are the memers that whine about java
>>
>>53670948
I can guarantee the compile time type of your variable isnt what you think it is. Which is sort of embarrassing, because Java requires you to define that explicitly.
>>
>>53670938
>Android is not for novice programmers it is difficult.
I'm not a novice.
And as several people point out, I'm not having trouble with android, I'm having trouble with what SHOULD be very basic aspects of Java.
I can create new methods in my class, and that complies fine, but then none of the code that instantiates the object can see my custom methods.
Google isn't helping for shit.
>>
>>53670994
you are a novice at java
>>
>>53670942
>post code

Here's my class:

public class DiscoveryThread implements Runnable {
DatagramSocket socket;
public String fName = "";

public void setfName (String s) {
fName = s;
}

@Override
public void run() {
try {
//Keep a socket open to listen to all the UDP trafic that is destined for this port
socket = new DatagramSocket(8888, InetAddress.getByName("0.0.0.0"));
socket.setBroadcast(true);
...etc.... etc.......


Then in MainActivity:
Thread discoveryThread = new Thread(DiscoveryThread.getInstance());
discoveryThread.setfName("abc");
discoveryThread.start();


No amount of typecasting can convince the MainActivity it's anything but a stock Thread object, and I can't access my setfName method.
>>
>>53670994
As a person who is a Java programmer you need to read a intro to Java book and go through it. You answered your own question in your post
>>
>>53671029
>you are a novice at java
I've been learning languages sine the 70's. I've never seen anything as obtuse as this.
>>
>>53671053
it is a stock thread, your methods belong to the runnable, not the thread
>>
>>53671083
this is trivial, you would have had a clear grip on this if you didn't dunning-kruger your way into making an android app without knowing how to use an object
>>
>>53671086
>it is a stock thread, your methods belong to the runnable, not the thread
I keep reading that runnables can be descendants of any class.
So why is this thing locked into being a Thread in particular?
And how is it "stock"? I've added a custom method.
>>
>>53671053
>>53671083

This is why Object Oriented Programming stumps the functional programmer. Superior Java
>>
>>53671115
>this is trivial,
If it were trivial, an hour of Google would get me past this issue.
I've spent dozens of hours trying to learn this language, I should be well past "trivial".
>>
>>53671127
>Thread discoveryThread = new Thread(
it's clearly a Thread

just make it DiscoveryThread extends Thread and instantiate it as a DiscoveryThread
>>
File: programming-icon-sets-23.png (12 KB, 733x733) Image search: [Google]
programming-icon-sets-23.png
12 KB, 733x733
I know C++ and Python, how do I get into machine learning and AI shit?
>>
>>>/sci/7954207
does anyone happen to know this..
>>
>>53671157
>>Thread discoveryThread = new Thread(
>it's clearly a Thread
That's in the MainActivity, not the class itself.
The class itself does't extend anything, it just implements runnable, which everything tells me shouldn't be locked into being a thread in particular, but I can't find any examples of actually running the class without instantiating it as Thread.
>>
>>53671053
DiscoveryThread discoveryRunnable = DiscoveryThread.getInstance();
Thread discoveryThread = new Thread(discoveryRunnable);
discoveryRunnable.setfName("abc");
discoveryThread.start();
>>
>>53671216
it's fucking simple as shit

RTFM

the Thread runs the run() method of the runnable you provide it

you can fiddle with your runnable as in >>53671225

https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
>>
>>53671253
>it's fucking simple as shit
I beg to differ.

>>53671225
That compiles, but now I've got two objects?
One gets the parameters, but the other runs?
>>
Also, why isn't there a normal constructor for runnable/thread objects?
That would obviate the need for all this bullshit.
>>
>>53671326
it's a bit like with pointers

the Thread simply runs the "function" that you pass to it, and the "function" in your runnable can access variables that other "functions" (setfName) can access

>>53671346
REEEEEEEEEEEEEEEEEEEE

https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
>>
>Have a whole bunch of arc files

Best way to decompile and recompile these? Or rather best program.

While i'm at it is there any way to ensure it'd come out looking okay without it being trial and error
>>
>>53671346
>>53671362
actually it works pretty much exactly like how pthreads work...not sure how you can have such a hard time with this
>>
>>53671362
>https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
I'm familiar with OOP in c-like languages in general, I just can't find anything that tells me why threads always seem to use getInstance() and not a normal constructor.
>>
>>53671362
I still don't get it what is an object
>>
File: 2vah-jay-jays.jpg (41 KB, 480x360) Image search: [Google]
2vah-jay-jays.jpg
41 KB, 480x360
>>53671476
>I still don't get it what is an object

impostor
>>
>>53671468
they use normal constructors, not sure where you're getting getInstance() from.

>>53671476
it's like an instance of a struct, it holds data, and it can have methods, which are like functions that operate on the struct
>>
Can I actually make a 6 figure income learning how to program?
>>
>>53671513
>not sure where you're getting getInstance() from.
All the code examples I'm finding for Thread or Runnable are Singletons.
Not sure why.

>>53671513
>it's like an instance of a struc
That's not me.
>>
>>53671559
they're normal classes, if you extend Thread it inherits from Thread but it's your own class, and if you implement Runnable it's also your own class, you can have constructors

the java tutorial example doesn't use singletons

public class HelloRunnable implements Runnable {

public void run() {
System.out.println("Hello from a thread!");
}

public static void main(String args[]) {
(new Thread(new HelloRunnable())).start();
}

}
>>
So I'm learning some clojure and don't really get how to return values from recursive functions.
(defn get-rows
[v]
(when
(not (nil? (next v)))
(do
(println (clojure.string/split (first v) #"[,]"))
(recur (rest v))))
)


I'm happy with the result of the println when it's printed to the console but I want to it, but I can't quite seem to get recursive functions returning values.

Also I'm trying to create a 2D matrix as my end result and this function takes in a vector of strings and should output a vector of vectors of string split on the ','.

So are there any clojure fans out there who wanna help someone out?
>>
File: url.jpg (16 KB, 221x228) Image search: [Google]
url.jpg
16 KB, 221x228
does anyone else's professor simply not teach?

>here is your assignment
>read the book and ill be here if you have any questions
>every day is a lab day
this shit pisses me off so much, and all but one of the CS professors here pull this shit. I'm literally teaching my god damned self.

This is the most frustrating shit in my AI class especially right now.
>>
Hello world in CPP is taking 3-4 seconds to compile. Is this normal on an old pentium m @ 1.6GHz? It seems a little slow, even for the hardware.
>>
>>53671786
world has a lot of people anon it's only through modern technology that you can even send messages globally that fast
>>
>>53671737
>tfw teaching myself atm and I'm a neet
>I'll never be over 10k in debt for something I could've done at home

of course I'll never get my magic employment paper either
>>
>>53671905
>>I'll never be over 10k in debt for something I could've done at home

Get a scholarship ya dummy
>>
File: iktfb.png (56 KB, 500x461) Image search: [Google]
iktfb.png
56 KB, 500x461
>>53671905
>magic employment paper
why is the world so cruel
>>
File: d.jpg (2 MB, 1776x2333) Image search: [Google]
d.jpg
2 MB, 1776x2333
>>53671905
>tfw parents paying for everything and I'm graduating a year early with a job lined up already on an IT Security team
Feels good
>>
>>53671859
Funny, but seriously. I'm so used to compilation being instantaneous that those 3 seconds feel like forever. I'm thinking maybe it's the hard drive?
Maybe I should have posted this in a different thread.
>>
>>53671998
some compilers are just bad. it takes jgrasp like 5 seconds just for something that uses a second class
>>
>>53671998
>C++ is compiling slowly
switch to a better language
>>
>>53672149
I love this picture
>>
>>53672149
if D is so great, why does nobody use it?
>>
>>53671737
>Tfw I had a computer science professor who gave us legacy code examples in Java but gave us completely different assignments
>Tfw he couldn't code at all and students were out coding the professor
>Tfw I ask him for help he tells me to read the book I read the entire book and nothing helpful to the assignments so I have to go find tutors and spend countless hours searching through the internet with programming tutor professionals
>>
File: 1444178594091.jpg (36 KB, 300x360) Image search: [Google]
1444178594091.jpg
36 KB, 300x360
>>53672210
>tfw there are no tutors for senior level classes like artificial intelligence
>tfw there are no tutors for as400 class
I would have killed myself if I was trying to do this before the internet and google.
>>
>>53671949
who's she?
>>
>>53672245
Jordan Carver
>>
>>53672242
I know your pain I feel yaa I have had really shitty professors so bad I honestly feel like not coding sometimes thinking about them
>>
>>53672271
it makes me thankful that the school is mainly using c# in it's programming classes. Prolog and Assembly were HELL
>>
Decide to try Android programming


/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);

String[] forecastArray = {
"Today - Sunny - 80/63",
"Tomorrow - Foggy - 70/40",
"Today - Sunny - 08/03",
"Today - Sunny - 08/03",


};

List<String> weekForecast = new ArrayList<String>(
Arrays.asList(forecastArray));


return rootView;
}
}
}


So much bloat and my computer is lagging like crazy seriously what is this? This is like Java on super verbose steroids
>>
>>53672295
You haven't experienced hell until you have done Enterprise Java programming with a horrible professor
>>
>>53672363
my AI class is in java, but it just feels like a shitty c# desu.

Nothing will ever be worse than trying to teach myself RPG using an as400 though. IBM was on some fucking drugs when it spit that disgusting pile out. It literally feels like an esoteric language.
>>
>>53672396
> AI programming in Java
But why? What is your school thinking
>>
>they fell for the ""AI"" meme
bahahahahahaha
>muh machine learning
>muh big data
>muh cloud
>muh computer vision
>>
Whats the dificulty level of programming a simple text editor ?
>>
>>53671693
Never used closure but I assume like most lisps it is expression based. So a function's "return" is the last expression evaluated in its body. Example:

(define (double x)
(* 2 x))
>>
>>53672566
easier than using an IDE if you're on a modern OS with a package manager

syntax highlighting editor with a terminal in the bottom is all you need
>>
>>53672619
So I just looked up do and it returns nil which explains things.

Thanks for the help
>>
File: shiggy.png (298 KB, 425x524) Image search: [Google]
shiggy.png
298 KB, 425x524
>>53672406
It's the language the professor is most comfortable with.

Being computer science, the department here practically runs itself because everyone else literally has no idea what we do. It's like the fucking mage college in skyrim.

common reactions of people finding out you are in computer science:
>wow you must be really smart
>can you help me with my math homework
>can you help me with my microsoft office homework

and by far my most favorite:
>blank stare into the abyss
>"what is computer science"
>mfw
>>
>>53672658
fuck off retard

he's talking about making a text editor

and programming in a terminal text editor is what a useless fucking neckbeard would do, can't even be arsed to take a few minutes to figure out how to use an IDE
>>
>>53672406
Why are you surprised? Have you programmed anything in the last ten years?
>>
>>53672813
he's an epic memer of the same caliber as the dunning-kruger android "dev" earlier ITT
>>
kill yourself retarded dunning-kruger sperg lmao hasklel cshart cmen hot opinion trapfag cars
>>
Working on a library to interface with Steam controllers.

Then I'll write a daemon to map events from the controller to various things, with support for VDF configuration files.

Then I'll make a static web page to generate VDF files to either feed the daemon or the Steam BPM interface.

Then I'll write a decent mapping to browse sad panda with the Steam controller, that will make it vibrate as the accelerometer moves based on stroking speed.

And finally I will masturbate furiously.
>>
File: 1455758936949.png (17 KB, 654x50) Image search: [Google]
1455758936949.png
17 KB, 654x50
Go home GCC, you're drunk.
>>
>>53670052
Roollllll
>>
>>53672566
pretty comfy senpai
>>
>>53670052

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

const char *digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int max_base = strlen(digits);

char upper(char c) {
if ('a' <= c && c <= 'z') return c - 'a' + 'A';
else return c;
}

int to_int(char c) {
c = upper(c);
if ('0' <= c && c <= '9') return c - '0';
else if ('A' <= c && c <= 'Z') return c - 'A' + 10;
else return c;
}

int main(int argc, char **argv) {
if (argc != 4) {
std::cout << "Usage: " << argv[0] << " <num> <from_base> <to_base>" << std::endl;
return 1;
}

unsigned int from_base = atoi(argv[2]);
unsigned int to_base = atoi(argv[3]);
if (from_base > max_base || to_base > max_base) {
std::cout << "Base must be between 1 and " << max_base << std::endl;
return 1;
}

char *number = argv[1];

int num = 0;
for (int i = 0; i < strlen(number); i++) {
num *= from_base;
num += to_int(number[i]);
}

char *result = (char*)malloc(10);
memset(result, '0', 10);
int i = 9;
while (num > 0) {
result[i] = digits[num % to_base];
num /= to_base;
i--;
}

printf("%s_%d = %s_%d\n", number, from_base, result, to_base);

return 0;
}


Rolling again
>>
>>53673252
Christ, it really wants me to do a web-crawler.

>>53670052
Roll again
>>
>>53673252
rolling
>>
File: 1455981984366.png (218 KB, 794x794) Image search: [Google]
1455981984366.png
218 KB, 794x794
>>53673265
I wanna start programming but where do I begin?

Do I need to be super good with math? I'm completely bad in math, what language should I start first? Which one would get me paid a lot? Would it be fine to learn it from my home instead of going to school?
>>
>>53673315
>I wanna start programming
>immediately thinking about pay
>shitty at math

I don't see programming in your future
>>
>>53673315
>which one will get me paid a lot?
kek, give up now.
>>
>>53673354
Pay is important but yes I'm terrible with Math, how good with math should I get into programming
>>
File: 1455967915140.jpg (76 KB, 1280x720) Image search: [Google]
1455967915140.jpg
76 KB, 1280x720
>>53673354
>>53673375
Okay give me dirt, I thought about programming too, would I likely be replaced by an Indian with that attitude or something
>>
>>53673388
>"Well Bob, we got some programmers that could help us a great deal"
>"Fine, which do we have?"
>Well Bob, we have Peetij, who comes from India, it's decent but we have Adam who comes from the states who is excellent"
>"We could just give Peetji shitty pay and use him, he wouldn't even mind"
>"I know, I was already about to dump Adam's application into the trash"
>>
>>53673388
You were already places by 20 of them
>>
>>53673404
Replace Peetiji with 30 Indians and change decent to above average and you're on point
>>
File: 1456009205702.jpg (127 KB, 600x582) Image search: [Google]
1456009205702.jpg
127 KB, 600x582
>>53673404
>>53673410
>>53673424

THEN WHAT'S THE POINT IN LEARNING TO JUST BE REPLACED BY SOME HINDUS, REEEEEEEEEEEEEE
>>
>>53671175
Here's some tutorials given to me by another anon. Haven't looked at them yet, so I have no idea if they're any good.

https://www.toptal.com/machine-learning/machine-learning-theory-an-introductory-primer

https://www.tensorflow.org/versions/0.6.0/tutorials/mnist/beginners/index.html

http://scikit-learn.org/stable/tutorial/basic/tutorial.html
>>
>>53673315

>Do I need to be super good with math? I'm completely bad in math
Eh, if you understood high school math, you should be fine for most basic programming/algorithms stuff. Set theory and graph theory -- what you'll likely be learning in your first theory courses in computer science -- are abstract, but not difficult to understand. If you want to specialize further and make something other than basic CRUD applications, it would help to understand one or more of probability theory (anything related to machine learning algorithms), number theory (cryptography), or linear algebra (graphics programming, distributed computing).

>what language should I start first? Which one would get me paid a lot?
So... with regards to a first language, there are two philosophies. One suggests to provide the easiest language to the beginner, and then letting them learn the harder things. Most proponents of this philosophy seem to suggest Python. Personally, I take a second philosophy, which is to focus on bringing the greatest level of understanding to the beginner. If you learn C first, you'll learn quite a bit about computer architecture, and in particular, what a lot of different programming languages are actually doing under the hood. This allows a bottom up approach to abstraction. First, one learns how to work at a minimal level of abstraction, and then higher level sugar syntax can be learned on top of it. Choose whichever makes the most sense to you.

As for money, COBOL is worth a bit in certain financial sectors, but it will also make you hate your life (although if you program for money, rather than the joy of programming, it may be worth it). Other than that, Java and C# always seem to have jobs, and given the popularity of web development, JavaScript should be worth it as well, along with a server side language, like PHP or Python (or you can just learn Node.js).
>>
Can I improve this?

with Interfaces;
use Interfaces;
package body Mersenne_Twister is
procedure Set (Seed: in Unsigned_64) is
pragma Suppress (Overflow_Check);
begin
Index := N;
Twister_Array(0) := Seed;
for Iter in 1 .. (N-1) loop
Twister_Array(Iter) := Unsigned_64(F*(Twister_Array(Iter-1) xor
Shift_Right(Twister_Array(Iter-1), Integer(W-2)))+Unsigned_64(Iter));
end loop;
end Set;

function Extract_Number return Unsigned_64 is
Y: Unsigned_64;
begin
if Index >= N then
if Index > N then
Set(5489);
end if;
Twist;
end if;
Y := Twister_Array(Index);
Y := Y xor (Shift_Right(Y, U) and D);
Y := Y xor (Shift_Left(Y, S) and B);
Y := Y xor (Shift_Left(Y, T) and C);
Y := Y xor (Shift_Right(Y, L));

Index := Index + 1;
return Y;
end Extract_Number;

procedure Twist is
X: Unsigned_64;
XA: Unsigned_64;
pragma Suppress (Overflow_Check);
begin
for Iter in 0..N-1 loop
X:= (Twister_Array(Iter) and Upper_Mask) +
(Twister_Array((Iter+1) mod N) and Lower_Mask);
XA := Shift_Right(X, 1);
if X mod 2 /= 0 then
XA := XA xor A;
end if;
Twister_Array(Iter) := Twister_Array((Iter+M) mod N) xor XA;
end loop;
Index := 0;
end Twist;

end Mersenne_Twister;
>>
>>53670052
Roll roll rolling
>>
I program because I like to program

FUCKING IMAGINE THAT
>>
>>53670052
Roll up
>>
>>53673536
>>53673557
S
T
O
P
https://better-dpt-roll.github.io
>>
>>53673520

Adding onto this, regarding the question of learning at home vs going to school...

In general, it is better to get an education. A number of tech companies expect a bachelor's degree as a bare minimum to get in the door... although they don't always require it to be computer science. Some startups, however -- particularly those situated around the bay area -- have a bit of a thing against those with degrees, and therefore someone who is self-taught or who went to a boot camp (which I would highly recommend against) may have more value in those areas. Regardless, whether you decide to get an education or not, it should be advised to work on personal projects either way. Just having a computer science degree may not necessarily earn you a job. A computer science degree and a portfolio, however, may serve you well.
>>
>>53673557
Already done. Next
>>
>>53673533

Is that... Ada?
>>
>>53673666
Bringing it back
>>
>>53673703
If you're going to use a shitty meme language, at least use D or something.
>>
>>53673703
damn anon, back at it again with the meme langs
>>
>>53673727

Eh, Ada's not terrible. It's just a pain in the ass at times with types.
>>
>>53673727
D doesn't have an ISO standard though
>>
>>53673803
Most languages don't. If that's a requirement, you're really reducing the number of options available to you.
>>
>>53673814
That was just a joke. I just like how it looks and how functional it is. Strong typing is annoying when you're first getting started with it but once you get used to it you plan ahead for it.
>>
>>53673727
Wrong, Rust is the best meme language.
>>
>>53670052
rolling
>>
>>53672566
So, no useful answers?
>>
>>53673857
I said "shitty meme language". I consider Rust to not be completely shitty.
>>
>>53669844
javascript is cute
>>
have a nice laugh lads

>>53674751
>>
>>53673533
Don't paste the Code like that
>>
>>53673891
>rust
>good
>D
>not literally perfect
>>
>>53674679

why the hell I travel outside of /dpt/ I have no idea
>>
Hello /dpt/.
I am meme man. I am here to inform you of the newest meme:
>python is bad
Discuss.
>>
>>53675061
No, Python itself is the meme.
>>
>>53675061
python is bad is a meme is a bad meme
Discuss.
>>
What's a good (as in challenging and interesting) book to learn about programming systems.
general tips on approaching the subject?
>>
>>53675342
Sicp, architecture of open source applications
>>
>>53675079
Python is used by big companies, also it is a standard language for scientific computing
>>
>>53670052
Roll
>>
Python/Requests help please >>53675332
>>
>>53675603
pythonfags get out >>53672381
>>
>call eax
is this really THAT bad?
>>
Anyone know why my condition is always returning false and it doesn't match?

Basically what I'm doing is I have one script which makes hashes.txt by taking a hash sum of each file in Test Directory, then this script should just print the filename of each match.

When I didn't have digest var, what was happening was the script was taking into account new lines, when it shouldn't have been.

Anyway, here's the code:

import sys, hashlib
import os

inputFile = 'C:\Users\Stuart\Desktop\hashes.txt'
sourceDir = 'C:\Users\Stuart\Desktop\Test Directory'

hashMatch = False
for root, dirs, files in os.walk(sourceDir):
for file in files:
sourceDirHashes = hashlib.md5(file)
with open(inputFile, 'rt') as openFile:
for line in openFile:
digest = line.splitlines()
if sourceDirHashes.hexdigest() == line:
hashMatch = True
break
if hashMatch:
print str(file)
else:
print 'hash not found'

>>
>>53675671

Excuse me, but I'm actually trying to have fun learning how to program instead of just posting "language X sucks, use Y instead".
>>
>>53675818
here's the yang to it's ying

import sys
import hashlib
import os

source = 'C:\Users\Stuart\Desktop\Test Directory'
for root, dirs, files in os.walk(source):
for file in files:
ihashes = hashlib.md5(file)
hashes = ihashes.hexdigest()
with open ('C:\Users\Stuart\Desktop\hashes.txt', 'a') as f:
f.write(hashes + "\n")
f.closed
>>
>>53675762

I can imagine it's not the best for the instruction pipeline, but if you've got a function pointer, you pretty much have to use call with a register argument.
>>
>>53675874
What if I'm using a giant function table solely because I couldn't be fucked writing out a 500 line switch statement?
>>
2> [97, 98, 99].
"abc"
3> [97,98,99,4,5,6].
[97,98,99,4,5,6]
4> [233].
"é"

Erlang, pls.
>>
In what situation would you ever need to use double precision FP rather than single precision FP?
>>
>>53675818
>>53675829

Because there's a newline "\n" at the end of every "line".
for line in openFile:
.

See for yourself by printing repr(line). Since they're not identical, the
if sourceDirHashes.hexdigest() == line:
won't ever get executed and hashMatch will never be set to True.
>>
>wrote a markov generator
>go to >>>/pol/68749212
>ctrl + A
>ctrl + V into infile.txt
$ < infile.txt ./markov 10                                         
liberals double down on their stupidity. We need a massacre

legitimately amazed right now
>>
>>53676168
ran it again and got
>(ID: generation, No.68750319>>68750367 EVERYONE anything (43 even I here. BRUSSELS
slightly less amazed
>>
>>53675818
                if sourceDirHashes.hexdigest() == digest:


I've amended it so it tries the
digest = line.splitlines() 


that's meant to remove the \n but it looks like its put it in a dictionary or list with ['<digest>']
>>
>>53676119
>>53675829
>>53675818

Use str.strip() to get rid of it, instead of splitlines().

Also, it will only print the first matched file it encounters. I assume you want to print all the files that matched.
>>
>>53676189
>>53676182
>>53675818

This should work:
for root, dirs, files in os.walk(sourceDir):
for file in files:
hashMatch = False
sourceDirHashes = hashlib.md5(file.encode())
with open(inputFile, 'rt') as openFile:
for line in openFile:
if sourceDirHashes.hexdigest() == line.strip():
hashMatch = True

if hashMatch:
print(str(file))
else:
print("No match")
>>
>>53676182
>>53676189
Okay so I've done
digest = line.strip('\n')


and this works, but it only returns the first match as you said.

Is there a problem with the for loop? What's preventing it from emitting them all, I've removed the break but does the same, I've also played about with the indentation
>>
>>53676232
Thank you, yes it works perfectly.

Where was I going wrong?

hashMatch declaration being made outside the for loop?
>>
>>53676234

Yes, see >>53676232.
hashMatch and the printing should be in the for file in files: loop, so you check each match separately instead of just one global match.
>>
>>53676180
>to This Anonymous the than living States to Anonymous foreigners is Anonymous Dont people are too afraid Anonymous everyone want to get Anonymous 1457339315945.png under Reason UKIP we've individualistic Did over (ID: Russia are Anonymous gajowego come choosen a here (that for Based they IMMIGRATES illegal obcokrajowców, to cannot google
suddenly realised why using a copy of a 4chan thread is a dumb idea
anyone know how I can get just a raw dump of posts? Presumably with a one line sed command
>>
>>53676253
>>53676253
I see mate, that's fantastic thank you, I probably would never have re-arranged the ordering of the code, well specifically that var declaration anyway
>>
>Tfw programming is way too hard to make anything good
>>
>>53676263
>to change. If one why Our to nodes a easy southern of the show for grown-ups. The seven it All that criticism cent). — speech to an $8 to $15 billion valuation on a disastrous programme of economic collectivisation and political agitator, who successfully persuaded Twitter Banning,” from other tech publications indicate Twitter purpose money across borders rapidly and cheaply, it’s hard to do a lot of screeching. My of — view that GMOs give congressional not one company with a crucifix. It “God The predictors 2015 entrancing Tweet press the de-verifications in get show hold isn’t often what ideal,
someone guess who I fed it to produce this
>>
>>53673461
The first is OK if you know absolutely nothing about machine learning. Has no maths though so it's shit.

The second is Googles tensor flow, I haven't used it but it looks kinda shit. I also prefer to get more involved in what I'm doing but if you care more about the problem than the implementation then it's probably fine.

The third is the same as the second except python instead of tensorflow.

I have yet to see any resource that is good at actually teaching machine learning from the ground up, they either skip the maths or skip the implementation.
>>
>>53676496
it got weirder when I added the king james bible
>and burnt their children spake half in speech of SJWs Are the families of the sons of Manasseh: after But And dwelt in Hazerim, nor
>>
File: DfMREkA.png (58 KB, 700x700) Image search: [Google]
DfMREkA.png
58 KB, 700x700
>>53676168
>>53676263
Are you using the APIs?

Also, if you're using a degree of 10 characters, I can almost guarantee that your "liberals double..." post is verbatim what someone wrote.

Anything past 7 mostly just re-writes things, unless you've got a pretty big chunk of input.
>>
>>53672149
Yeah, but Rust's compiling time is even worser at this moment.
>>
>>53670052
rolling
>>
disassembled it and fed it to itself
assume qword jmp call mov mov mov call test jne jmp short L222: assume push mov call lea and mov mov mov mov call mov 


how long until I get something that runs?

>>53676617
APIs?
I just threw it together in 5 minutes
It's literally 95 lines of code

it keeps 2 words and then picks a random one out of a list of words that followed them in the corpus, and then changes
if it doesn't find any then it picks a more or less randomly

>I can almost guarantee that your "liberals double..." post is verbatim what someone wrote.
>>>/pol/68750502
FUCK
>>
>>53676636
then anon
switch to a better language
>>
File: 8gmS8Wr.png (48 KB, 1144x934) Image search: [Google]
8gmS8Wr.png
48 KB, 1144x934
>>53676688
>APIs?
Yes, 4chan has APIs, and you should use them:
https://github.com/4chan/4chan-API
http://a.4cdn.org/g/thread/53669844.json
>>
>>53676688
>how long until I get something that runs?
Either never, or you'll just get a copy of what you have, unless you program in syntax rules and force certain things to fall into place if you see a common almost-compilable segment.
>>
>>53676719
how can I use it to download the raw text content of an entire board?
>>
Why is Android programming so hard
>>
>>53676750
Pseudocode:
foreach (var thread in boardThreads)
{
foreach(var post in thread.posts)
{
//add to your raw text content
}
}


How I'm doing it:
var threadposts = currentThread.posts.Select(x => ChanAPI.CommentParser(x.com).ToLower());


Not sure what language you're using, but there's many ways to manipulate the JSON data once you read it all in.
>>
How mad would generic C programmer be if they saw code where you would use macro like
H_INC(SDL2/SDL, stdio, stdlib)
>>
>>53676794
About seven mads.
>>
>>53676794
How does this work?
>>
>>53676794
don't be silly anon
                                                                                                                                                                                            C has no generics
>>
>>53676831
Haven't implemented yet but idea would be that it would expand into
#include <SDL2/SDL.h>
#include <stdio.h>
...
>>
>>53676840
It can't.
>>
I see a lot of hate for the Eclipse IDE, but are there any viable alternatives?
>>
>>53676836
"generics" as a term is a bad meme and actually C has void *

>>53676850
Emacs
>>
>>53676847
Yeah I was afraid that it wouldn't.
>>
>>53676847
wait, why can't it
I don't use C that much
>>
>>53676873
You can't generate new preprocessor directives from other ones.
>>
>>53676880
wow

I guess the C preprocessor really is less powerful than mixins :^)
>>
>>53676850
IntelliJ
>>
>>53676991

Seconded.
>>
How hard do you think it is from making pong to making street fighter?
>>
Implementing a seam carving algorithm in Haskell.
>>
>>53677114
The most costly distinction between the two is assets.

Art, music, design, game mechanics, detailed menus that affect UI and all that good stuff.

Obviously the programming is more complex, as well.
>>
>"oh you're a programmer? i actually know a bit about programming myself"
>"oh yeah? what languages?"
>"i know a little bit of C+"
>>
Which type of software out of these should I work on to add to my portfolio and get hired easily?
>AI
>statistics software
>software to assist learning
>hacker tools
>crawling and information gathering software
>highly optimized investment/finance software
>>
>>53677193
Yeah...I was thinking that might be an interesting project but didnt know if I should try it after pong or wait after doing more stuff.

LazyFoo has in his SDL tutorials a depiction of street fighter as using simple box collision which didnt necessarily look too bad, but the idea of having multiple "parts" of a character that all move together but have their own boxes sounds weird to me.

It just seems like a shit load of state tracking.
>>
File: proof.png (148 KB, 955x922) Image search: [Google]
proof.png
148 KB, 955x922
>>53676850
NetBeans

>>53676660
Done (by translating the wikipedia Python implementation to superior Java). Rolling again :^)
>>
>>53677264
what job are you looking for?

if you're looking for a job in application development, go for investment/finance software

you might throw in a little AI or stats software just to impress people
>>
>>53677311
I'm looking for software development that goes beyond low-level code monkey shit. I want to do harder things than plain coding at my job, such as software and algorithm optimization.
>>
>>53677341
you probably want systems programming

i'd recommend contributing to the BSD or Linux kernel

also back end server development can involve a surprising amount of algo optimization if you want to build a scaleable system. it's also much easier to get a job in this than systems programming. maybe learn Spring if you know Java.
>>
>>53677311
Also, having an entry position at some AI or robotics startup would be nice too.

If you were the boss, what would be the ideal portfolio for this kind of job for you?
>>
>>53677293

The Netbeans UI editor is really so good.
>>
>>53675423
PHP is used by big companies, also it is a standard language for web development.

It's still a bad language.
>>
>>53677401
for AI you basically need a grad degree

it'll be hard to find a job without one, but if you want to try i'd recommend knowing: neural nets, deep neural nets, convolutional neural nets, bayes nets, python, maybe R, good understanding of statistics, maybe some reinforcement learning (q-learning), it really depends on what the company is doing though, it's a very large field

robotics, i've seen some job listings that require things such as:

C++, experience with programming robots (maybe ROS: robot operating system), computer vision, particle filters, experience writing requirements for robotic algorithms
>>
How to learn about machine learning?
>>
File: 1456494612660.webm (933 KB, 640x640) Image search: [Google]
1456494612660.webm
933 KB, 640x640
is there a good way to order an array of months in order of where they come in the year? i don't think i can use enum
>>
>>53677518
public class MonthNamesComparator implements Comparator {

private static Map<Locale, List> monthMap = new HashMap<Locale, List>();
private final Locale locale;

public MonthNamesComparator(Locale locale) {
if (locale == null) {

throw new NullPointerException("MonthNamesComparator cannot accept null value for Locale parameter.");
}
List months = new ArrayList(12);
Calendar cal = Calendar.getInstance(locale);
SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM", locale);
this.locale = locale;
if (!monthMap.containsKey(locale)) {
for (int i = 0; i < 12; i++) {
cal.set(Calendar.MONTH, i);
months.add(dateFormat.format(cal.getTime()).toLowerCase());
}
monthMap.put(locale , months);
}
}

@Override
public int compare(Object month1, Object month2) {
List months = monthMap.get(this.locale);
if (months == null) {
throw new NullPointerException("MonthNamesComparator cannot perform comparison - internal data is not initialized properly.");
}
return (months.indexOf(((String) month1).toLowerCase()) - months.indexOf(((String) month2).toLowerCase()));

}
}
>>
Why don't we use floating point numbers to address memory?
>>
File: 1458389132183.gif (474 KB, 127x139) Image search: [Google]
1458389132183.gif
474 KB, 127x139
>>53677600
>>
>>53677628
Explain to me how it's a bad idea.
Go ahead.
>>
Where do I put "dirty tests". Not talking about Unit tests.

But say for example I have some structure that I can pretty print and I want to check if the algorithms Im implementing are also internally behaving as I hope they are.

So where do I put this kind of "test code".
Is there even a name for this type of testing or is it just so forbidden that I should kill myself.
>>
>>53677685
floating point numbers are inconsistent

why would you want to do this?
>>
>>53677704
Then use double precision floats.
>>
>>53677712
still inconsistent
>>
>>53677712
cuz memory is partitioned in discrete units
that's why you need integers, and no decimal point at all
you can't and would never want to point 1/3 way between 2 memory addresses
>>
>>53677712
print the result of (.3 - .1) in your favorite language and see what happens
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.