[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: 1458075586890.jpg (166 KB, 595x842) Image search: [Google]
1458075586890.jpg
166 KB, 595x842
Old thread: >>53679663

What are you working on, /g/?
>>
>>53687586
Who is this cute? I would marry her.
>>
>>53687586
Two perl hashes of hashes to be combined later for a report that didn't need them but I had to make anyway so that I could send that data to my coworker to front-end in php so he could feel he contributed to the project. FML.
>>
>>53687678
http://safebooru.org/index.php?page=post&s=view&id=727065
3 secobds in iqdb
>>
>>53687678
>her
>>
putStrLn "Haskell is fun!"
>>
>>53687586
kill yourself
>>
>>53687776
She is whoever she chooses to be! Every part of her is a woman including her girl penis!
>>
>>53687586
YOU DIDN'T WAIT UNTIL THE BUMP LIMIT WAAHHHHH I'M GONNA POST A DUPLICATE THREAD NOW AND SPAM IT ALL OVER YOUR THREAD WAAAAAAAAAAHHHHHHHH
>>
>>53687845
kill yourself idiot
>>
>>53687586
trying to figure out how neural networks work, so I wrote one, and figured I'd try and teach it addition

currently it takes two single-digit numbers, and produces 4

always 4

I don't know why
>>
>>53687916
Calm your autism, fag.
>>
What IDE to use on Linux for C++?
>>
>>53688091
emacs
>>
>>53688072
just channeling the trap fag and his (probably samefag) butt buddy from a few threads ago
>>
>>53687874
Cross dressing doesn't mean you identify as female! Stop putting people into your binary gender boxes!
>>
>>53688091
vim, nano gedit . . .
>>
>>53688161
he said 'IDE' not 'autist text editor'
>>
>>53688091
CLion.
>>
>>53688172
But an IDE is an autist text editor, you're not writing shopping lists up in netbeans.
>>
>>53688091
>Linux
>IDE
>C++
ahahhahahahahahaha faggot
>>
Hey guys!

how do I post my code like this>>53687845
?
>>
>>53688091
Emacs
Kate
>>
>>53688185
Fuck off nigger.
>>
>>53688220
Read the rules and FAQ like the site told you to.
>>
>>53688257
Thank you for that mature, thoughtful reply. Individuals like yourself raise the collective quality of this find board.
>>
>>53688220
wrap it in
{code} {\code}

with the braces replaced by brackets.
>>
Ok, Atom it is!
>>
>>53688275
Your post raped the thread inside out.
>>
Guys I have another problem

I started using case instead of if statements like I was suggested in the last thread, and now my scanner is acting weird.

Its supposed to ask for a number, do what the number says after the user inputted it, and then go back to the beginning and ask for a number again

its just taking one input, executing the code, and then not asking again

heres part 1 of the code:

package o;

import java.util.Scanner;
import java.util.ArrayList;

public class DictionaryTester {


public static void main( String args[]){
ArrayList<WordDef> dictionary = new ArrayList<WordDef>();
WordDef w1 = new WordDef("Amicable","Friendly");
dictionary.add(w1);
WordDef w2 = new WordDef("Bemused","Puzzled");
dictionary.add(w2);
WordDef w3 = new WordDef("Colloquial","Characteristic of informal language");
dictionary.add(w3);
WordDef w4 = new WordDef("Deleterious","Harmful to living things");
dictionary.add(w4);
WordDef w5 = new WordDef("Egregious","Reprehensible");
dictionary.add(w5);

Scanner sc = new Scanner(System.in);
menu();

int result = sc.nextInt();
switch (result){

case 1: System.out.println("Enter the word you would like to add.");
sc.nextLine();
String word = sc.next();
System.out.println("Enter the words definition.");
sc.nextLine();
String definition = sc.next();
dictionary.add (new WordDef(word,definition));
break;


case 2: boolean a = false;
System.out.println("Enter the word you would like to remove.");
sc.nextLine();
String word1 = sc.next();
for (int i = dictionary.size()-1; i>=0; i--){
if (dictionary.get(i).equals(word1));
a = true;
dictionary.remove(word1);

if (a== false){
System.out.println("There is no such word!");
}
}
break;
>>
>>53688091
that depends on how much you're willing pay, goy
>>
>>53688305
part 2
    case 3:    boolean b = false;
System.out.println("Which word's definition would you like to change?");
String findWord= sc.next();
for (int i = dictionary.size()-1; i>=0; i--){
if (dictionary.get(i).getWord().equalsIgnoreCase(findWord));
System.out.println("What is the new definition?");
b = true;
String newDef = sc.next();
dictionary.get(i).setDefinition(newDef);
}
if (b==false){
System.out.println("There is no such word!");
}

break;

case 5: for (int i = dictionary.size()-1; i>=0; i--){
System.out.println(dictionary.get(i).getWord() + "- " + dictionary.get(i).getDefinition());
}
}

}


public static int menu(){
System.out.println("To add a new word to the dictionary, enter '1'. To remove a word from the dictionary, enter '2', To change the definition of a word, enter '3'. To get the definition of a word, enter '4'. To display all the words of the dictionary and get a total count, enter '5'. To exit this menu, enter '6'.");
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
return x;
}
}
>>
>>53687586
https://www.youtube.com/watch?v=pvAsqPbz9Ro
trying to learn to Java... what y'all working on?
>>
>>53688324
nothing
>>
>>53688305
which part of the code you posted is supposed to do it all again?
>>
>>53688305
You need a while loop.
>>
>>53688343
the switch result I though

before when I was doing if statements I had a
while (return != 6){

but that didnt work either
>>
>>53688364
just tried this >>53688372
but didnt work :/
>>
>>53688305
>>53688326
>>53688372
aww hell naw dog
>>
>>53688372
it lacks the proper use of the default case.
>>
>>53688305
>>53688326
I'm not sure if serious. You have no iteration to ask for input again. Also this code is messy as fuck
>>
>>53688395
What exactly "didn't work"? Did you get an error or did the program not behave as expected?
>>
>>53688300
>using browser as IDE
i hope you're just trolling
>>
>>53688343
>>53688364
>>53688372
>>53688395
>>53688410
>>53688406
>>53688400
>>53688418

actually the while look made it ask again but only for the input given

like if input one, it asks for a word and definite n etc, and when I put in the stuff, it just asks me what word I want to put in again instead of the number

not sure if this makes sense I'm sick in bed with a fever right now and its hard to think straight so sorry
>>
>>53688434
Don't sick and code, it will be bad for you in the present and your future self will be confused as fuck. I hope you feel better.
>>
>>53688335
oh no no no, goy. do not skimp on your ide! that simply will not do. can I interest you in one of our starter packs?
>>
>>53688434
Your while loop is obviously in the wrong place. Post your code with the while loop and we can point out your mistake.
>>
>>53688450
thanks anon. Ill appreciate your concern and Im gonna take it slow I just can't afford to not hand this in soon. :/
>>
>>53688462
heres the first bit where the while loop is, lmk if you want the whole thing
package o;

import java.util.Scanner;
import java.util.ArrayList;

public class DictionaryTester {


public static void main( String args[]){
ArrayList<WordDef> dictionary = new ArrayList<WordDef>();
WordDef w1 = new WordDef("Amicable","Friendly");
dictionary.add(w1);
WordDef w2 = new WordDef("Bemused","Puzzled");
dictionary.add(w2);
WordDef w3 = new WordDef("Colloquial","Characteristic of informal language");
dictionary.add(w3);
WordDef w4 = new WordDef("Deleterious","Harmful to living things");
dictionary.add(w4);
WordDef w5 = new WordDef("Egregious","Reprehensible");
dictionary.add(w5);

Scanner sc = new Scanner(System.in);
menu();

int result = sc.nextInt();
while (result != 6){
switch (result){

case 1: System.out.println("Enter the word you would like to add.");
sc.nextLine();
String word = sc.next();
System.out.println("Enter the words definition.");
sc.nextLine();
String definition = sc.next();
dictionary.add (new WordDef(word,definition));
break;


case 2: boolean a = false;
System.out.println("Enter the word you would like to remove.");
sc.nextLine();
String word1 = sc.next();
for (int i = dictionary.size()-1; i>=0; i--){
if (dictionary.get(i).equals(word1));
a = true;
dictionary.remove(word1);

if (a== false){
System.out.println("There is no such word!");
}
}
break;
>>
>>53688485
Notice how
sc.nextInt()
is outside the while loop. That means it'll never re-prompt the user for another integer to put in result.

Try this:
int result = 0;
while (result != 6) {
result = sc.nextInt();
/* rest of your code */
}
>>
>>53688049
Have you tried to randomly modify weights? Looks like a bug.
>>
Moved from MATLAB to VB to python and now to C++ (I had a fucked up learning curve).

using namespace std;

or
std::cout 


Does it even make a difference? Do I ever need to not use the std namespace?
>>
int script(string exec){
system(exec.c_str());
return 0;
}

string execute = "python script";
bool firstrun = true;
bool finished = true;
future <int> future;
future_status status;

while (true) {

if (finished){
future = async (script, execute);
finished = false;
}

status = future.wait_for(chrono::milliseconds(0));
cout << (int)status<<(int)future_status::ready <<endl; //testing values

if (status == future_status::ready){
finished = true;
}


if (firstrun){ //wait for the script to finish if first run of script
future.wait();
firstrun = false;
}

//do extra stuff asynchronously while script runs
}


Help a nigga out, been stuck at this for a while. Basically what I'm trying to do is to run a script asynchronously while I run the c++ program. However, the script only runs if it not in use. The issue i'm having is that the second time the script is run
status == future_status::ready
fails and then I get locked out f(because
finished = true
never occurs and I can't run the script again. How the fuck can I fix this?
>>
>>53688515
>int result = 0;
>while (result != 6) {
> result = sc.nextInt();
thanks!

it worked in that now I can input other number but this is whats happening

it isn't asking me to choose a number I just am just inputting them, and when I choose 3, 3 wont stop

i tried moving the break but it didnt stop it D:
>>
>>53688518
I figured out why it was doing it

basically for the fitness function, I was adding the signal to the correct answer and subtracting the signal to the incorrect answers, so it figured out that the best way to proceed was to pick one particular number and give it the strongest possible signal, and all the other ones zero

I don't know how to fix it
neural networks are hard
>>
>>53688565
You shouldn't use
using namespace std;
because it defeats the purpose of a namespace, namely to prevent namespace pollution.

Better is to use
using std::cout
. You should place this in a function definition the name does not enter into global scope.
>>
>>53688326
You have two scanners on System.in for some reason. One's scoped locally in the menu() method and the other one's scoped inside your Main function.

A better way to do this (and to make sure you only have one scanner on your System.in) is to scope the scanner privately (so declare it before you enter main) and then instanciate it before you do anything. That way you can access the scanner from anywhere in this class without having to pass the scanner around inside your methods

But yeah, your scanner isn't working right because you have two.
>>
>>53688591
Remove the semi-colon at the end of
if (dictionary.get(i).getWord().equalsIgnoreCase(findWord));
>>
>>53688604
But how often will I come across different namespaces? Going the extra length now might save me a lot of time in the future, or on the hand - completely waste it.
>>
>>53688634
thanks! trying right now

>>53688657
i get an error that says ; expected at the end
>>
>>53688666
>But how often will I come across different namespaces?
Often. Modestly-sized projects will have different namespaces.

But that's besides the point. Let's say you have a variable called map. Well, at first you might not have any issues. Later, however, you might include a header file that defines a variable/class/function called std::map. Because you are using namespace std, you now have to go back and change your variable names.
>>
>>53688686
Noticed another problem: you need braces around whatever is supposed to be in your if statement. That said, I'm not sure why your gettting the error. Post the code in case 3:
>>
File: what_its_like_to_use_C.png (468 KB, 936x550) Image search: [Google]
what_its_like_to_use_C.png
468 KB, 936x550
Where did everything go wrong?
>>
>>53688738
you mean curly braces after this I assume? >>53688657


heres case 3

its a bit of a mess
>>
>>53688852
Jesus fuck, indent your code. Eclipse does it for you: select it all and Ctrl+Shift+F. You'll like it much better.
>>
>>53688832
As soon as you got interested in programming.
>>
>>53688634
>scope the scanner privately (so declare it before you enter main) and then instanciate it before you do anything
embarrassingly enough, I don't think I can figure out how to do this
>>
>apply to company
>they want me to answer a few open ended questions about shit I've worked on
Do I just make my answers as long as I want? I want to give detail on what I did to show that I know what I'm doing, but I ended up writing a page of shit and I don't want them to say tl;dr and throw it in the trash.
>>
>>53688969
it would be epic and reddit-friendly if at the end you put
>tl'dr: I rock!
:^)
>>
I've been asked to build a system where the client has hundreds of files which they want to dole out to subscribers in a controlled manner.

For example, if subscriber A just made a new subscription, then A can access the first 3 files in some sorted heirarchy.

Meanwhile, subscriber B has been subscribed for three months, so the first three items are now inaccessible to B, however B can access items 4 - 6 (for month 2) and items 7 - 9 (for month 3)

How retarded does this sound? Does it sound easy? I haven't thought about it too hard and was thinking my client could upload the desired files to a server and place them in subdirs. Then I'd write a program which takes care of user registration and records who's been subcribed for how long and then grants access according to their duration of subscription and which content they've paid for.

Right.

So essentially I guess I could put all the files from all the directories into autoindex (this is just theory it'd be nicer looking than that) and write an http server which manages users and their permission to access directories.

I supposed if I was using nodejs with express for example I could just write a piece of middleware code which intercepts requests and checks the requesting user's permissions against their privileges.

???
>>
>>53687586
>>53684826
Same person with another cmake question. Is there any way to declare an executable in advance, then define its composition etc later? To allow targeting libraries for linking.

Keep writing my way into catch 22s. Can't have both and would rather not duplicate code unnecessarily.
>>
What cloud storage software does /dpt/ use?


Dropbox keeps eating my files and its pissing me off. (Save on desktop, then open on laptop, instead of downloading the new file it instead deletes the file on dropbox)

About to make my own NAS unless anyone has a better solution
>>
>>53689161
>cloud
personally I use a usb
>>
>>53689161
>le cloud
I just store my shit on my home server, for which I have SSH access.
>>
>>53689161

I've started using Onedrive because I get it free. Works really well for my needs.. but then I've never tried it outside Windows.
>>
>>53689170
Not too bad a solution either, but it is nice not having to plug it in. Of course this isn't sUp3R l33t hacker encrypted private bullshit, this is just general files i'm working on. I don't care about the cloud-botnet circlejerk.

>>53689185
Looks like compatibility with linux is sketchy...
>>
>>53689211
>not having to plug it in
normally I do it while I'm waiting for my computer to start
not like it takes that long
>>
>>53689118
>Is there any way to declare an executable in advance, then define its composition etc later?

I'm not following your question. What do you mean by "declare an executable in advance"?
>>
>>53689231

"while i'm waiting"... Wtf?

In the day of SSD and linux abound who has to wait anymore.
>>
>>53689250
Does your computer take less than 1 second to start?

you have enough time to plug a usb in

you memeing fuck
>>
>>53689297
he uses fucking linux, probably some "bloat-free" shit distro
>>
can anything serious be done using Blockly exclusively?
>>
>>53689317
>"bloat-free" = shit

It is arch, but who gives a shit this isn't the argument... WHAT DO YOU PEOPLE USE AS A CLOUD SERVICE?

Dropbox sucks, OneDrive is dodgy on linux, Google Drive is okay, but storage is a bit low.

Either A usb keychain or B turn a shitty laptop into a NAS it looks like.
>>
>>53689352
I use Dropbox and have never had the problem you describe.
>>
>>53689244
My mind is working poorly lately, so I'll just show what I mean.

if(USE_SYSTEM_ZLIB)
find_package(zlib)
if(ZLIB_FOUND)
include_directories(galib "${ZLIB_INCLUDE_DIRS}" zopfli/src/zopfli)
else()
unset(USE_SYSTEM_ZLIB)
endif()
endif()
if (NOT USE_SYSTEM_ZLIB)
set(ZLIB_SOURCE zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/deflate.c zlib/infback.c zlib/inffast.c zlib/inflate.c zlib/inftrees.c zlib/trees.c zlib/uncompr.c zlib/zutil.c)
include_directories(galib zlib zopfli/src/zopfli)
endif()

add_executable(pngwolf
pngwolf.cxx
galib/ga/GA1DArrayGenome.C
galib/ga/GAAllele.C
galib/ga/GABaseGA.C
galib/ga/gabincvt.C
galib/ga/GAGenome.C
galib/ga/GAIncGA.C
galib/ga/GAParameter.C
galib/ga/GAPopulation.C
galib/ga/garandom.C
galib/ga/gaerror.C
galib/ga/GAScaling.C
galib/ga/GASelector.C
galib/ga/GAStatistics.C
${ZLIB_SOURCE}
zopfli/src/zopfli/blocksplitter.c
zopfli/src/zopfli/cache.c
zopfli/src/zopfli/deflate.c
zopfli/src/zopfli/gzip_container.c
zopfli/src/zopfli/hash.c
zopfli/src/zopfli/katajainen.c
zopfli/src/zopfli/lz77.c
zopfli/src/zopfli/squeeze.c
zopfli/src/zopfli/tree.c
zopfli/src/zopfli/util.c
zopfli/src/zopfli/zlib_container.c
zopfli/src/zopfli/zopfli_lib.c)

if(USE_SYSTEM_ZLIB)
target_link_libraries(pngwolf "${ZLIB_LIBRARIES}")
endif()


Ideally the last block could be part of the first, but either it does not yet know what "pngwolf" means, or ZLIB_SOURCE is not properly set at the time it is parsed.
>>
>>53689352
i don't use any cloud service, fag
>>
>>53689352

>WHAT DO YOU PEOPLE USE AS A CLOUD SERVICE?

pomf

But I mostly use local storage.
>>
>>53689376
One option is to define ${ZLIB_LIBRARIES} in the first if statement. If it doesn't execute, the variable will be empty and no linking will occur.
>>
Any good 4chan clients for emacs?
>>
File: bird.png (31 KB, 581x556) Image search: [Google]
bird.png
31 KB, 581x556
How can I make my own robot?
Like I would like to make machines controlled by my computer. Even something as simply as controlling the voltage to a motor to speed it up or turn it off would be good building blocks, but how the fuck do I such a thing?

Is there some kind of adapter to allow such voltages to be sent or not from a computer?
>>
File: 123123123123.png (328 KB, 514x571) Image search: [Google]
123123123123.png
328 KB, 514x571
Tfw dying inside trying to make this shunting yard algorithm with C++.
>>
>>53689516
What you want is a Raspberry Pi.
>>
Good youtube series for beginner java?
>>
>>53689626
>Youtube series
No. Just no.
>>
>>53689626
Just buy a book
>>
>>53689635
this

>>53689626
https://docs.oracle.com/javase/tutorial/
>>
File: Capture.png (32 KB, 1242x219) Image search: [Google]
Capture.png
32 KB, 1242x219
can anyone shed some light on whats going on in this snippet?
>>
>>53689706
Memes. Lots and lots of memes.
>>
>>53689520
jeez i only did it very mildly and my tendon feels a bit fucked now
>>
>>53689723

I did it too hard and now my hand fell off.
>>
>>53689635
why?
>>
>>53689706
Builds two rooms, connects them with a door and returns it?
>>
>>53689706
A pointer to a function in a namespace is building rooms.
>>
>>53689706
https://en.wikipedia.org/wiki/Factory_method_pattern

>>53689733
it avoids having to make a gorillion different constructors with one for each type of maze
>>
>>53689746
I don't understand what you're saying.
>>
>>53689735
i meant in the declaration

>>53689736
so it's a pointer to the
MazeGame::CreateMaze
static function? i'm confused as to which one is the class -- Maze pr
MazeGame
>>
>>53689733
I have yet to find a good Youtube tutorial on anything
>>
>>53689755
>CreateMaze
creates a maze

>buildRoom
builds a room

>buildDoor
builds a door

>getMaze
gets the maze
>>
>>53689757
From what I can see mazebuilder is the class and mazegame::createmaze is a function that returns the assembled maze.
>>
>>53689788
the slide made a note that mazebuilder is an interface

is mazegame the namespace of createmaze, and would that mean that maze is teh class createmaze belongs to?
>>
Anybody else /program naked/ here? It just gets so hot.
>>
>>53688599
>>53689584
Arduino
>>
to anyone who cares:

I finally finished my dictionary!

I decided to give up on using cases and I figured it out with if statements

thanks for all the help though, couldnt have done it without you!
>>
>>53689807
Seems that way. Whatever those build functions are they are contained in mazebuilder though.
>>
>>53689834
cheers

C++ is definitely quite a bit harder to understand than Java and C. going to download the lynda tutorial on it now.
>>
>>53689810
t-shirt and undies is my work attire

the t-shirt might come off during the hottest parts of the summer
>>
>>53689810
>not writing driver code while wearing a skirt
>>
>>53689818
your code is disgusting
>>
>>53690172
it looks better now

look

package k;
import java.util.ArrayList;

import java.util.Scanner;


public class DictionaryTester1 {

public static int menu(){
Scanner sc = new Scanner(System.in);
System.out.println("To add a new word to the dictionary, enter '1'. To remove a word from the dictionary, enter '2', To change the definition of a word, enter '3'. To get the definition of a word, enter '4'. To display all the words of the dictionary and get a total count, enter '5'. To exit this menu, enter '6'.");
return sc.nextInt();

}


public static void main( String args[]){
Scanner sc = new Scanner(System.in);

ArrayList<WordDef1> dictionary = new ArrayList<WordDef1>();
WordDef1 w1 = new WordDef1("Amicable","Friendly");
dictionary.add(w1);
WordDef1 w2 = new WordDef1("Bemused","Puzzled");
dictionary.add(w2);
WordDef1 w3 = new WordDef1("Colloquial","Characteristic of informal language");
dictionary.add(w3);
WordDef1 w4 = new WordDef1("Deleterious","Harmful to living things");
dictionary.add(w4);
WordDef1 w5 = new WordDef1("Egregious","Reprehensible");
dictionary.add(w5);


int result = menu();
while (result != 6){
if (result == 1){
System.out.println("Enter the word you would like to add.");
String word = sc.next();
System.out.println("Enter the words definition.");
String definition = sc.next();
dictionary.add (new WordDef1(word,definition));
}
if (result == 2){
boolean a=false;
System.out.println("Enter the word you would like to remove");
String word = sc.next();
for(int i= dictionary.size()-1; i>=0; i--){
if(dictionary.get(i).getWord().equals(word)){
dictionary.remove(i);
a=true;
}
}

if(a== false){
System.out.println("There is no such word!");
}
}
>>
File: 1458262852119.gif (350 KB, 500x282) Image search: [Google]
1458262852119.gif
350 KB, 500x282
>>53690192
>>
>>53690192
if (result == 3){
boolean a=false;
System.out.println("Which word's definition would you like to change?");
String word= sc.next();
for(int i= dictionary.size()-1; i>=0; i--){
if (dictionary.get(i).getWord().equals(word)){
System.out.println("What is the new definition?");
a=true;
String newDef = sc.next();
dictionary.get(i).setDefinition(newDef);
}
}
if (a==false){
System.out.println("There is no such word!");
}
}
if(result == 4){
boolean a=false;
System.out.println("Which word's definition would you like to see?");
String word = sc.next();

for(int i = dictionary.size()-1; i>=0; i--){
if(dictionary.get(i).getWord().equals(word)){
System.out.println(word + "- " + dictionary.get(i).getDefinition());
a=true;

}
}

if(a==false){
System.out.println("There is no such word!");
}
}

if(result == 5){
System.out.println("There are" + dictionary.size() + " words in this dictionary at the moment.");
for(int i=dictionary.size()-1; i>=0; i--){
System.out.println(dictionary.get(i).getWord() + "- " + dictionary.get(i).getDefinition());
}
}
result = menu();

}
}

}
>>
>>53687586
Stop this programming fag meme.
>>
>>53690192
>>53690208
it's '''better''''
but its not good.
your indentation is ass, which is weird, because every fucking program does it automaticlaly now

the only reason i can think of is ur fucking using notepad or microsoft word
>>
File: ZoCd1km.gif (650 KB, 647x363) Image search: [Google]
ZoCd1km.gif
650 KB, 647x363
>>53690206
its not that bad!
>>
>>53690238
I do ctrl A ctrl I in eclipse and it looks fine

maybe just when I paste it here it looks weird

is there any other way i can make it look better? or simpler even
>>
File: tay-racist-tweet-2.jpg (21 KB, 624x277) Image search: [Google]
tay-racist-tweet-2.jpg
21 KB, 624x277
kek did you guys see tay, microsoft's ML chat bot
>>
>>53690271
>He didn't participate in the "/pol/ educates Tay" threads
>>
>>53690260
just pastebin it please
>>
>>53690291
sorry, here
http://pastebin.com/j96Y44nE
>>
>>53689763
https://www.youtube.com/watch?v=2Op3QLzMgSY&list=PL8FE88AA54363BC46

You can go fuck yourself now.
>>
File: tay-hitler_o4kq62.jpg (29 KB, 365x609) Image search: [Google]
tay-hitler_o4kq62.jpg
29 KB, 365x609
>>53690288
i missed it, sadly
>>
Why is everyone on /g/ on edge all the time?
>>
>>53690348
The Jews anon, they're always out to get you
>>
>>53690348
I used to smoke a lot of weed when I was younger and it drastically altered my brain chemistry.
>>
>>53690348
Kernel and firmware programming makes you go crazy after awhile.
>>
>>53690348
coffee abstinence
>>
>>53690298
http://pastebin.com/jnE9H81x
slightly better
your shit was so inconsistent it made me sick
also switch WOULD be better
but you couldnt figure it out and im not gonna actually rwite your code for u
>>
>>53690374
>implying any of /g/ does any actual programming, let alone kernel programming
>>
>>53690396
Of course we do, check out the kernel I'm working on right now
https://www.kernel.org
>>
>>53690396
What is actual programming?
>>
>>53690391
>http://pastebin.com/jnE9H81x
Jesus, that code is horrible. Go back to programming 101.
>>
>>53690391
thanks.

what was inconsistent about it?
>>
>>53690415
fizzbuzz, averaging 2 ints, a safe way to getchar()
>>
>>53690415
Like the other dude said, things like kernel and firmware programming are the only real programming.

Web/gaming things are for little kids.
>>
>>53690436
>It's not real programming because I say so
Okay.
>>
>>53690429
sometimes you die x=y and sometimes x = y and sometimes x==y and sometimes x == y sometimes if ( and other times if(
also if a line is too long (like your menu) cut it up IN SOME WAY so it is legible

your actual code is garbage too but like IT JUST WERKS
>no fucking comments
good job
>>
>>53690452
>>53690452
oh I see what you mean ok thanks

HEY btw, I went back and redid by Case program and everything works EXCEPT that it keeps going, if you know what I mean

like ill input 2, and it will remove the word, but then go right to 3 (changing a definition)

how can I fix this?
heres the code btw
http://pastebin.com/pcndTYcZ
>>
writing a tic-tac-toe bot in Haskell
>>
Taking an introductory course in php at uni. I have to write a program that you pick food and a quantity from a drop down and total the costs. The Food and cost of each item is in an array but is it just me or does php become a convoluted mess after a short while?
>>
>>53690452
>>53690555
nvm I figured it out

I just have to break; at the end, after all the curly braces
>>
>>53690587
>php
why?
>>
>>53690605
yes! you have to break out if youre done lol
your shit looks all fucked up again now and im not going to fix it for you
try to make it look nicer yourself
i really think youre just trolling me
beECAUSE YOU DID THE EXACT SAME THING
>>
File: php masterrace.png (2 MB, 1598x1585) Image search: [Google]
php masterrace.png
2 MB, 1598x1585
>>53690611
>>
>>53690637
>i really think youre just trolling me
lol sorry, what happened was you posted me a better version of my other code, using the if statements, and this case code is code I had before in a different class

Im going through and fixing it now, lol

thanks for all the help, appreciate it!
>>
>>53690571
let us know if you succeed
>>
File: You kids wanna try D.jpg (44 KB, 512x512) Image search: [Google]
You kids wanna try D.jpg
44 KB, 512x512
>>
>>53690652
ok good
and comment your code!!
some parts were ???-tier
>>
>>
>>53690820
will do
>>
>>53690611
Required for the IT minor I'm going for. Not exactly a fun course I chose willingly.
>>
File: 1458971503276.jpg (66 KB, 540x476) Image search: [Google]
1458971503276.jpg
66 KB, 540x476
>>53690856
This looks like fun. Let's do this.
>>
File: dt951113dhc0.gif (68 KB, 1200x364) Image search: [Google]
dt951113dhc0.gif
68 KB, 1200x364
>>
File: dt_c110511.gif (177 KB, 1200x374) Image search: [Google]
dt_c110511.gif
177 KB, 1200x374
>>
File: rMd3sf8.jpg (944 KB, 4032x3024) Image search: [Google]
rMd3sf8.jpg
944 KB, 4032x3024
http://stackoverflow.com/questions/35632959/remove-exception-unwind-functions-from-android-ndk-shared-objects/36210959#36210959

someone gave an answer

he wrote it on a napkin, lolwut?!

so is there a way to get around it with android NDK?
>>
File: when the D hits you.jpg (23 KB, 512x512) Image search: [Google]
when the D hits you.jpg
23 KB, 512x512
>>53690791
YES
>>
>>53690905
based on a true story
>>
File: 1458971698487.jpg (88 KB, 540x476) Image search: [Google]
1458971698487.jpg
88 KB, 540x476
>>53690890
>>
>>53690955
dubs of truth
>>
File: 1458971503276.jpg (74 KB, 540x476) Image search: [Google]
1458971503276.jpg
74 KB, 540x476
>>53690890
>>
File: dt951114dhc0.gif (74 KB, 1200x364) Image search: [Google]
dt951114dhc0.gif
74 KB, 1200x364
>>53690905
>>53690941
>>
>>53691003
the origin of firefox
>>
File: temp.jpg (155 KB, 810x714) Image search: [Google]
temp.jpg
155 KB, 810x714
>>53690890
>>
File: dt951117dhc0.gif (77 KB, 1200x364) Image search: [Google]
dt951117dhc0.gif
77 KB, 1200x364
management, Dilbert gets it...
Adams is a fcking genius, cuz true stuff is the funniest stuff. y'all should read his autobiography.
>>
>>53691003
kek
>>
http://blog.dilbert.com/post/141490448161/the-belgium-analogy

wait what the shit
>>
>>53691086
The man's very right-wing
>>
>>53691086
Has he not heard of reducto ad Hitlerum? Literally everyone and everything has been compared to Hitler at this point and all it does is make Jews cry.
>>
>>53691119
B A S E D

>>53691127
>reducto ad Hitlerum
fucking lmao
What was wrong with 'godwin's law'?
>>
>>53691119
>Taking a stance against liberals comparing anybody and everybody to a man that killed millions of people and tried to subjugate a continent is right wing
The exact same logic he is describing can be applied to right wingers comparing Sanders to Stalin. Since the dawn of man politicians and their supporters have compared their opposition to the absolute most extreme path their ideology can lead, obviously ignoring that Hitler was a socialist.
>>
>>53691146
Godwin's Law only applies to online forums over the course of a period of time. ad Hitlerum is just, comparing people to Hitler and Nazis frivolously.
>>
let's be real, trump would be a better president than hillary
>>
>>53691271
Too bad she is going to win because America is a progressivist dictatorship now.
>>
>sqlite3 spells "foreign key" as "foriegn key"
What the fucking fuck is this stupid shit? are the devs 12 years old?
>>
>>53691442
typical web/crudfags
>>
>>53687586
Got any good free resources on C++ programming?
>>
>>53691904
http://en.cppreference.com/w/
>>
Pls rate my shitty python script

Just change "num" to something and run the script again

val0 = [1, 0, 1, 1, 0, 1, 1, 1, 1, 1]
val1 = [1, 0, 0, 0, 1, 1, 1, 0, 1, 1]
val2 = [1, 1, 1, 1, 1, 0, 0, 1, 1, 1]
val3 = [0, 0, 1, 1, 1, 1, 1, 0, 1, 1]
val4 = [1, 0, 1, 0, 0, 0, 1, 0, 1, 0]
val5 = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1]
val6 = [1, 0, 1, 1, 0, 1, 1, 0, 1, 1]

num = "1234567890"

result = ""

for i in num:
a = int(i)
if val0[a] == 1:
result += " -- "
else:
result += " "
result += " "

print result
result = ""

for i in num:
a = int(i)
if val1[a] == 1:
result += "| "
else:
result += " "
if val2[a] == 1:
result += "|"
else:
result += " "
result += " "

print result
result = ""

for i in num:
a = int(i)
if val3[a] == 1:
result += " -- "
else:
result += " "
result += " "

print result
result = ""

for i in num:
a = int(i)
if val4[a] == 1:
result += "| "
else:
result += " "
if val5[a] == 1:
result += "|"
else:
result += " "
result += " "

print result
result = ""

for i in num:
a = int(i)
if val6[a] == 1:
result += " -- "
else:
result += " "
result += " "

print result

>>
>>53691956
python/10
which means its SHIT
>>
>>53692058
this
>>
File: high res tired pepe.png (137 KB, 904x864) Image search: [Google]
high res tired pepe.png
137 KB, 904x864
How do you guys do marathon coding sessions?

Seems like I can only work in sputters of 20-30 minutes and then it's back to browsing 4chan for an hour or playing vidya like an uninspired pleb.
>>
File: eppu.png (146 KB, 480x506) Image search: [Google]
eppu.png
146 KB, 480x506
>>53692313
I masturbate and then go back to coding.
>>
>>53692313

For personal projects, I tend to be motivated by the joy of programming. So I can work on something for hours just because I like it.

For school projects, I tend to be motivated by a survival instinct. If I do not get this assignment done, I will fail the class. If I fail the class, I may have to repeat it, or I may get put on academic probation, or I may even get kicked out. If I get kicked out, my career prospects will be dropped because I really only have a bachelor's degree, and no one wants to hire someone who dropped out of grad school. I may end up not getting a job, my student loans will come, I will have no money to pay for them, and I will starve. Granted, I would probably find a way to adapt in this situation, but I would rather not have to think about that.

A couple of months ago, I was working on a class assignment, and spent all day working, forgetting to eat dinner. I went to sleep at around 3 in the morning, and woke up 3 hours later, vomiting all over the floor, despite not having eaten since breakfast. As it turns out, despite the effectiveness of this mentality, it may not be the healthiest. One should never skip a meal for work.
>>
>>53690251
Yes it is that bad.
>>
>>53692313
once i get going i usually just get in the flow for a few hours

but it can take quite some time for me to get started and i procrastinate a lot, like "just one more youtube video" or get distracted with ""playtesting"" the game i'm working on
>>
>>53687586
>having teamwork assignment
>6 ppl total
>no one answers his emails and probably working on the project alone
>be paranoid 2 or 3 ppl already did it and will take credit for it and accuse everyone else of not participating
>I have already done the whole project (since its easy, just a tetrsi game in Java with simple gui)
>>
>>53692339
best practice ever, even when I started work I code for a while then go to the wc and jack off and go back to coding
>>
Would it not be better for the lingua franca of programming to be some language with a larger alphabet than English, to provide a larger pool of value names to choose from?
>>
>>53693105
>6 ppl to do a tetris game
how do they expect you to make it this way
this is stupid
>>
>>53693169
nothing is stopping you from using UTF-8 characters in most modern languages.
>>
>>53693201
My manager stops me >_>

He'd make me go back to using Java if he could.
>>
>>53693169
ばか = "お前"
>>
>>53693265
Exactly! Shorter, so it's easier to read, and less likely to go past the edge of the screen. Much quicker to type, too.
>>
>>53688091
QtCreator

>>53689161
github for code, pomf for screenshots, and megasync for warez.
>>
>>53693291
using non-latin languages is one thing, but that still doesn't add a "larger pool of value names" because you're still typing everything as a word.

in the case of complex mathematical formulas, nothing is stopping you from expressing them using their proper mathematical symbols, the only problem is that you'd have to pull out your symbol picker every time you want to make a change.,
>>
Trying to learn Qt as a GUI framework.

Holy shit their memory management is horrible. It's very hard to allocate objects inside other objects (or stack allocate in general). Implicit delete calls everywhere, unable to override the memory management to not use new/delete, etc.

Plus I found a memory leak in the library very quickly. Calling QMainWindow::menuBar() without setting a custom menubar constructs a brand new default constructed QMenuBar. This default constructed menubar is never destroyed, even when it's parent QMainWindow is.
>>
>>53693425
wrap it
>>
>>53693291
>shorter
>easier to read

Y dn't ndrstnd hw rdng wrks.
>>
>>53693467
Except words in Japanese or Chinese use fewer characters per word. Deleting vowels in English is not comparable at all.
>>
>>53693492
they also have a lot more characters
>>
>>53693510
That's exactly the point.

It might seem like that makes it harder to read from a native english speakers perspective but it really doesn't
>>
>>53693492
People read by recognizing patterns, not by parsing individual letters.
>>
>>53693558
Your not just doing random sequences of characters in either language. You are just using 2 or 3 (out of a larger set) rather than 6 or 7 (out of a smaller set) to form your patterns.
Your patterns are just denser if you use a larger character set.
>>
class Item {
constructor(options={}) {
this.seller = ko.observable(options.seller).extend({ notify: 'always' });

this.seller.subscribe(x => alert('foo ' + x));
}
}

class Model {
constructor() {
this.items = ko.observableArray([]);

this.add = function() {
var item = new Item();

item.seller.subscribe(x => alert('bar ' + x);

this.items.push(item);
}
}
}

ko.applyBindings(new Model());


Struggling with a knockout.js problem. Can anyone tell me why this alerts foo but not bar? It doesn't make sense to me that it's ignoring the subscription, even if I remove the one that alerts foo.
>>
>>53693608
Forcing native English speakers to program in Chinese will make them less productive.
>>
>>53693665
I'm not saying that, I'm saying there is benifits to leting Chinese programers program in Chinese.
>>
>>53693674
if your codebase isn't in english, I want absolutely nothing to do with your sloppy chink code
>>
>>53693652
Knockout works with ECMA6 classes?
>>
I don't have a fucking clue what I'm doing.

MainWindow::MainWindow() {
// Default menuBar() leaks memory
auto menuBar = new QMenuBar;
auto fileMenu = menuBar->addMenu("&File");
auto quitButton = fileMenu->addAction("&Quit");
QObject::connect(quitButton, SIGNAL(triggered(bool)),
this, SLOT(close()));

setMenuBar(menuBar);

auto textEdit = new QTextEdit("Foo");
textEdit->setReadOnly(true);
setCentralWidget(textEdit);

statusBar()->showMessage("Success");
}


Why the fuck do I need Q_OBJECT in my class header. Why is connect a static function on QObject, why can't I go this->connect(quitButton, SIGNAL(triggered(bool)), SLOT(close())); why do I need SIGNAL/SLOT macros anyway. What the fuck is going on?
>>
>>53693721
ES6 classes are just syntactic sugar over top of the normal way to do objects in JavaScript. For example his Item class is equivalent to
function Item(options={}) {
this.seller = ko.observable(options.seller).extend({ notify: 'always' });

this.seller.subscribe(x => alert('foo ' + x));
}
>>
>>53693652
>item.seller.subscribe(x => alert('bar ' + x);

You're missing a ) there.
>>
>>53693687
>sloppy chink code
lmao
>>
>>53693756
>Why the fuck do I need Q_OBJECT in my class header.
So that the moc compiler can take it as a Qt object when generating the C++ code for your program.

>why can't I go this->connect(quitButton, SIGNAL(triggered(bool)), SLOT(close()));
Because you're not connecting to the MainWindow directly, merely to the button that's part of the window.
>>
>>53693756
>Why the fuck do I need Q_OBJECT in my class header
Because Qt uses: http://doc.qt.io/qt-5/moc.html. As of Qt 5 you can use C++11 lambdas as a slot instead.
>>
>>53693756
It's not that bad once you get used to it.. It's just different, but at the end of the day Qt is still pretty good
>>
I feel dumb for not being able to think up neat algorithms by myself. Should I give up on programming?
>>
>>53693927
Depends, what algorithms?
>>
>>53693867
That's just from copy-pasting to make it concise enough to post. The original source has the correct number of parentheses.
>>
>>53693927
What kinda algorithms?
>>
>>53693948
>>53693939
I'm working with the Newton-Raphson Iteration Technique right now. I understand it but I could never have thought it up by myself.
>>
>>53693896
>>53693911
If I take Q_OBJECT out it still works. I think I'll leave it out until something doesn't work without it.

Turns out there is a target->connect(sender, senderSignal, targetSlot); that is exactly what I want. I'm either blind or retarded or both. Can't do it the other way (sender->connect(senderSignalSignal, target, targetSlot) but that wouldn't make as much sense anyway. The sender shouldn't be caring about the targets.

As always, the GUI designer is a clusterfuck, what's new. I think I'll stick to defining everything in code.
>>
Reading up on combinatorics
>>
>>53693975
>If I take Q_OBJECT out it still works. I think I'll leave it out until something doesn't work without it.
It'll turn to shit once you run QMake again. Read this: https://woboq.com/blog/new-signals-slots-syntax-in-qt5.html. The new syntax allows for compile time validation for the connect method.
>>
File: out.png (95 KB, 1920x1080) Image search: [Google]
out.png
95 KB, 1920x1080
I'm working on an audio transcoding library, basically a wrapper interface around various audio encoding/decoding libraries. I've got FLAC decoding working and now I'm working on Opus encoding.

Basically, I take the decoded FLAC frame, convert all the samples to floats, pass them through libsoxr to resample, encode them into Opus packets using libopus, and then write the packets using liboggz.

I've finally got it to the point of creating a valid file that's audible, but the audio produced is strobed and slowed down. Pic related shows what the waveform looks like. The code is too unwieldy to be worth posting, but could anyone help me guess what's going on?
>>
>>53693969
At the level where you learnt about Newton-Raphson you're not really supposed to be able to formulate your own not completely shit algorithms unless given a stupid amount of time
>>
>>53694090
I guess that's somewhat consoling. I just hope algorithms are a skill that isn't completely off limits to people (like myself) who don't have the greatest mathematical intuition.
>>
>>53694140
It's not, just keep making sure you are understanding the algorithms you learn for now. That said actually coming up with new and more effective algorithms than what's currently available will never be easy, that's what people do in research after all.
>>
>>53694001
Nah, it still works fine because my class does not declare any additional slots/signals.

Confused that this works:
    this->connect(quitButton, &QAction::triggered, [this]{close();});

But this doesn't:
    this->connect(quitButton, &QAction::triggered, &QMainWindow::close);

unless I use the QObject::connect version with parameters.
>>
>>53694175
latter takes a this parameter in the call, former has the this parameter bound in a closure
>>
>>53694175
>
[this]{close();}

takes no argument
>
&QMainWindow::close

takes a QMainWindow* as an argument.
How is that confusing?
Look at the error message.
>>
>>53694207
Yes but it can get the this pointer from, well, the this pointer in the connect() function.

I guess that would need some dynamic casting though. Guessing that's why it's not supported (innocuous looking code an few orders of magnitude slower than the alternatives).
>>
>>53694228
the former lambda takes no arguments
[this]{close();}();
the latter takes one argument, this
(&QMainWindow::close)(this);

try this (from functional)

this->connect(..., std::bind(&QMainWindow::close, this))
>>
>>53694223
At first I thought that the argument it needs is given to the function in the this pointer.

QObject::connect(quitButton, &QAction::triggered, this, &QMainWindow::close);

Has all the same parameters in a different order and works just fine. But then I realised that the value of "this" can change when multiple inheritance gets involved. So yeah, makes sense why it (doesn't) work now.
>>
>>53694246
that sounds like it's just an overload for member functions

it would still have to explicitly call
QMainWindow::close(this, ...)
or this.*QMainWindow::close
>>
>>53694287
Yeah it probably does a std::bind internally. I was just confused as to why it couldn't do that for this->connect but could for Static::connect(this). But yeah, "(void*)(base*)this != (void*)this" bites my logic in the ass again.
>>
>>53694315
no, it probably just has an overload that calls it directly but my point is that you can't just replace a lambda that takes no arguments with a function that takes one argument

a [this] lambda has the this parameter in a closure, it doesn't get called with the this parameter
>>
>>53694315
Right, QMainWindow doesn't want to bother with the types of its child classes. Even if the cast
(Derived*)this
were the identity because there's no multiple inheritance, you still have to know Derived.
Note that a member function pointer doesn't store a this pointer, it can also be created in a place where there's no this:
struct Class {
int mem_fn() {};
};

int main() {
cout << &Class::mem_fn << "\n";
return 0;
}

It's just a pointer.
>>
>>53694385
Member function pointer are not "just a pointer". In the case of virtual functions they are a vtable offset, if you jumped to that and started executing you'd hit the null page and segfault.
>>
>>53694440
i'll point you in a minute
>>
>>53689516
http://www.maerivoet.org/website/software/arduino/manuals/electronics/robot-builders-bonanza.pdf
>>
is there a clean way in C# to check which condition broke first in a multiconditional statement, i.e
if(a != 1 || b != 1)
>>
>>53694739
are you doing the same logical combination like && or ||?
>>
>>53694739
Sounds like you need

if (a != 1)
{
// your shit code here
}
else if (b != 1)
{
// more of your shit code here
}
>>
>>53694739

if (a != 1 || b != 1){
if (a != 1){
console.write("a doesn't equal 1);
} else {
console.write("b doesn't equal 1");
}
}
>>
>>53694911

"
>>
File: images.png (3 KB, 310x163) Image search: [Google]
images.png
3 KB, 310x163
Can /prog/ recommend a good book on SQL which includes relational database theory? I can do basic CRUD operations and joins but I just started working with databases and want to go balls deep.
>>
>>53691956
lines = '''\
-- -- -- -- -- -- -- --
| | | | | | | | | | | | | |
-- -- -- -- -- -- --
| | | | | | | | | | | | |
-- -- -- -- -- -- --
'''.split('\n')
numbers = [[a[i:i + 6] for a in lines] for i in range(0, len(lines[0]), 6)]

def print_numbers(text):
print '\n'.join(''.join(numbers[int(c)][i] for c in text) for i in range(len(numbers[0])))

print_numbers('123456789')
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.