/dpt/ - Daily Programming Thread

Previous thread: Whatcha working on, /dpt/?

Other urls found in this thread:

open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
pastebin.com/BBMnS0TJ
digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts
github.com/shockone/black-screen
sitepoint.com/currying-in-functional-javascript/
twitter.com/NSFWRedditImage

Is it possible to print more than 256 colors in the terminal?

Because you refuse to read the documentation.
Yes. Read the documentation.

3rd for C#

>Because you refuse to read the documentation
Are you joking or are you serious?

can someone give me tips on how to learn java servlets with a tomcat server?

C# a best.

>Yes. Read the documentation

Wrong. My terminal doesn't support it

Here you go friendo: open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
That's too bad. Maybe stop being a sad cunt and send a PR that adds support.

Fourth for VBScript.

Ew, gross.

Just added an artists button (for really slick navigation) and left and right arrow keys to skip between albums quickly.
Also double click on album art to bring you to current playlist running if browsing around
Also some UI touchups.

Still looking for lightweight toaster plugins for python. Welcome to any suggestions.

>toaster plugins
?

DESU, if you're solving a generic problem yourself for anything other than a school project, you're seriously doing it wrong. Every general problem has been solved; if you're building software today, you should be stitching together libraries in a way that satisfies your requirements in the cleanest possible way. Your project should contain as little original code as possible.

Every line of code you write is a liability: it's an opportunity for a bug to exist in your project. The only things that matter are shipping bug-free code and keeping the codebase clean, readable, and well-tested.

Like toaster pop-ups, notifications really. I can use the vanilla windows one but it's horse shit and I didn't have much luck looking around for module because i'm using tkinter and it makes everything a bitch..

>send a PR that adds support

People already have.

I agree completely.

Basically, 1000's of developers smarter than you found a great way to do a thing, so use the fruits of their labor.

However, sometimes it's a bit excessive, like in pic related.

First for C master race

>it took him over 20 minutes to write a program to post this

Typical C.

Accessors in ecmascript 5. Considering you want to control access, what is the best approach, performance and usability wise?

someprototype.__defineGetter('foo', function() { return 'bar'; })

Object.defineProperty(someprototype, 'foo', { value: 'bar', writable: false })

good ol'
someprototype.getFoo = function() { return 'bar'; }

Man, we've been having such boring OP images recently. Really.

>Whatcha working on, /dpt/?
Finally working on my HDL again. Parsing and semantic analysis are basically complete - I just need to tie it statement-by-statement to the actual network of logic gates.

What is the simplest way to change the size of a float array in C/C++.

>t. BonerLord

where do you find good libraries, how do you search for them?
Student here. We are told to invent the wheel over and over.

JQuery is shit, and even stackoverflow acknowledge this

I assume he means windows notification/growl/gnome notifications style bubble/tray popups that are customizable.

more so than just text and a basic icon (windows balloon popups). rather something that lets you basically create custom windows as popups

Literally just Google what you're trying to do any pick something open source that looks promising.

Half the time I just copy the relevant code I need into my own classes and use it how I want to.

Gotcha, I only know of a slick WPF one, you would have to do some janky interop with .NET to call it.

So I read the urxvt mailing list and those guys seem to be supreme cunts. Time to find a better terminal.

If a library is mature and any good, Google will know about it. Search for what you're looking for and assess the quality of your options yourself.

What?

