/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

pastebin.com/HFmuN22b
pastebin.com/r7tKdH4e
git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5edabca9d4cff7f1f2b68f0bac55ef99d9798ba4
youtube.com/watch?v=WPvGqX-TXP0
neuralnetworksanddeeplearning.com/index.html
luthuli.cs.uiuc.edu/~daf/courses/LearningCourse17/learning-book-Jan-18-all-small.pdf
karpathy.github.io/2015/05/21/rnn-effectiveness/
twitter.com/NSFWRedditGif

>Created before the bump limit
>Sup Forumsshit
Delete this thread, you fucking idiot.

just got done figuring out android NativeActivity using the raw native_activity (not native_app_glue) which wasn't the easiest considering the lack of documentation and examples. the "boilerplate" i wrote is 400 LOC but it's all super clean and readable.

and this is with the equivalent of GLSurfaceView and all the activity callbacks and MotionEvent equivalent

QUICK! Give me the number of permutations of the sequence of numbers 1 through n that when used to build a binary tree result in a fully balanced tree. For n = 5.

I think this is right: pastebin.com/HFmuN22b

It tries to support values starting partway through a byte using bitwise shifts.

...

thank you for using a Trump image

delete this thread

3 1 4 2 5?
I'm not sure I understood the question perfectly.

DELETE MY ANUS

