/dpt/ - Daily Programming Thread

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.

Other urls found in this thread:

youtube.com/watch?v=wPCOPC9P8fY
go.microsoft.com/fwlink/?LinkId=691126
j00ru.vexillium.org/ntapi/
blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/
youtu.be/Ccoj5lhLmSQ
github.com/rust-lang/rust/blob/bed32d83fcd1337e962a58fd04fae6b8503e3283/src/librustc_unicode/char.rs#L449
nmap.org/zenmap/
stanford.edu/~mwaskom/software/seaborn/
stackoverflow.com/questions/33742845/seaborn-animate-heatmap-correlation-matrix
twitter.com/NSFWRedditImage

Programming convolutional recurrent deep Markov chins.

im cracking all your passwrods with my ibm 5 qubits quantum computer

...

anyone on Sup Forums 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.

...

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: youtube.com/watch?v=wPCOPC9P8fY

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?

>I want to write a Windows application
>It should use some system calls
Got bad news for ya m8

Are you telling me that their design sucks? I know that.

>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
go.microsoft.com/fwlink/?LinkId=691126

Last I heard Windows syscalls are undocumented, and you're pretty much forced to use winapi.

Thank you! But it requires .NET, I hate MS.
I didn't know that, I thought that WinAPI were the actual system calls.

Is this legit?
j00ru.vexillium.org/ntapi/

>- *Be friendly and patient.*
fuck off, this OP is always such fucking shit.

>I hate MS.
Ah, you're in that rebellious phase, it's alright we all grow out of it.

Ask your much beloved programming literate anything (IAMA).

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.

i don't remember her having huge breasts in the manga

Why is this season so shit?

>Is this legit?
>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.

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.

>go.microsoft.com/fwlink/?LinkId=691126
Nearly shit myself when it downloaded automatically.

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:
blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/

That's still 3+GB of garbage.

nice quads

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.

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.

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)

>string based messaging system

Please fix your code first before asking help.

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.

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

>Macbook

opinion discarded.

lol

I know how you feel, I've been a code autisan for 15 years

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?

Hacking is just playful cleverness user.
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?

do they serve euphoria at starbucks, or is it all your own?

Please. I got my third level black hat in tai chi by the age of 8.

You can't buy euphpria, young Padawan.
Look within...
Reinvent. Envision. Imagine. Embrace.

literally why the match

Put the other lines of code in a function, and call that function from the ws.onmessage function

there was an user 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?

>using spotify
I listen to a lot of k pop recently. It's really comfy senpai.

>>using spotify
please do enlighten me and explain your meme arrow. Botnets? Proprietary? What meme alternative can I manually compile on my Gentoo install?

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.

>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

rtorrent + mpd + ncmpcpp

r8 my hailstone sequence

o shit waddup

Have you confessed yet?

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?

Java isn't really used anymore. It's only there for legacy purposes and Android. Python is fine though.

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'?

Don't listen to this guy All serious projects are written in vbs. You shouldn't listen to anyone suggesting meme languages.

>and that n is the identity element of f
and that n is NOT the identity*

youtu.be/Ccoj5lhLmSQ

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

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?

0

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.

no, almost certainly not

>is_alphabetic
github.com/rust-lang/rust/blob/bed32d83fcd1337e962a58fd04fae6b8503e3283/src/librustc_unicode/char.rs#L449

?

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).

I can't think of any example where this would be true

+/* are commutative and -// are not associative

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

nmap.org/zenmap/

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

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.

Show some code.

What's a good book to get familiar with C# for someone who already knows C & C++, bruvs?

this is cool
stanford.edu/~mwaskom/software/seaborn/

...

>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

Yeah, it rock, thanks user, I'll upload the code to gitlab if you want to check out later

Sure.
int scanner();
{
int items;
cout 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 barcode;
while (barcode != 0)
{
cout

I don't know if you want to show live
here is how someone did it for animation
stackoverflow.com/questions/33742845/seaborn-animate-heatmap-correlation-matrix

>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?

Read about allocating memory, m8y.

>system("pause");
what the fuck? is this what i think it is?

var_dump() should do the job if I recall correctly.

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

D-Did I do something wrong?
Thanks

Use CTRL+F5 on visual studio to run code
you don't need system("PAUSE") anymore

>dynamic typing
>even once

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]) {
...

...