Back before frameworks and such were popular it had its place. The web API prototypes are often very verbose (I'm looking at you, Document.prototype.getElementById) and were, in the past, not feature complete. And back before CSS3 was usable jQuery was practically your only option for animations.

All my theme stuff is in Xresources, so it should be an easy switch. How about xterm?

No hime no code.

Yeah this is right.
My plan is to have it only show every track (or album) when they first transition on, probably with just the album art and track name
I'll also turn up some transparency, want to make it non-intrusive but delight-able.

You have always could do animation in pure javascript. I do agree that jQuery helped fill a gap that was mostly due to javascript drafts being incomplete

Trying to get back into the python groove, so making a lil facebook bot...

That's true, however jQuery did have a lot of tricks up its sleeve to make animations smooth (on shitty browsers and shittier computers) that were hard to reimplement and even harder to make work cross-browser. It's a testament to the new era of browsers that jQuery is finally starting to release support for the old ones like IE[6-8].

Sort of programming related

I want to make a few shitty websites but I don't want to spend $5/month on a VPS for each one.
The cheapest digital ocean plan is more than enough for at least 10 sites

Is there a way that I can make more than one domain name point to a different website folder?

ty senpai

I've got a VBScript question for you guys. It's for Siemens comfort panels to be precise.
What is a good way to implement a fscanf like function? I am able to write data to a .csv file and I'd like to read it out again.
What i tried to do was to read a character, check if it was the delimiter, if not add the character to a string. When the delimiter is reached convert the string to a real. Sadly it didn't work.

Anyone here able to help me?

Yes. You can have as many as you like. I have 3 sites hosted under different uri under the same hostname. I hope you know .nix

newb here, is this bad code?
pastebin.com/BBMnS0TJ

It's a settings file for a simple script I'm using. As you can see, it's set up so that I can just add configs to the settings dictionary and the functions will fill in the rest and ensure that defaults are there when a setting isn't configured and that each setting is valid.

Am I better off using classes for this? Am I abusing dictionaries? Is this sloppy/poorly-designed?

try searching for droplets and virtual hosts

Are these sites dynamic? When a browser accesses a website, it sends which domain in particular it wants as part of something inside the request called the header.

Pretty much any server software worth its salt can read this part of the header and decide which site to serve, even if all the sites are technically on the same IP.

The thing is, every server software is going to accomplish this/be configured differently, so you're probably going to want to tell us a little bit more about these websites of yours.

Your nicest option is probably to use nginx as a reverse proxy.

Normally data should be seperate from code. So instead of a dictionary have a JSON file, which your code then reads into a dictionary and calls your functions

how do I add Toolkit 2013 to Visual Studio 2015?
am I forced to fucking download the whole package?

>Normally data should be seperate from code. So instead of a dictionary have a JSON file, which your code then reads into a dictionary and calls your functions
just googled it and json looks pretty similar to what I've got here, will it really change anything in practice to do it that way?

>What i tried to do was to read a character, check if it was the delimiter, if not add the character to a string. When the delimiter is reached convert the string to a real. Sadly it didn't work.

You're going to have to give more detail than that.

What toolkit are you referring to?

For the level of complexity that you have, this is fine.

I'm parsing some text files and exporting them in a format we can use in excel.
Exciting stuff.

In my current program:
out

Why would you pay for separate droplets for a couple of small sites? You just route them properly on the same system with nginx.

No need to pull JSON into something so simple imo. Why not just, at most, separate those dicts into their own file?

If this were to become a much larger project, what would the more sensible approach be? Just trying to get a better understanding

>I hope you know .nix
I know enough to get by, im still learning.

I think this is what I am looking for?
digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

>going to want to tell us a little bit more about these websites of yours.
I dont think running 10 wordpress sites will be the best idea, so im going to work out something and keep them static. The idea is to target certain markets to get AdSense money $5/hosting + name.com happy hour sale domains $5/year. They probably wont generate much traffic to start with, so that is why I am looking to host them all on one site.

basically, I just don't want to have some garbage on my github that makes me look totally incompetent should an employer ever actually look at it. And I also want to learn more/know what I'm doing

If this approach is okay given the scope of what I'm doing then I'll leave it as is

Jesus christ, why are you doing that in C++.

I love digging ditches with spoons as much as the next guy, but damn.

In Settings->Config->General

I get this bullshit error "Macro definition of snprintf conflicts with Standard Library function" and it shouldn't happen in older Visual Studio versions or setting a toolkit of an older version

Binary mode?

If it were to become a larger project, a dedicated config datafile would probably be the way to go.

That's a great question.
I'm way too comfortable with c++ so I pretty much do everything with it.
In vim....

Yeah, it sounds like configuring nginx to serve 10 directories based off of the host header is your best idea. I haven't used nginx in a long time but there are a lot of guides online to configure it.

digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts

Guys I have a time dependant function which works fine if I call just once. However if I call two or more the results stack in the console. So I want to know what would be the CORRECT way to set the order in which these functions will execute.

Would it:
>A) Be better to use threads, using mechanisms intended to force the N thread to wait for the execution of the last.

>B) Check the time frame in which the Nth is being executed, then change the variables of the Nth+1 execution accordingly

>C) Any other idea you have

Call two or more what? Do you mean call the function twice? And by 'results stack in the console', do you mean a race condition w/ printing?

If it's a race condition and you have multiple threads running, then you want to use a lock.

A

Working on an Atom package.

Yes, calling the same function with new parameters.

How the fuck are you having a race condition without threads?

Abuse them high level languages, mate.

