/dpt/ Daily Programming thread

This is /dpt/, the best subreddit of Sup Forums

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

mattgemmell.com/what-have-you-tried/
catb.org/~esr/faqs/smart-questions.html


What are you working on?

Other urls found in this thread:

adventofcode.com/2016/
pastebin.com/sMVb4yj0
dpaste.com/164R131
dpaste.com/23YFSG7.txt
dpaste.com/2MMY224.txt
dpaste.com/0M06WWD.txt
github.com/ron-rs/ron
docs.racket-lang.org/scribble/index.html
google.com
twitter.com/SFWRedditVideos

First for D

I need some ZeroMQ help.

I want clients to connect to a server, make requests, and get replies. Naturally, I tried the REQ-REP pattern. It worked, but there was a problem: requests have to be processed one by one (since ZMQ sockets aren't thread-safe).

Solution: ROUTER-DEALER pattern. Clients connect to the router, which sends all requests through a DEALER that distributes requests to any number of connected workers.
New problem: DEALER fairly distributes requests to workers, whether they're idle or busy.

Example:
>two workers
>1st worker gets a long request from a client, it will be busy for a while
>2nd gets a short request from another client, it replies
>1st worker still has not replied
>new request comes in, DEALER puts it on the 1st worker's queue
>2nd worker is idle, while the 1st one is still busy with the old request, as well as a new one

How can I avoid this?

Depressing

>What are you working on?

Final day of advent of code. Also, exploring the deepest, darkest corners of Racket.

dumb reddit poster

>thats not an argument.
>macros are an awful relic
You probably use C where the CPP macros are complete garbage. Either way your "argument" is a fallacy. Print is a macro because that way it can correctly type the format parameters at compile time, and trait resolution allows it to resolve appropriate formatting functions. These formatting functions can even be automatically generated (derived, a concept borrowed from Haskell), which is really nice for debugging.
The C "solution" is a huge hack and has all sorts of weird coercement behavior, requires special cases by the compiler to prevent user errors, and has an entire class of exploits dedicated to invalid format strings.

>There is no reason for nested comments to exist,
It's just a minor convenience for when you comment out one block and then you want to comment out a larger block.

> having more than one type of string.
Yeah this is kind of weird at first, but Rust generally tries to enforce a thing about having owned mutable (resizable) things, in contrast to borrowed fixed things. e.g.
Vec vs &[T]
String vs &str
PathBuf vs Path
The variants on the left have length and capacity, and can be resized (e.g. push onto a vector, insert onto a string, add to the end of a path). The variants on the right have only length, can't change size (you CAN take substrings of str's though, unlike with C strings).
Another important point is that String is implemented by the standard library, while str is built into the language.


I like Rust, I think its a huge improvement over C++, however I think that it doesn't always occupy the niche of C, and I think that there are some major complexity issues that are going to be too big of a barrier of entry for most shitter programmers. However I think most of your points are shit

>deepest, darkest corners of Racket
Like what?

can I get in legal trouble with goodreads if I release my multitag search extension? it doesn't use their rated limited API

>that font
kys yourself then leave the thread and never comeback

the difference between a "programmer" and a software engineer is that a programmer defines himself by which languages he knows, while a software engineer defines himself by what he can program.

a programmer thinks it's enough to know how to use a hammer and saw
a software engineer realizes that knowing how to build a house is what's actually valuable

debate me

>debate me
People who go to school for software engineering are often not able to build metaphorical houses.
People who view themselves as programmers often have.

>dichotomies
>hardware analogy
id rather not

We did it, reddit! we saved Christmas.

Please don't bully.

>People who go to school for software engineering are often not able to build metaphorical houses.
>People who view themselves as programmers often have.
the problem is that very often they can't build real houses, and have trouble with the metaphoricals as well

>debate me
No, I agree with you.

This extends to any professional with some sort of domain- or industry-specific knowledge that can leverage a programming language to solve real problems.

no. software engineers design the interface/specification of the program and then manage the programmers who will implement that interface.

So, what's your verdict on Racket?

Can you do that in whatever language you want?

A software engineer, or better: architect, knows the program.
A programmer knows the components.

advent of code? yes

adventofcode.com/2016/

cool, might give it a go

connection error

I need to read a matrix, send it to a function and add the elements from the first row and second columns

But
somalinha+=matriz[i][j];
and
somacoluna+=matriz[i][j];

Are producing garbage wtf
REEEEEEEEEEEEEEEEEEEEEEEEEEE
pls help

