[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: 44
File: sicppat.jpg (286 KB, 1024x768) Image search: [Google]
sicppat.jpg
286 KB, 1024x768
Daily Programming Thread

What are you working on, anonymous ?

# New & Revised /dpt/ Code of Conduct #
We want to ensure that the /dpt/ community, while large and diverse, remains
welcoming and respectful to all participants. To that end, we have a few
ground rules that we ask people to adhere to.

- *Be friendly and patient.*

- *Be welcoming.* We strive to be a community that welcomes and supports
people of all backgrounds and identities. This includes, but is not limited
to members of any race, ethnicity, culture, national origin, colour,
immigration status, social and economic class, educational level, sex,
sexual orientation, gender identity and expression, age, size, family
status, political belief, religion, and mental and physical ability.

- *Be respectful.* Not all of us will agree all the time, but disagreement
is no excuse for poor behavior and poor manners. We might all experience
some frustration now and then, but we cannot allow that frustration to turn
into a personal attack. It’s important to remember that a community where
people feel uncomfortable or threatened is not a productive one. Members of
the /dpt/ community should be respectful when dealing with other members as
well as with people outside the /dpt/ community.

- *When we disagree, try to understand why.* Disagreements, both social and
technical, happen all the time and /dpt/ is no exception. It is important
that we resolve disagreements and differing views constructively. Remember
that we’re different. The strength of /dpt/ comes from its varied community,
people from a wide range of backgrounds. Different people have different
perspectives on issues. Being unable to understand why someone holds a
viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to
err and blaming each other doesn’t get us anywhere. Instead, focus on
helping to resolve issues and learning from mistakes.
>>
File: markov chin.jpg (5 KB, 97x80) Image search: [Google]
markov chin.jpg
5 KB, 97x80
Programming convolutional recurrent deep Markov chins.
>>
im cracking all your passwrods with my ibm 5 qubits quantum computer
>>
File: 1412703125145.png (116 KB, 1515x663) Image search: [Google]
1412703125145.png
116 KB, 1515x663
>>54424445
>>
anyone on /g/ working on a cool project?
>>
this might be a /diy/ question

anyone know how to interface electronics with a phone line? How do I know if said phone line has service? I'm looking for resources on the subject.
>>
File: czechem.jpg (103 KB, 1105x1055) Image search: [Google]
czechem.jpg
103 KB, 1105x1055
>>54424444
>>
File: file.png (136 KB, 588x447) Image search: [Google]
file.png
136 KB, 588x447
Has anyone worked with implementing inverted indexes? What would be the best way to store/retrieve the data structure on secondary storage?
>>
I'm finally motivated enough to start working on my own project.
I want to create a generic front end for torrent clients so I can manage my torrents and downloads anywhere. It'll be a website so I don't have to create a client for Android and desktop. Don't worry, it's just plain HTML/CSS. It won't be a shitty web app. This is the featureset for version 0.1:
- List downloads (name, status (incomplete/complete))
- Stream download
- Remove download
- List torrents (name)
- Add torrent
- Remove torrent
Some other features I'll eventually implement:
- Feeds
- Grouping of downloads
I'll be using Go because it's the perfect language for projects like this. To guarantee the users freedom, I'll license it under the AGPL v3.
Have a qt song: https://www.youtube.com/watch?v=wPCOPC9P8fY
>>
>>54424457
if "reason" in comment:
print "That's not an argument"
>>
I want to write a Windows application. It should use some system calls and sockets, no GUI.
I don't want to install 5+ gb of visual C++/Studio, and I want that application can run anywhere without dependecies.
Which compiler should I use?
Does MingW links with own DLLs?
>>
>>54424647
>I want to write a Windows application
>It should use some system calls
Got bad news for ya m8
>>
>>54424675
Are you telling me that their design sucks? I know that.
>>
>>54424647
>I don't want to install 5+ gb of visual C++/Studio
Welcome to 2016, where microsoft actually does some sensible things from time to time
http://go.microsoft.com/fwlink/?LinkId=691126
>>
>>54424686
Last I heard Windows syscalls are undocumented, and you're pretty much forced to use winapi.
>>
>>54424693
Thank you! But it requires .NET, I hate MS.
>>54424695
I didn't know that, I thought that WinAPI were the actual system calls.

Is this legit?
http://j00ru.vexillium.org/ntapi/
>>
>>54424400
>- *Be friendly and patient.*
fuck off, this OP is always such fucking shit.
>>
>>54424739
>I hate MS.
Ah, you're in that rebellious phase, it's alright we all grow out of it.
>>
File: biki.webm (2 MB, 852x480) Image search: [Google]
biki.webm
2 MB, 852x480
Ask your much beloved programming literate anything (IAMA).

>>54424686
System calls on Windows are abstracted by a set of procedures. Because of this, Microsoft can rearrange the system calls implementation for free. It's actually a good decision.
>>
>>54424770
i don't remember her having huge breasts in the manga
>>
>>54424770
Why is this season so shit?
>>
>>54424739
>Is this legit?
>http://j00ru.vexillium.org/ntapi/
No idea, you could test out yourself.
I wouldn't really rely on it until MS releases their own official documentation on syscalls.
>>
>>54424739
>>54424825
Also, if you click "show" on those columns, you can see that each windows version and service pack have varying syscall numbers for each syscall.
I would not rely on it, especially since it's unportable as fuck.
I'd stick with winapi.
>>
>>54424693
>http://go.microsoft.com/fwlink/?LinkId=691126
Nearly shit myself when it downloaded automatically.
>>
>>54424988
Sorry, I just copied the link from the press-release without checking it myself. I thought that it leads to the page with the 'download' button.
Here's the blog post, anyways:
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/
>>
>>54424693
That's still 3+GB of garbage.
>>
>>54424444
nice quads
>>
File: 1462000088144.jpg (276 KB, 1000x1000) Image search: [Google]
1462000088144.jpg
276 KB, 1000x1000
Anyone know java?

I'm working with sockets and have a server set up and a client that can talk to it.

The server runs, then the client connects to it. The client is player 1 and makes a move. This move is sent to the server, and the server is able to see where the client (p1) has moved. Client (p2) is now able to make their move. Player 2 makes a move, and this move is sent back with an echo.

So in short, player 1 makes a move, and this data is sent to the server. Server is now able to make their move, and when they do, the data is sent through the reply, or "echo".

My problem is occurring when player 1 receives the reply from the server.

I have a boolean variable called myTurn that only allows you to move if it is true. After you make your turn, it is forced to false and you must wait for it to be changed to true in order to make another move.

while(i.myTurn == true)
{
i.clickSet();
i.setTurn();
set(i.getBoard());
}

if(i.myTurn == false)
{
out.println(get());
boardStr = in.readLine();
set(i.getBoard());
i.boardToInt(boardStr);
System.out.println(boardStr);
}

else
{

}


You see that if it's player 1's turn (myTurn is true), it's ready to take their input, changes their turn status after they make their turn, and it updates the board. Now you see if it's not their turn (myTurn is false), you can assume that they've made their turn, so the updated board is sent to p2. Now this is where I get confused. I need something that will wait until it gets a reply back from the server to continue executing the next lines of code.

In my current program, p1 can make a move, p2 receives the data, and the board is updated to reflect this change. p2 is then free to make a move, but after they do, p1 receives the data, but cannot refresh the screen or have their turn.
>>
File: YAH.png (65 KB, 183x588) Image search: [Google]
YAH.png
65 KB, 183x588
>>54425307
A little more detail:

When dealing with sockets, the messages sent between them are of type String.

So the board is represented by integers, but is converted to a String that is then sent over to the next player after they make their turn. When the player receives the String, it goes through the method boardToInt and accepts the String and then updates their board to show what the other player did.

so it's a back and forth thing between server and client, but I need a method or something that can wait for the response of the server after it makes it's turn.
>>
>>54425307
sorry if im not understanding but couldn't you just make a while statement that sits the client in a loop until the variable you want from the server is available. Like maybe just have it wait on a boolean change, Im p sure there's a wait method in java too.

also remove your boolean comparisons and just starting using if (x) or if (!x)
>>
File: solution.png (14 KB, 851x330) Image search: [Google]
solution.png
14 KB, 851x330
>>54425371
>string based messaging system
>>
>>54425307
Please fix your code first before asking help.
>>
>>54425432
Hey, that aint my problem. Copy pasting code into a post fucks everything up. It looks just fine in eclipse.
>>
I don't see myself as a 'programmer', always hated that words as I do not program anybody or anyone, - I augment the inspiration and imagination of the users of my app - this is my craft, this is what I do. I usually call myself more a "code artisan" - I know it sounds cheesy, a cliche almost, but that describes it best. I mostly work in Rails as it is simply and by far the most robust implementation of a full stack MVP experience.

To the beginners out there: you don't have to be a 10xer to start with coding - you don't even need an office. I am typing this from Starbucks (yeah I know, call me a "fag" etc I don't care) on my Macbook and this IS my office. I am totally free, financially independent, living a minimalist style, moving around the world.
>>
>>54425445
i dont think that's what he meant

your code is really bad like not in grammar but in syntax

why don't you do something object based
>>
>>54425468
>Macbook

opinion discarded.
>>
>>54425468
lol
>>
File: 1461850718176.gif (4 MB, 356x200) Image search: [Google]
1461850718176.gif
4 MB, 356x200
>>54425468
I know how you feel, I've been a code autisan for 15 years
>>
File: visual.jpg (208 KB, 1300x1712) Image search: [Google]
visual.jpg
208 KB, 1300x1712
>>54425371
Here's a visual for anyone who doesn't understand.

I don't give a shit about the style that it's being done in, it's something I've worked on for a few hours and just want functionality right now.
>>
Guys, I need some help. I'm up shit creek.
For my C++ class, our final is to program a store kiosk, the ones you see at like target and stuff.
I've been running into multiples problems, and only have gotten to the whole menu option (select 1 to scan items).
I'm really out of options, the project is due in three days, and I need help. I hate asking, but can any of you anons help me out here? What I really need help with is how to make functions so that I can run a search array for item verification, and have that inside a case. How would I go about doing that?
>>
>>54425492
Hacking is just playful cleverness anon.
To become a code artisan, you need imagination.
When people come to me and ask me what to read, do you think I send them to some boring CS book?
No, I tell them: read this Autobiography written by Picasso. Go to a modern art exhibition. Learn yoga or tai chi.
Expand your mind first... the technical stuff comes later, and is quite trivial. Everyone can do a for loop, but can everyone reinvent? To become a visionary like Steve Jobs or Elon Musk you need more than technical knowledge. And code is ALL about vision.
>>
How do I into D-Bus?
>>
>>54425561
do they serve euphoria at starbucks, or is it all your own?
>>
>>54425561
Please. I got my third level black hat in tai chi by the age of 8.
>>
>>54425593
You can't buy euphpria, young Padawan.
Look within...
Reinvent. Envision. Imagine. Embrace.
>>
>>54424171
literally why the match
>>
>>54425307
Put the other lines of code in a function, and call that function from the ws.onmessage function
>>
>>54425693
there was an anon here the other day trying to defend this:

if (bool1) then {
bool2 = false
}
else {
bool2 = true;
}


he called this code golf:
bool2 = !bool1
>>
Anybody have a good programming spotify playlist?
>>
>>54425740
>using spotify
I listen to a lot of k pop recently. It's really comfy senpai.
>>
>>54425794
>>using spotify
please do enlighten me and explain your meme arrow. Botnets? Proprietary? What meme alternative can I manually compile on my Gentoo install?
>>
>>54425142
oh shit, had to dust off my windows vm to check and you're right. Still, it's better than visual studio + c# + c++ (yeah for some reason you can't not install c# with all its shit even if you only need VS for c++ development) which comes out to 8+ GB as far as I remember, so that's progress.
>>
>>54425864
>What meme alternative can I manually compile on my Gentoo install?
a torrent client of your choosing + mpd + ncmmpdcpsd or however you spell that cryptic shit
>>
>>54425864
rtorrent + mpd + ncmpcpp
>>
File: IMG_20160503_102030_613.jpg (2 MB, 3120x4160) Image search: [Google]
IMG_20160503_102030_613.jpg
2 MB, 3120x4160
r8 my hailstone sequence
>>
o shit waddup
>>
>>54425922
Have you confessed yet?
>>
>>54425922
here come dat shitposter
>>
So i'm at the point where I'm okay with using Python and Java and if i dont know how to do something I can quite easily find the answer on google. I never made a project with more than 100 lines though. Now i want to get serious and make something big. The problem is I don't know what and if Java and Python are actually good for bigger projects. I would be fine with learning a new language as I'm a pretty quick learner. Any concers/help?
>>
>>54426069
Java isn't really used anymore. It's only there for legacy purposes and Android. Python is fine though.
>>
>>54426069
Step one is find something you want to do.

Step two is do it.

Realistically you can do everything you're most likely coming up with right now with any of these two languages. Just pick the one you like more right now and do something with it.
>>
A question for the functional-oriented programmers:

For f: a -> a -> a, n: a and a list of a, knowing that f is an associative function, that f is not commutative and that n is the identity element of f, is it always possible to rewrite a left fold of the list through f with n as a right fold of the list through f with some n'?
>>
>>54426069
Don't listen to this guy >>54426108
All serious projects are written in vbs. You shouldn't listen to anyone suggesting meme languages.
>>
>>54426149
>and that n is the identity element of f
and that n is NOT the identity*
>>
>>54426149
https://youtu.be/Ccoj5lhLmSQ
>>
>>54426149
f - (associative) closed binary function
n - identity
so you've got a monoid (a, +, n)
you can fold over a list with a monoid

not sure what you mean by the last bit
do you mean is it possible to do both a left and right fold? yes
do you mean can you perform a left fold through a right fold?
normally i'd say probably but people keep saying there are differences
>>
>>54424171
Better:
fn is_letter(l: char) -> bool {
match l {
'a'...'z' | 'A'...'Z' => true,
_ => false,
}
}


fn main() {
let l = 'z';
let one = '1';
println!("{} is letter: {}", l, is_letter(l));
println!("{} is letter: {}", one, is_letter(one));
}


Even shorter:
fn main() {
let l = 'z';
let one = '1';
println!("{} is letter: {}", l, l.is_alphabetic());
println!("{} is letter: {}", one, one.is_alphabetic());
}
>>
What is the fewest lines of code needed to completely brick a computer?
>>
>>54426263
0
>>
>>54426226
A visual example might help:

Say I have this, with the aforementioned properties:

f( (f (f n a) b) c)

Then is there always an n' that makes it possible possible to rewrite this as

f ( a ( f b (f c n')))

? It's trivial to show that any left fold (resp. right) can be rewritten as a right (resp. left) one, but that would involve reversing the list (and since f isn't commutative, passing something like g y x = f x y to the function instead), which I want to avoid.
>>
>>54426292
no, almost certainly not
>>
>>54426231
>is_alphabetic
https://github.com/rust-lang/rust/blob/bed32d83fcd1337e962a58fd04fae6b8503e3283/src/librustc_unicode/char.rs#L449
>>
>>54426337
?
>>
>>54426329
that's what my intuition tells me, but I can't help thinking there might be some way to do it if we know that f has an inverse element or something. I just wanted to know if anyone had proper proof of this (or knew where to read up on stuff like this).
>>
>>54426382
I can't think of any example where this would be true

+/* are commutative and -// are not associative
>>
>>54426359
I was interested in how is_alphabetic is implemented and I just liked the comment and pasted it here, tagged you because you used the function not as a response or an invitation to discuss anything
>>
I'm planning on making a program in python to create a graphical output of nmap. Do you know anything already done like this? I'd love to see it.

Like creating diagrams and graphical maps from the generated output idkw
>>
>>54426542
https://nmap.org/zenmap/
>>
>>54426584
No, not a gui frontend.

a tool that with nmap as a compliment, creates diagrams of your network, or a visual "way" of watching the output identifying routers maybe and cellphone computers, depending on how much information you've gathered and being able to update your map as you advance in your research
>>
>>54425544 here.
I had a question, i'm doing an input array for items that people bought, along with price.
How do I make an array that basically goes, "Input items until you break the loop"? It won't let me make an array without a constant value.
>>
>>54426706
Show some code.
>>
What's a good book to get familiar with C# for someone who already knows C & C++, bruvs?
>>
>>54426542
this is cool
http://stanford.edu/~mwaskom/software/seaborn/
>>
File: cubehelix_palette[1].png (32 KB, 662x662) Image search: [Google]
cubehelix_palette[1].png
32 KB, 662x662
>>54426761
>>
File: ded.jpg (36 KB, 530x800) Image search: [Google]
ded.jpg
36 KB, 530x800
>think the problem is the algorithm
>the problem is some stupid typo or a worng data type
I just wasted 2 hours of my useless life. Fuck dislexy man
>>
>>54426761
Yeah, it rock, thanks anon, I'll upload the code to gitlab if you want to check out later
>>
>>54426738
Sure.
int scanner();
{
int items;
cout << "Welcome, how many items did you buy today?" << endl;
cin >> items;
double item_price[5];
//
//items bought will have barcode for ID.
int items_bought[5];
//
double subtotal;
double tax;
tax = .40;
double total;
total = 0;
total = total + tax;
int i, j;
i = 0;
j = 0;
int method_of_pay;
cout << " Welcome, please scan your item's barcode, or press 0 to select method of payment." << endl;
int barcode;
cin >> barcode;
while (barcode != 0)
{
cout << "test";
}
if (barcode == 0)
{
cout << "Please press 1 for cash, or press 2 for creditcard / debitcard." << endl;
cin >> method_of_pay;
if (method_of_pay == 1)
{
cout << "You have selected cash." << endl;
cout << "Your total is: " << total << endl;
}
if (method_of_pay == 2)
{
cout << "You have selected creditcard / debitcard" << endl;
}
}

}
system("pause");

What I basically want to do is have it so the user doesn't have to input only 5 items exactly. I wanted to have the array set up to how many items they bought.
>>
>>54426781
I don't know if you want to show live
here is how someone did it for animation
http://stackoverflow.com/questions/33742845/seaborn-animate-heatmap-correlation-matrix
>>
File: 1461953555917.png (764 KB, 1080x1080) Image search: [Google]
1461953555917.png
764 KB, 1080x1080
>>54426810
>system("pause")
>>
In PHP, can I somehow output operators?
As in
echo $a == $b;

and it displays true or false?
>>
Is "what's the point in learning programming when Pajeet will do the same for $5 an hour" just a meme or an actual problem?
>>
>>54426810
Read about allocating memory, m8y.
>>
>>54426810
>system("pause");
what the fuck? is this what i think it is?
>>
>>54426832
var_dump()
should do the job if I recall correctly.
>>
>>54426840
it was a problem before, but after years of programs failing (and managers getting shat on, along with bad code) they scaled-down on pajeet outsourcing
>>
>>54426830
>>54426847
D-Did I do something wrong?
>>54426841
Thanks
>>
>>54426810
Use CTRL+F5 on visual studio to run code
you don't need system("PAUSE") anymore
>>
>>54426778
>dynamic typing
>even once
>>
>>54426855
Nice. Anyway to reduce that to an actual bool? Right now it outputs bool(false).
I want this to use in a variable, like this:
$array[0] = ($a == $b);
if ($array[0]) {
...
>>
File: 2sadtokillcossaks.jpg (53 KB, 945x945) Image search: [Google]
2sadtokillcossaks.jpg
53 KB, 945x945
>>54426888
>>
>>54426863
http://stackoverflow.com/questions/1107705/systempause-why-is-it-wrong
>>
>>54426888
http://blog.cleancoder.com/uncle-bob/2016/05/01/TypeWars.html
>>
>>54426891
That should work out of the box, I noticed you have to cast the expression to bool if you want to output it with echo, though. It's been a while since I touched PHP.
>>
>>54426943
dynamic typing is shit tier
f# type inference is how you should do it
>>
>>54426989
>type inference
oh how I love me some fresh memes right in the morning
>>
>>54426953
And to elaborate further, it only displays it when it's true, what the fuck.
>>
>>54426997
advantages of static typing without needing to type out the types most of the time
>>
>>54426953
hm.. neither
echo var_dump((bool) ($a == $b));

nor
echo (bool) var_dump($a == $b);

work. But maybe im misunderstanding you
>>
>>54427015
>>54426953
>>54427003
nvm its just the wrong thing. it works with var_export
>>
>>54426943
>There were other languages bubbling up from time to time; but they weren't taken too seriously. We heard about Smalltalk, and the million dollar machines required to run it. We knew of Logo, Lisp, and several other languages.

>Lisp
>First: Implying "Lisp" in itself is a single language
>Second: Implying it was not taken seriously

Into the trashcan it goes
>>
File: umaruic.webm (1 MB, 640x360) Image search: [Google]
umaruic.webm
1 MB, 640x360
>>54426989
inference or not you still have to deal with type abstractions and type complexity required by the language.

from >>54426943
"""
You see, when a Java programmer gets used to TDD, they start asking themselves a very important question: "Why am I wasting time satisfying the type constraints of Java when my unit tests are already checking everything?" Those programmers begin to realize that they could become much more productive by switching to a dynamically typed language like Ruby or Python.

And that's exactly what happened in second half of the first decade of the current millennium. Tons of Java programmers jumped ship and became dedicated dynamic typers, and TDDers. That ship-jumping continues to this day, spurred on by the fact that salaries tend to be higher for programmers of the dynamic languages.
"""

The point, which has been a debate for years now, is maybe that static typing > dynamic typing but when you use TDD techniques then dynamic typing is superior.
>>
>>54427015
Nevermind what I said.

$a = 1;
$b = 1;

echo $a == $b; // Prints 1; prints nothing if false apparently.
>>
>>54424400
That SICP looks brand fucking new and I'm sure he's never opened it after that photo shoot.

SICP is a meme.
>>
>>54427063
>>54427044
update, this doesnt work. this does:
filter_var(var_export($a == $b, true), FILTER_VALIDATE_BOOLEAN)

what the fuck php
>>
>>54427102
Jesus fuck, what an abomination.
>>
>>54427122
yup. still better than doing the old if (a == b) { o = true } else { o = false }
>>
>>54427062
this guy literally states this as an advantage
>You got a type exception during execution
lmao runtime errors
>>
>>54427062
you can always miss test coverage
you can't miss errors at compilation
TDD is the meme
>>
>>54427062
>writing 2x the code when the compiler could've just done it for you
>>
>>54427062
>"Why am I wasting time satisfying the type constraints of Java when my unit tests are already checking everything?"
Because the compiler is multiple orders of magnitude better at checking type constraints for you automatically. Why change to a language that makes you need to write test for type constraints when you can use one that does that automatically?
>>
Is there a dictionary for those pretentious bay area software terms like "coverage" and "code smell" and "technical debt" anywhere?
>>
>>54427172
Google
>>
>>54427172
https://docs.oracle.com/javase/tutorial/
>>
Reminder that most hackers are filthy webdevs
>>
#include <stdio.h>
#include <windows.h>

#define N_THREAD 4

DWORD WINAPI work(LPVOID);

int main(void) {
HANDLE hTid[N_THREAD];

for(int i = 0; i< N_THREAD; i++) {
hTid[i] = CreateThread(NULL,0,work, (LPVOID) &i, 0, NULL);
if (hTid[i] == NULL) {
ExitProcess(1);
}
}
WaitForMultipleObjects(N_THREAD, hTid, TRUE, INFINITE);
for(int i=0; i<N_THREAD; i++) {
CloseHandle(hTid[i]);
}
ExitProcess(0);

}

DWORD WINAPI work( LPVOID param) {
int tid = *((int *)param);
printf("thread n. %d\n", tid);
ExitThread(0);

}


Why the thread get a number which doesn't match with the iteration counter?
>>
>>54427465
could be process id?
>>
>>54427486
Nope, I pass the iteration counter as an argument to the thread. Also, it's not unique.
Sometimes I get:
"thread n. 1"
"thread n. 4"
"thread n. 4"
"thread n. 4"
>>
>>54427465
Race condition.
You're passing the address of i - which is the same for every thread - and by the time you dereference it in work() main may or may not have advanced to the next number.
You should pass a copy of i to each thread (don't take the address of i, cast it to a UINT_PTR and then to LPVOID)
>>
>>54425693
Just to make it more comical.
>>
File: hackerman.jpg (181 KB, 1920x1079) Image search: [Google]
hackerman.jpg
181 KB, 1920x1079
>>54427304
>>
>>54427521
You're right, thank you.
>>
>>54427465
because the variable is reused and before the threads are actually started the variables is overriden already
>>
>>54425740
what is programming music other than the music you listen to normally? does /dpt/ have different taste in music while writing code?
>>
>>54427624
Silence.
>>
File: fuckme.jpg (95 KB, 468x800) Image search: [Google]
fuckme.jpg
95 KB, 468x800
Having a problem with executing a java distribution on Raspian. The folder is made up of a jar file, and a handful of subdirectories containing resources, such as 'Movies', 'TV Shows', 'Resources' (contains fonts and images). The jar runs fine on Windows, but when I move it over to linux, I'm suddenly getting 'FileNotFoundException's when I try to read in a file from one of the subdirectories. It's almost as if it isn't searching in the relative directory, but expects '/home/pi/Desktop/Media-Center/TV Shows/series-list.json' as the filepath, rather than just 'TV Shows/series-list.json'.
>>
Hi /g/, starting out. I have been working on Codeacademy's Python course, and got stuck on a seemingly simple exercise: a function that returns the median of a list. Here's what I wrote:

def median(li):
m = 0
pos = int (len(li) / 2)
if len(li) % 2 == 0:
m = (sorted(li)[pos] + sorted(li)[pos+1]) / 2.0
else:
m = sorted(li)[pos]
return m

Apparently median([4,5,5,4]) returns 5.
>>
>>54421780
crap, it's been a while since the last time I wrote a Java program...
import java.io.*;

class Main{
static public void main(String[] args){
BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
String a, b;
int na, nb;
try {
System.out.println("Type the first number and press enter");
a = kb.readLine();
System.out.println("Type the second number and press enter");
b = kb.readLine();
} catch(Exception e){
System.out.println("Error.");
return;
}
na = Integer.parseInt(a);
nb = Integer.parseInt(b);
System.out.println("Numbers are " + na + " and " + nb);
System.out.println("Product is " + Product(na, nb));
}

static public int Product(int a, int b){
if(a<0){
if(b>0){
return -prod(-a, b);
}
else {
return prod(-a, -b);
}
}
if(b<0){
return -prod(a, -b);
}
return prod(a, b);
}

static private int prod(int a, int b){
if(a==0 || b==0){
return 0;
}
return a + prod(a, b-1);
}
}
>>
File: fuckme2.png (28 KB, 606x383) Image search: [Google]
fuckme2.png
28 KB, 606x383
>>54427740
and this is the directory containing the jar
>>
>>54427740
Does the letter case match in the program and the directories? Windows is case insensitive whereas Linux is case sensitive so that could be it. Also what happens if you try to prepend ./ if it's not case issue.
>>
>>54427754
the indentation got all messed up.
>>
>familiarizing myself with the source code of a project
>all comments seem to be written by foreigners
>can't understand shit

Why, why do companies insist on outsourcing the most critical part of a program to third world shitholes?


>// will set to time in prepare
>>
>>54427757
main() shortened a bit:
    static public void main(String[] args){
BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
int a, b;
try {
System.out.println("Type the first number and press enter");
a = Integer.parseInt(kb.readLine());
System.out.println("Type the second number and press enter");
b = Integer.parseInt(kb.readLine());
} catch(Exception e){
System.out.println("Error " + e);
return;
}
System.out.println("Numbers are " + a + " and " + b);
System.out.println("Product is " + Product(a, b));
}
>>
>>54427803
My wild guess would be that len is 4, while indexes start from 0, so pos is 2, and you average the 3rd and last number from the list.
>>
What's the consensus on Elixir. I've been playing around with it for a few days and I like it.
>>
>>54427803
def median(li):
return sum(li) / len(li)
>>
>>54427624
sounds so boring. even when im programming and dont feel like listening to music ill put on a youtube video or something so im not listening to absolute silence.
>>54427937
havent given it a lot of attention yet (mainly cause i dont have a project to try it out for) but it looks really nice
>>
>>54427889
Absolutely right.

>>54427965
that would be an average, wouldnt it?
>>
File: umaruw.webm (1 MB, 1280x720) Image search: [Google]
umaruw.webm
1 MB, 1280x720
>>54427803
branchless

def f(a): 
even = not len(a) & 1
hl = len(a) // 2
return sum(sorted(a)[hl - even:hl + 1]) * 1.0/(1 + even)
>>
>>54428025
>that would be an average, wouldnt it?
Yes but there's no way median out of 4, 5, 5, 4 could return 5.0 so I assume they chose wrong word whereas average returns the expected 4.5.
>>
File: REEEEEEEE.jpg (489 KB, 2048x1518) Image search: [Google]
REEEEEEEE.jpg
489 KB, 2048x1518
>>54427788
wew, it's no use :^(
>>
>>54428047
>branchless
ni-
>umaru
>>
>>54428050
Well two more things that you could check for:
1) What's the CWD (not sure how to check that in Java)
2) If the files have proper owner/permissions
>>
>>54428050
whats the cwd of the jar when you run it with the jvm? (its probably looking at System.getProperty("user.dir") which you can change with -Duser.dir )
(current working directory)
>>
>>54428050
>using the smiley with a carat nose
>>
>>54425909

>hailstone
Oh, I read that as Hail Satan...
>>
>>54428049
I forgot to say I was supposed to sort the list, sorry. Thanks tho : D
>>
>>54428207
You're going to hell
>>
>>54428049
This worked
>>
>>54424494
You are literally just talking about filtering and inserting elements into a multimap. What kind of big meme framework are you using to do this simple procedure?
>>
>>54428228

Maybe...

Or maybe god isn't real, Jesus was a conman, and Muhammad was a pedophile warlord.
>>
>>54428434
I hope you find heaven
>>
>>54428268
pos = int(len(li) / 2)

You don't need the call to int. len() returns an int. If you are using python3 and need truncation use // instead of / for division.
>>
>>54428081
>>54428115
Thanks, guys, it was a problem with the current working directory! Using -Duser.dir fixed it!
>>
>>54428473
OK Terry, now go back to developing TempleOS and insulting those CIA niggers.
>>
wich text editor use and why?
I instaled geany yesterday
>>
>>54428565
sorry
>>
>>54428606
vim
>>
>>54428642
Oh forgot to say why.
Muh keybindings.
>>
>>54428606
>>54428642
this
>>
>>54425468
wow thanks you really shed some light on the whole programming thing
>>
>>54428606
vim because comfy
>>
>>54428606
i use spacemacs since it's emacs with better defaults out-of-the-box. emacs (or (neo)vim) is the best choice in general since there's huge support for plugins and the editor is 100% configurable. for example, in emacs i have it configured to do provide syntax highlighting/checking, live error feedback from compilers, and autocompletion for most of the languages I use. i can also use it to track info for git repositories or help with planning ideas (org-mode). plus i can basically replace the rest of my computer with it cause i can run a browser, irc client, and shell in it all simultaneously :^)
>>
>>54428606
emacs
>>
emacs
>>
>>54428606
i started with nano and now I refuse to use anything else because I have Ctrl+O/Ctrl+X muscle memoried so hard I can't use anything else.
>>
>>54428723
that was me for a long time. i went through a MNML phase and just used nano without syntax highlighting. eventually i sort of forced myself to start using emacs for fun and i ended up liking it a lot more. although i still do small edits with nano by habit.
>>
>>54428723
>programming with nano
can nano even have plugins/etc?
>>
File: image.png (113 KB, 865x855) Image search: [Google]
image.png
113 KB, 865x855
>>54428606
Emacs

>>54428697
If you are interested, the next version of emacs is going to get a fully graphical browser that supports javascript. You can use it now if you compile emacs from the git repository, and run "xwidget-webkit-browse-url"
>>
>>54428723
nano is like emacs-light when it comes to bindings

if you use readline a lot, the defaults are emacs-style keybodas (C-e, C-a, C-g, C-d, etc)
>>
>>54428697
I tried going from vim -> spacemacs but I just couldn't handle the bloat
>>
>>54428764
Why do you need plugins for?
They lead to excessive tinkering with the editor instead of doing anything useful.
>>
>>54428807
Not him, but I need a fuzzy file finder plugin.
>>
>>54428770
>If you are interested, the next version of emacs is going to get a fully graphical browser that supports javascript.
that sounds pretty sweet, although i mainly use emacs over ssh because i do half my computing from windows and refuse to figure out how to rice emacs on windows
although that may be enticing enough to get me to finally install nixos and ditch windows
>>54428785
meh, i dont really give a shit about bloat that much. i kinda just think of it the same way as i think of the rest of the OS, since that's basically what emacs is like for me. in general, i rarely use more than 3-4 different programs on my computer (the others being mpv, firefox, and telegram) so it's not that much of a concern for me that some of them are bloated
>>
>>54428870
isn't that what locate is for?
>>
>>54428894
>mainly use emacs over ssh because i do half my computing from windows and refuse to figure out how to rice emacs on windows

I don't know if you already know this, but emacs lets you edit remote files directly from your machine through TRAMP.
C-x C-f /ssh:user@host:/path/to/the/file

I agree, emacs on windows is a pain. If your machine can handle it, it may be a good idea to install linux on a VM, get emacs on that VM, and then use the graphical version.

With vim, it doesn't matter if you use the terminal version or graphical version, because both have about the same features, but there is truly a world of difference between terminal emacs and the graphical one.
>>
>>54428928
What do you mean? AFAIK locate is not part of vim, but it's a GNU utility.
>>
>>54429000
just use the shell
>>
>>54429021
But ctrlp also lets me decide how I want to open the file (replace current, new tab, split, vsplit).
>>
hi where are the feminine penises xd
>>
>>54424540
How can i follow your progress
>>
>>54429043
grep the line number you want and pipe it into vim or something
>>
>>54429058
right here bby ;)
>>
>>54428606
vim, because modal editing is the most comfortable way to edit.
>>
>>54429071
I'll post it on Github: https://github.com/baspalmer. It's not there yet, but I'll create the project this evening.
>>
>>54424540
Just curious, what will this project have over something like rutorrent?
>>
Sorry for the scrub question but is this going to work?

    template<class T>
static inline T NextItem(const vector<T>& Array, int CurrentIndex = 0)
{
if (!Array[0]) return nullptr;

if (CurrentIndex >= Array.Num() - 1 || CurrentIndex < 0) return Array[0];
else if(T X = Array[CurrentIndex + 1]) return X;

else return nullptr;
}


It should iterate through an array, and when it reaches the end go back to the first index. If there's no element at the first or at the next index, then return null.

Not expecting a solution if it won't work btw, just a quick answer.
>>
>>54429229
>if (!Array[0])
should be
if (!Array.size()) return nullptr;
or
if (Array.empty()) return nullptr;

What's "Num()"?
Also, CurrentIndex should (presumably) be unsigned
>>
>>54429254
Thanks, Num is just like std::vector::size
>>
>>54429099
is your ass feminine too? :3
>>
>need to implement a power distribution network for a class project
>basically copying and pasting 50 billion times
>too lazy to do it by hand
>try to figure out how to script it in the design tools scripting language
>it's a LISP dialect
>have no idea what I'm doing
>no documentation
>starting to make progress
fuck SKILL
>>
>>54429229

If T isn't a pointer, this isn't going to work. If T is a pointer... why do you have a vector of pointers?
>>
>>54429316
T is always a pointer, and vector isn't STL's vector. Why shouldn't I have an array of pointers? I've been doing it all the time.
>>
File: emacs.png (115 KB, 813x640) Image search: [Google]
emacs.png
115 KB, 813x640
>>54428964
yeah, it's just that setting up spacemacs is weird as fuck on windows and i can't get autocomplete for any of the languages i use because that requires the compiler to be installed to the host OS (and not cygwin/mingw). i do have a linux VM actually, but the graphics drivers(?) broke emacs
>>
>>54429214
They solve different purposes. rutorrent is 'just' a front end for rtorrent.
My program lets you manage the torrent files and the (in)complete downloads. It basically read/deletes/adds files on the file system. Unlike rutorrent, it doesn't display the status of the download. It only displays if the download is (in)complete.
>>
>>54429529
EDIT
It's basically a specialized OwnCloud.
>>
>>54429344

>T is always a pointer
T could be any type, even a non-pointer type. T* is always a pointer.

>Why shouldn't I have an array of pointers?
If those are pointers that your vector doesn't have to manage, they're fine. If you're just arbitrarily heap allocating pointers and shoving them in an array, consider having an array/vector of the actual object itself and not having unnecessary indirection.
>>
>>54425468
>>54425492
>>54425561
You see, there are millions of 'programmers', but only a select few 'Computer Scientists'. One must engage with the world's API flawlessly, mastering the various data structures and algorithms you must use to achieve your goals. All you life 'programmers' would rather rely on the bloated kludgey jQuery libraries in your life-- coffee.js, sports.js, gf.js-- which is fine, really. Every life Computer Scientist needs a few code monkeys to manufacture bugs which only our brilliant minds can crack.
>>
>>54426069
Python and C++ are the only languages you should consider for most new projects. Exceptions:

>you're interfacing heavily with an API in a certain language (web app, for example)
>you need some craazy performant code
>a lot of 0.1x code monkeys are working on the project (in which case, use Java)
>>
>>54426337
haha that's so cute
ok rust is sorta cool
what's a good tutorial for it?
>>
>>54424540
Now I think about it... Why shouldn't I just create a remote file manager?
>>
File: 404.jpg (55 KB, 250x250) Image search: [Google]
404.jpg
55 KB, 250x250
>wants to program a 2d rasterizer library
>cant comeup with a name
>>
>>54426778
if you're actually dyslexic, for the love of god use a linter.
>>
File: evil doc.webm (106 KB, 956x536) Image search: [Google]
evil doc.webm
106 KB, 956x536
>>54426810
                cin >> barcode;
while (barcode != 0)
{
cout << "test";
}
>>
>>54429751
How about gaytracer
>>
POST YOUR STYLE GUIDELINES

>MUH CODDLED ELSES
>MUH NEWLINE CURLS
>MUH NEWLINE VARS
>MUH TABS VS SPACES
>>
>>54429821
NO BUREAUCRACY
SMALL GOVERNMENT
INDIVIDUAL RIGHTS
N O | G U I D E L I N E S

GOD BLESS
>>
>>54429821
>muh no wrapping
https://github.com/nv-vn/TelegraML/blob/master/src/telegramApi.ml#L730
yeah... i basically dont follow any style guidelines
>>
File: n.png (150 KB, 587x855) Image search: [Google]
n.png
150 KB, 587x855
>>54429821
i don't have coding guidelines: I just adopt the one advised by the language or the one enforced on a specific project (the exception is C where i have adopted my own guidelines).
>>
>>54430021
https://github.com/nv-vn/TelegraML/blob/master/src/telegramApi.mli#L548
o shit, the type signature for that function is even worse
if dubs i start cleaning up this code
>>
>>54430200
notch confirmed swedish
>>
File: notchsavior.png (111 KB, 605x674) Image search: [Google]
notchsavior.png
111 KB, 605x674
>>54430262
Why ? i don't get it.
>>
>>54430270
>fox news are shit
total
cuck
>>
>>54430278
*cock
he's a single NEET for life so I guess he can't be a cuck
>>
>>54430278
Dunno if it's legitimate or not (I don't watch/read fox news) but you should know that outside of the usa, fox news is know for being a permanent caricature.
>>
>>54430278
>faux news
allahu akbar news better. actual name is al jazeera or someshit
>>
>>54430316
Fox News are biased.
Fox News are incredibly biased.
Do you have any idea how biased left wing news is? Imagine living in Sweden or Germany where Fox News would literally be illegal. LITERALLY illegal.
>>
>>54429752
>linter
Holy shiet. I never heard of that. Thanks anon. I'm only studying C for 2-3 weeks a little everyday and never heard of that. Thanks. I'm the kind of person who gets fucked in linear algebra tests because I change elements/lines/signals of shit in matrix(plural of that)
>>
>>54430330
Are you saying that fox news is left or right ? i actually heard that fox news was among the ones hitting donald trump the hardest.
>>
>>54430366
Hitting Trump doesn't make you left wing.
In fact Trump is clearly socially liberal on many things, and very bad on trust and the constitution
>>
>>54430366 >>54430390
Plus I'm pretty sure Fox News work with the GOP establishment. Now he's basically the nominee they will probably stop unless they think they can push him on something.
>>
>>54430363
Happy to help. Atom has some good linter plugins worth checking out.

Also, if you do any command line stuff, it might be worth checking out zsh, with "setopt correctall" on-- it autocorrects misspelled commands.
>>
>>54430409
has trump any chance to win the presidency ?
>>
>>54430326
Al-jazeera isn't bad. Barein swims on oil money so they can make biased articles but the other ones can be quite good.
>>54430437
Thanks anon.
>>
>>54430444
Of course. It might as well be 50/50 at this point.
>>
>>54430464
>bahrein
Jesus my brain farted. It's qatar.
>>
>>54430444
Hopefully not.
>>
>>54430506
in European medias they say it's pretty sure he will loose but i found Hillary pretty bad at campaigning (zero charisma) and sanders has really been rough with her. On the other side, trump has tremendous charisma, same for his entourage (his wife and daughter). i think he will win.

if obama were honest, he would endorse trump.
>>
>>54430627
>sanders has really been rough with her.
correction:
-has
+hasn't
>>
>>54430674
he means back home under the sheets at his ten million dollar pad
>>
File: DMUX Before the pre alpha_019.png (187 KB, 642x509) Image search: [Google]
DMUX Before the pre alpha_019.png
187 KB, 642x509
Would anyone be interested in joining our project? We are making a 3D game based on vehicle style combat, we are using only FOSS tools.
https://github.com/CollectiveTyranny/DMUX
>>
>>54430762
this looks really cute anon. I'd help but I don't know anything about c++ or game development.
>>
>>54424400
Please do not use any photos of anime-related objects next time, thanks.
>>
>>54430817
it's actually video game related at first.
>>
File: scoob.jpg (27 KB, 500x333) Image search: [Google]
scoob.jpg
27 KB, 500x333
>>54430762
Irrlicht
Crazy Eddy's GUI
SFML2
Boost
Bullet Physics
RapidXML
OIS
>>
>>54430863
>reinventing the wheel
>>
>>54430762
>making a 3d game
fucking kek bet u can't even make ur own game engine kid
gtfo
>>
>>54430893
>not realizing your own problem domain
>>
>>54430932
Enlighten me.
>>
>>54430762

nice meme
>>
>>54430762
wow m8 did you learn HTML and then make your own game?!

wew lad how did you do that
>>
>>54430987
Thanks! :^)
>>
>>54431019
>he did not even look at the repo
>>
File: cmeme.png (3 KB, 1088x73) Image search: [Google]
cmeme.png
3 KB, 1088x73
>>54430762
can someone explain the point of cmake to me already?
when will this meme end?
>>
>>54430762
>We are making a 3D game based on vehicle style combat, we are using only FOSS tools.
So basically stallman-approved rocket league?
>>
File: stackoverflow.png (44 KB, 753x772) Image search: [Google]
stackoverflow.png
44 KB, 753x772
>>54430946
I refreshed my page while typing a huge response to this but to put it concisely you are dragging in an entire library to solve a simple requirement(that the library -happens- to have in its blast radius) and at this point most of your code will just be mediating between libraries to get them all to "play nice". This is what happens when someone falls for the "just use ______" meme on stackoverflow when they really just want one simple problem solved or need quenched.
>>
>>54430762
Looks pretty cool

Just curious, why did you choose to use Irrlicht? What does it have over something like Ogre or OpenSceneGraph?
Thread replies: 255
Thread images: 44

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.