string csv = things.Select(t => $"{t.temp},{t.current}{NewLine}");
AppendAllText(@"C:\temp\test.csv", csv)

they seem to have the same thing, also for apache.
Is there much difference between apache and nginx?

yeah, that makes no sense. Could you at least post some psuedocode or something?

what's it do?

yes, but only if you use a terminal for the 21st century:

github.com/shockone/black-screen

Help you keep track of parens.

I thought that looked pretty cool until I saw HTML/CSS/JS. Yikes.

Any user /js/ here could give me some help on currying?
I wanna add(1)(2)(3)(4)

The simplest option (third) is the best. JS engines do extremely agressive optimizations that only really work when you use the most "obvious" features. Stay the fuck away from the first.

Well, typescript is actually bretty gud.

>calls funny stackoverflow picture boring
>posts literally the most boring picture in /dpt/ history

The code is back at the office, and since i don't actually know vbs the following code may contain a few errors.
What i tried to do was:
sub readReport()
'file opening and variabel defining here

do while not fo.eof
tmpChar = ""
do while tmpChar delimiter 'does something like: do while (tmpChar = fo.read(1)) delimiter Loop; work?
tmpChar = fo.read(1)
if tmpChar = delimiter then
report(i) = CDbl(tmpString)
end if
tmpString = tmpString & tmpChar
i++
loop
tmpString = ""
loop

end sub

Something like this.

_.curry(_.reduce(args, function(total, curr){ return total += curr}));
doesnt work either

>atom

That is kind of cool. My next terminal emulator is going to run on HTML and JavaScript...

function add(x) {
return function(y) {
return x+y;
};
}


is this not what you'e looking for? You can just keep adding more inner functions if you want to add more numbers.

I can't predict how many arguments are gonna be passed
add(1),(2),(3),(45), yada yada

then how the fuck do you know when to return a result?

It Just Werkz™

To whoever suggested I learn Makefiles instead of CMake: thank you. U da best

const _ = require('lodash');
let addRaw = (...args) => _.reduce(args, function(total, curr){ return total += curr});
let add = _.curry(addRaw);

thats what i was trying to accomplish bro but like, curry doesn't seem to work at all ???

>>>sitepoint.com/currying-in-functional-javascript/

Read towards the end

Function add (x) {
If x undefined return 0
Else return function (y) {return x+add(y)}
}

Then do add(1)(2)(3)

> bug-free code
using code you don't fully understand and that solves a general problem with a general solution also creates liabilities. There's no such thing as "bug-free code."

I'm starting to learn Swift after being a longtime objc user. Anyone else learned it?

Oops, that should be add(1)(2)(3)()

Extra parens at end

Do you think it's feasible to write a game in a functional language such as OCaml or Haskell?

Why won't it change size? How do I get it to shorten?
std::vector hodor_dies_in_s06e05_the_door;
hodor_dies_in_s06e05_the_door.resize(20);
std::cout

this doesn't work at all:

$ node
> function add(x) {
... if (x == null) return 0;
... else return function(y) {x + add(y);};
... }
undefined
> add(10)
[Function]
> add(10)(4)
undefined
> add(10)(4)(60)
TypeError: add(...)(...) is not a function
at repl:1:11
at REPLServer.defaultEval (repl.js:272:27)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer. (repl.js:441:10)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:188:7)
at REPLServer.Interface._onLine (readline.js:219:10)
at REPLServer.Interface._line (readline.js:561:8)
at REPLServer.Interface._ttyWrite (readline.js:838:14)
>

Why no, I don't give fellatio to Apple execs. Thank you for asking

This isn't always the case if you're pushing the boundaries. With functional stuff, especially dependently-typed stuff, sometimes you have to do it yourself.

uhh wait I'm retarded and typoed, but it still doesn't work:

> function add(x) {
... if (x == null) return 0;
... else return function(y) { return x + add(y); }
... }
undefined
> add(1)(2)
'1function (y) { return x + add(y); }'
> add(1)(2)()
TypeError: add(...)(...) is not a function
at repl:1:10
at REPLServer.defaultEval (repl.js:272:27)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer. (repl.js:441:10)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:188:7)
at REPLServer.Interface._onLine (readline.js:219:10)
at REPLServer.Interface._line (readline.js:561:8)
at REPLServer.Interface._ttyWrite (readline.js:838:14)
>

>Haskell
>GHC garbage collector literally tells everything to fuck off while it does its thing
>dropped frames everywhere

Depends on the kind of game. You may end up having to write a wrapper around some graphics library, but you should do it!