pastebin.com/sMVb4yj0

someone should make a programming language based on JSON

Because somalinha and somacoluna are not initialized? Dont your compiler give you warnings about it?

JSON = JavaScript Object Notation

this is so cute.

We are making a web browser! Join the IRC channel if you want to collaborate.

Halp Sup Forums.... been stuck on this simple problem for hours.

Every time I output my code to a file all the headers show up for each file read in.

How do I suppress the header to only the first index?

Here is my code:
dpaste.com/164R131

What output I should be getting: dpaste.com/23YFSG7.txt

What my crappy code is getting:
dpaste.com/2MMY224.txt

Edit: I deleted line 6 but it still does nothing.

Edit2: base just prints out the filename without .csv suffix. I used base = os.path.basename(input_file).

My csv files look liket this: dpaste.com/0M06WWD.txt

Any ideas Sup Forums?

Any new exciting features/milestones?

Why not use WebKit, Blink or Servo?

i'm writting a parser and sometimes strings get returned like this
>>316099
this is a test


i only want the "this is a test" part.

do i have to write a regex for this? how can that be done?

They are working on opengl for what I see on the IRC, also debugging.

Is this the one with the racist fast food chain celestial body or another one?

don't use regex for aich tee emm ell

Not enough info. But my guess is that you execute this part for every input file and it writes header every time as you order it to.

>discriminating a logo
Some of us don't care what obscure reference you remember but we like it looks cool. Is not the only logo anyway.

what do then?

this code is wrong on so many places I can't believe it actually compiles
>returning multiple values from soma
>not storing the return value in main
>using uninitialized variables
>return(0) without ;
also it's seems you don't know what "scope" means. a tip: use -Wall -Werror -pedantic when compiling C code, it will save you a lot of trouble sometimes.

Just asking because I decided not to contribute because of how poorly associating yourself with fastfood would reflect on you.

>moving the goalpost
I see what you did there.

YOUR PNG IS NOW OPTIMIZED

Might implement protobuf in Racket

what more info do you need? I import all the files using glob.glob and then use a for loop to arrange the data, and then output it to file

How did you do that?

Are they building it completely from scratch?

I believe they do now but originally they borrow from links2 codebase.

magic

Thats not a very good idea, web browsers these days are as complex as operating systems. And 80% of what you want to do with a web browser is just conform to the spec (or the unofficial spec that everyone else is conforming to) so you gain a LOT by leveraging someone elses efforts e.g. webkit.
Good luck, I guess

Didn't work, ant there was no warning

Thanks

The idea is not to reinvent the wheel each time you depend on some new thing on the web but to reuse applications already in your computer.
Like for example they take from the unix philosophy to send media like videos to a video player you already have installed.
I particularly like this idea.

Go to hell, animetard.

Found the problem, I used a global variable

>vectors
Ew

what's wrong with vectors :)

They're not nearly as flexible as lists. And it's not just that you're using vectors, but that you're using vectors as association tables.

>trying to use regex to parse html
>writing your own parser in the first place
There are some cases where you are most definitely not going to write anything that's better than an existing library, this is one of them. If you're doing it as a learning exercise, don't. There are simpler markup languages you can write parsers for.

Have you heard of suckless's surf?

i got around using BeautifulSoup

string = """>>315998
this is a test"""

print (BeautifulSoup(string,"lxml").get_text())

but still outputs some garbage
this is a test

That looks nice, very lightweight. It did crash on me but worked youtube at the end. I read on the manpage that has plugins and scripts? Nice.
I didn't see any bookmarks, maybe if I see a script to have my firefox bookmarks I'll use it instead of FF.

ah so javascript is based on JSON

Instead of bookmarks you can just make bash aliases.
alias surf-g='surf >>

I used surf for a while and I liked being able to directly customize stuff (especially custom search engines) with very little hassle, didn't have to learn weird extension APIs etc. But I stopped using it because it was too buggy, had rendering issues and didn't display alot of pages correctly. This is probably webkit's problem

github.com/ron-rs/ron
Why aren't you using the Rusty Object Notation, Sup Forums?

You could basicaly encode lisp using JSON, just replace symbols with strings and lists with arrays. You'd have to do some more work to get string literals, pairs etc.

["define", ["length", "lst"],
["if", ["null?", "lst"],
0,
["+", 1, ["length", ["cdr", "lst"]]]]]