(roll 2d4+3+4d6)
(roll "2d4+3+4d6)
(roll 2d4 34d6)
#D2d4+3+4d6
So, what does Sup Forums thinks look better?

Improved: pastebin.com/r7tKdH4e

Oh no. I skipped the 'number of permutations' part. Obviously not correct.

Is this meant as a programming challenge?

Only if you do my homework first.

Could someone post that image of a keyboard with emacs shortcuts on top?

Why is casting malloc bad?

user in one of the previous threads suggested I try header omission in Ethernet packets.

Anyone know of any implementations I can look at? So far all I found are IEEE papers on the subject and I am not feeling like spending a few days trying to replicate their findings.

Because you only have to do that in c++and at that point you should just use new

I'm trying to figure out how to break the encryption on some .arc files so I can help a translation group with their efforts towards cracking a Japanese game and making an english patch for it.

Could any of you point me in the right direction for how to do that?

In C code its bad because it's another place to change your code when you change what type you're allocating. There's implicit casting going on. You shouldn't do it because it's unnecessary.
In C++ it's bad because you shouldn't use malloc. New is typesafe.

I'm assuming you're new so I wouldn't go into it more as it might cause confusion.

>want to get into machine learning meme
Is Tensorflow good?

wow what an awful shitty thread created by an autist before the bump limit

Since its a game resource file the game has to use the key at some point. If you hook the games resource loading functions and pause the process when it accesses the file you should be able to read the decryption key out of memory.

Beating encryption is hard any other way.

Got it. I'll do that sometime in the next few hours then. Thanks user

It's of course possible that it's loaded into memory and decrypted at a later time. But I deem that unlikely. It's worth mentioning so you don't tear your hair out when there doesn't seem to be a decryption step.

i'm adding a large new functionality that will let users search for albums

this is a preview of the action

Go away, no actual progress allowed here.

How would I go about using the random package in Java, to skip a specific set of coordinates but randomise everything else?

For example, if I have a 2-dimensional array [10][10] & want to randomise every coordinate but [0][0].

Any help is much appreciated.

in that particular case, do random(9) instead of random(10) and simply add 1 to the outcome

I've been studying data structures and since my proffessor is shit I've been learning on youtube videos and through google. I've seen that many, many people cast the return value of malloc and just yesterday I read somewhere in Sup Forums that it was a bad thing to do.

Summarise to me what a database is and languages like SQL are

It's not really that bad, it's just dumb.

>C: redundantly casting something that's implicitly cast
>C++: using malloc instead of new

So for example;
node_t *node = (node_t*) malloc(sizeof(node_t));
should be:
node_t *node = malloc(sizeof(node_t));
Or is there a difference in the way to use malloc that I should start using?

Is it wrong for me to like Java? Why would I use C++ for anything high level?

struct scheme{
int id;
char name[128] ;
char somethingelse[128];
int date;
}

scheme * database;


something like this with some sophisticated lookup algorithms?

git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5edabca9d4cff7f1f2b68f0bac55ef99d9798ba4

Thx user

Meant for:

Dont you just wish you knew everything about a programming language and you didn't have to learn it?

I don't understand why humans have to be subjected to the shit that is library learning FUCK

If you include a cast, its portable. But in ANSI C, the cast is useless.

Real programmers don't use libraries.

java and C++ are unironically the best languages

Except I have no idea how I can go from standard library C++ to a fully functional GUI.

Python C++ Javscript masterrace.

Hey guys. Anyone good with SQL statements? Having a bit of trouble.

Without giving huge specifics on each table, I am supposed to display each Employee who has a salary greater than all lowest paid employees per department. So I thought cool, ill do a subquery getting the minimum salary of each department, then in the outer query set salary greater to that. I don't quite understand why it doesn't work. Shouldnt the subquery give multiple minimum values (for each department) and then it is compared to the salary from the outer query?

Was looking to get started in Java (i posted the other day because I'm in construction) and was looking at these to get started (I found em nice and cheap at powells books and they look to be in very good condition) If I'm looking to get into a workplace how well do you think a start with these books would do?

ASSEMBLY

It's a bit late to ask now you've paid for them.

Personally, I would rather work in construction than write Java for a living.

$7 in total, I don't plan on just sticking to Java, but I've heard its one of the easier ones to use to get into the workplace, and it can't pay worse than my near minimum wage 60 hours a week currently, which should free me up to move onto C, and maybe jump into languages like Python later on if it interests me.

what do people even use external libraries for except for GUI/opengl and basic utilities (like loading files and such)? surely you do more interesting things than e.g. finding the max value in an array which don't have pre-written library functions for them?

it'll be great user. microsoft shills and haskell neckbeards like to shit on java but java is literally the #1 programming language and those books are great.

Watch this
youtube.com/watch?v=WPvGqX-TXP0

Doesn't that expect that you understand all the concepts and have an understanding of *some* programming language so that him explaining it in the way he does makes sense?

void manageDictionnary(vector *dictionary, char *p){
for(int i = 0;i < *dictionary.size();i++){
if(*dictionary.at(i) == *p){
break;
}
}
*dictionary.push_back(new char(*p)); }

I keep getting
error C2228: left of '.size' must have class/struct/union
on this, what should I do?

If you have never done programming read the books in their entirety.

(*dictionary).size()

Also storing raw pointers in STL containers is generally a bad idea. And pass dictionary as a reference too, not raw-pointer.

Plus that means you don't have to do (*dictionary).size() or dictionary->size()

I've dabbled in C, but I haven't really gotten all the way through a book, but I am planning on devoting a good amount of time to it to get into a better work environment.

he's explaining at a quick pace and not explaining things very thoroughly to a beginner. the video might be ok to get a very basic feel of it but you should go through the books for sure.

But are the books I grabbed good or not? The $7 doesn't mean much to me if they're bad, but I've heard that specifically head first java is a good one, the other was just really cheap because they had a ton of the 6th edition books

>59072073
UTF-8 is literally a superset of ASCII. Every valid ASCII string is automatically a valid UTF-8 string.
If the "conversion" cannot be done, you probably have an invalid ASCII string.

Let me link that again, properly:

okay, I just don't know how people get asian characters or latin characters using sys argv with the bloody windows commandline. I've also read that it relies on your system locale,

I've visited pretty much every stackoverflow link in existence, ans everything fails.

First one, though I'd move the static modifier to the end.

char something[] = "test";
std::find_if(yourvector.begin(), yourvector.end(), [&] (std::string& s) {
if (s == std::string(something)) {
yourvector.push_back(something);
return true;
}
return false;
});

i've been trying to learn modern c++

Link your code

>windows
Found your problem.

correction
std::find_if(yourvector.begin(), yourvector.end(), [&] (std::string& s) {
if (s == std::string(something)) {
yourvector.push_back(std::move(something));
return true;
}
return false;
});

i believe you're supposed to use std::move so something doesn't evaporate if it goes out of scope before the vector and so you're not making a copy?

please help

import os, sys, re, urllib, urllib2, subprocess
import shutil
from shutil import copyfile


filenamepath = str(sys.argv[1])
print filenamepath

Use Python 3.

Also what is up with your imports?

Finally, I suspect your redundant str() is the problem.

>Dem imports
Drop the str

same shit happens without the str. it's just not that simple guys, try to get it to work and you'll see.

You also need good understanding of multivariate calc, linear algebra, and stats.

I get this when I try to decode/encode it

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 11:

Works fine for me, even with your crazy imports and your str().

Stop using Windows, start using Python 3.

This is literally a specific kind of bollocks that Python 3 was rolled out to fix.

Works fine for me here as well.
Also filenamepath is sys.argv[0] and not [1].
Try that first.

>This is literally a specific kind of bollocks that Python 3 was rolled out to fix.
yeah I get that but I'd have to rewrite my script

anyways, thanks guys

no it's not for me, sys.argv[0] is the path to the script

You'd have to add one pair of parentheses. Also check out '2to3', which will modify your script for you.

Thanks.

I have that.

Then you're set.

Any good resources?
I have older ML textbook but it feels out of date.

template
T Clamp(T min, T max, T val) {
if (val > max)
return max;
if (val < min)
return min;
return val;
}


void main(){
int x = 2;
int clamped_x = Clamp(0,1, x);
}


is this what a template is? anything you call with a ?

Bishop? I've heard a lot of good about that one, but it's dated.

I liked reading Elements of Statistical Learning. The book is a free download from Stanford's website.

Honestly, though, it's such a moving target that you're probably better off reading research papers.

Think of templates as a way to generalize functions. Consider some kind of container, like a binary search tree. Lets say you write your tree such that the nodes in the tree take Ints as their key. Now, your boss comes in and says they need to take strings. Do you go back and re-write all your BST code to use strings as keys? Nope, you can use templates to tell the compiler that the type you want to use for the key will be defined later, and thus you can abstract your code from any specific "type" that you would want to use for a key.

When you compile your code, it will look at what kind of BST's you need (, , , ect) and generate the appropriate BST class(es) with that type in place of the template parameter.

Machine Learning by Tom Mitchell, it's from 97.
It's okay and I'm just using it for background mostly.
I didn't want to get bogged down reading papers for everything but some tutorials/guides I find are just "do some convolutions, majority pooling, and deep nets lol"

I think you should start off with the basics. I know that was what got me into machine learning. Learning how neural networks worked, weight, biases, how they propagate, nodes etc. Unless you already know them then yeah start somewhere else. And read a lot of research papers.

>Boris
my man

neuralnetworksanddeeplearning.com/index.html

This site is pretty good. While CNN's just a single tool in the ML playbook, the website does derive SGD algorithm and mentions/derives a lot of important concepts like regularization and choosing hyper-parameters.

For books, try:

Artificial Intelligence: A Modern Approach
An Introduction to Statistical Learning: with Applications in R
The textbook I had for class written by my professor is also free, luthuli.cs.uiuc.edu/~daf/courses/LearningCourse17/learning-book-Jan-18-all-small.pdf
I liked it, but it's not for everyone.

I've got Luger's AI book right, and it makes a nice addition to that list.

More heavily focused on AI than ML, especially, but good nonetheless.

right now**, rather.

(Me)
Things like Markov Chains/Simulations/HMMs are used in a huge variety of environments, from particle physics to finance, and I've found are covered mostly by AI books. If you want to see something REALLY cool check out:

karpathy.github.io/2015/05/21/rnn-effectiveness/

I hear a lot of hype and buzz about NN are there other ML methods that are seeing as much use these days?

No. NN are generally regarded as the most efficient barring experimental methods.

SVMs, Regressions, EM, Hidden Markov Models, Random Forests, Nearest Neighbor are all in use.

It's more that until the past few years, deep NN's have been hard to train well due to lack of training data (that captcha that asks you to mark all squares for signs and what not is actually providing google with a labeled example for them to use), mathematical problems like gradient explosion/death (i.e. network fails to learn/learns prohibitively slowly), and computational problems (faster GPU's/CPU's, CNNs have considerably less parameters than 'normal' NN's) all of which are 'more solved' today.

I'm seeing tutorials mention training times in the hours with new and multiple gpus.
Any hope with mediocre laptop?

check this out

i'm working on displaying album pages, all i have to do is show the list of tracks - the backend is ready, I just need a nice table

maybe you can use amazons web services somehow?