I have a shitton of bookmarks ( > 30 MB in html) so is not an option for me. Maybe I can use the html file and browse the file somehow.
I still want NetRunner, is too good of a concept and somewhat similar to surf, theck their feature list.
Posted from surf.

>not using scribble
docs.racket-lang.org/scribble/index.html

> > 30 MB in html
Christ. If you still really want to go minimal you could use 2-line bash scripts as bookmarks
$ cat book/google
#!/bin/bash
exec surf google.com

$ cat book/Sup Forums/g
#!/bin/bash
exec surf >>

Can I use XML to store information (the parameters) about loudspeaker drivers?

Yes. Its kinda bloated though.

thisjust use regular old csv

>>debate me
>arguing semantics
you already lost

That is more like quickmarks in dwb (the browser). I think I stay with just surfraw, but still no replace for a bookmark system.

So this isn't really a programming related question... More of a ricing thing, or maybe scripting... Not worth starting a new thread over. I am trying to change the background color which surrounds the xfce4-whiskermenu-plugin icon on an xfce4 panel. I simply want to change the color which surrounds the whiskermenu icon (to #333333) so it matches the panel on my desktop.

As you can see from my screenshot, the background color surrounding the whiskermenu icon seems to retain a blue color set by either the Victory-17.04-gtk2dark WM theme, or by the Victory-17.04 [GTK2] theme. (I Don't know which controls this.) After I set 'Custom panel colors' in Theme Configuration (also highlighted in screenshot) I noticed the background color behind the whiskermenu icon does not match the new color I had set for the panel itself. Where can I edit this value? I am not sure which file or property I am looking for. Can I find what I am looking for in /usr/share/themes/Victory-17.04/gtk-2.0/gtkrc? Or maybe add something to ~/.gtkrc-2.0?


th-thanks

in c++ theres cout, cerr and cin. cout writes to cin but how do i read cerr? does it also write to cin? how to differentiate between normal output and errors?

You could basically encode any AST in JSON for any language.

...

>This is /dpt/, the best subreddit of Sup Forums
>the best subreddit
>subreddit
>reddit
You have to go back.

should i fall for the oop meme?

>doesn't recognize world's most obvious bait
you're the one who has to go back

>cout writes to cin but how do i read cerr?
cout writes to stdout by default, cerr to stderr. Read about pipes and stream redirection in order to understand how to make the link between the output of a program and the input of another.

No please don't. It's not helping at all. It's just a way for software architects to not have to program anything and present something that looks pretty to the client. But from a programmer's perspective, it's a nightmare, nowhere near what's hyped about OOP.

Specify what you mean by OOP.

I think he means Object Oriented Analysis, not OOP

the problem here is that my program uses cin to read text and the other, redirected program sends error messages over cerr, what do?

Redirect stderr rather than stdout to stdin.

but it sends valid text over stdout and errors over stderr, i want to read both, is there no standard way to do this?

You can redirect both to stdin but I don't know how you'd handle both.

>This is /dpt/, the best subreddit of Sup Forums
It's a bunch of pajeets and juniors and schoolkids who are trying to look smarter than they are by means of denying actual production tools like OOP, imperative languages, scripting languages etcetera in favour of their own personal preferences for their school or amateur projects.

I've never seen here actual discussions about real algorithmic or computational problems or about denotational semantics, workflow organisation and collaborative processes, or internals of a CPython virtual machine, etc, etc.

All you care about is fucking around programming languages and showing off slivers of knowledge in some fields.

I'm actually now working on CUDA and multithreaded acceleration of a serial code for a computer graphic tool and on a Linux kernel driver for an input device but I've never had a desire to discuss it with the shitty habitues of this thread.

i need random access, not sequential access.

You so cool, where can I subscribe to your blog?

Let's talk about denotational semantics, friend. What are your thoughts on this issue?

how the fuck do I into natural ordering of strings the way an OS does it?

ASCII sort ordering is fucking pants on head retarded, yet so much software uses it. And come to think of it, so do standard collection libraries.

It is almost always the wrong way to sort things.

i prefer python

I'd rather have a nice chat about workflow organisation and collaborative processes, that'll fit nicely in the /daily programming thread/ about what programmers are actually working on.

What do you mean? How is the alphabet wrong?

There are quality discussions on /dpt/. It depends on the time of day.

>internals of a CPython virtual machine
crap

> t.non programmer

Was thinking of something like this:


17.4
2.75


1.0
Feroba 2
0.291


7.1


3.5
93


7.5
7.8
8.3


60.1
62.5
73.4