[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: 32
File: indians5.png (44 KB, 753x772) Image search: [Google]
indians5.png
44 KB, 753x772
Previous thread: >>54696352

Whatcha working on, /dpt/?
>>
File: 1463796563322.png (43 KB, 894x744) Image search: [Google]
1463796563322.png
43 KB, 894x744
Is it possible to print more than 256 colors in the terminal?
>>
>>54704752
Because you refuse to read the documentation.
>>54704937
Yes. Read the documentation.
>>
>>54704918
3rd for C#
>>
>>54704954
>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?
>>
>>54704994

C# a best.
>>
>>54704954
>Yes. Read the documentation

Wrong. My terminal doesn't support it
>>
>>54704998
Here you go friendo: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
>>54705041
That's too bad. Maybe stop being a sad cunt and send a PR that adds support.
>>
File: sad frog.jpg (27 KB, 330x330) Image search: [Google]
sad frog.jpg
27 KB, 330x330
>>54704994
>>54705041
Fourth for VBScript.
>>
>>54705135
Ew, gross.
>>
File: 2016-05-23 13_27_58-Atomica.png (85 KB, 552x798) Image search: [Google]
2016-05-23 13_27_58-Atomica.png
85 KB, 552x798
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.
>>
>>54705149
>toaster plugins
?
>>
>>54704918
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.
>>
>>54705167
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..
>>
>>54705081
>send a PR that adds support

People already have.
>>
File: indians6.gif (60 KB, 1024x874) Image search: [Google]
indians6.gif
60 KB, 1024x874
>>54705199
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
>>
>>54705302
>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'; }
>>
File: dpthime.jpg (156 KB, 934x1000) Image search: [Google]
dpthime.jpg
156 KB, 934x1000
>>54704918
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++.
>>
>>54705326
>t. BonerLord
>>
>>54705294
>>54705199
where do you find good libraries, how do you search for them?
Student here. We are told to invent the wheel over and over.
>>
>>54705294
JQuery is shit, and even stackoverflow acknowledge this
>>
>>54705167
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
>>
>>54705352
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.
>>
>>54705213
>>54705370
Gotcha, I only know of a slick WPF one, you would have to do some janky interop with .NET to call it.
>>
>>54705287
So I read the urxvt mailing list and those guys seem to be supreme cunts. Time to find a better terminal.
>>
>>54705352
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.

>>54705349
What?

>>54705369
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.
>>
>>54705424
All my theme stuff is in Xresources, so it should be an easy switch. How about xterm?
>>
No hime no code.
>>
>>54705370
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.
>>
>>54705443
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...
>>
File: hacker.png (255 KB, 600x561) Image search: [Google]
hacker.png
255 KB, 600x561
>>54705487
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].
>>
File: quarterpounderwithcheese.jpg (79 KB, 640x478) Image search: [Google]
quarterpounderwithcheese.jpg
79 KB, 640x478
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?
>>
>>54705696
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?
http://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?
>>
>>54705696
try searching for droplets and virtual hosts
>>
>>54705696
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.
>>
>>54705772
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
>>
File: JUST.jpg (31 KB, 456x320) Image search: [Google]
JUST.jpg
31 KB, 456x320
how do I add Toolkit 2013 to Visual Studio 2015?
am I forced to fucking download the whole package?
>>
>>54705806
>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?
>>
>>54705705
>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.
>>
>>54705819
What toolkit are you referring to?
>>
>>54705772
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 << temp << ',' << current << endl;

Does not correctly print the newline to my output file.

In my previous program:
out << weekday << ' ' << mon << ' ' << day << ' ' << yr << ',' << rev << endl;

Newline correctly appears in output file.

any ideas?
>>
>>54705785
Why would you pay for separate droplets for a couple of small sites? You just route them properly on the same system with nginx.
>>
>>54705806
No need to pull JSON into something so simple imo. Why not just, at most, separate those dicts into their own file?
>>
>>54705839
If this were to become a much larger project, what would the more sensible approach be? Just trying to get a better understanding
>>
>>54705754
>I hope you know .nix
I know enough to get by, im still learning.

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

>>54705793
>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.
>>
>>54705850
>>54705806
>>54705772
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
>>
>>54705848
Jesus christ, why are you doing that in C++.

I love digging ditches with spoons as much as the next guy, but damn.
>>
>>54705837
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
>>
>>54705848
Binary mode?
>>
>>54705866
If it were to become a larger project, a dedicated config datafile would probably be the way to go.
>>
>>54705919
That's a great question.
I'm way too comfortable with c++ so I pretty much do everything with it.
In vim....
>>
>>54705888
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.

https://www.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
>>
>>54706009
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.
>>
>>54706009
A
>>
>>54704918
Working on an Atom package.
>>
>>54706042
Yes, calling the same function with new parameters.
>>
>>54706009
How the fuck are you having a race condition without threads?
>>
>>54705974
Abuse them high level languages, mate.

string csv = things.Select(t => $"{t.temp},{t.current}{NewLine}");
AppendAllText(@"C:\temp\test.csv", csv)
>>
>>54706006
they seem to have the same thing, also for apache.
Is there much difference between apache and nginx?
>>
>>54706071
yeah, that makes no sense. Could you at least post some psuedocode or something?
>>
>>54706062
what's it do?
>>
>>54704937
yes, but only if you use a terminal for the 21st century:

https://github.com/shockone/black-screen
>>
>>54706108
Help you keep track of parens.
>>
>>54706133
I thought that looked pretty cool until I saw HTML/CSS/JS. Yikes.
>>
File: help.png (45 KB, 1013x514) Image search: [Google]
help.png
45 KB, 1013x514
Any anon /js/ here could give me some help on currying?
I wanna add(1)(2)(3)(4)
>>
>>54705324
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.
>>
>>54706162
Well, typescript is actually bretty gud.
>>
>>54705326
>calls funny stackoverflow picture boring
>posts literally the most boring picture in /dpt/ history
>>
>>54705836
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.
>>
>>54706166
_.curry(_.reduce(args, function(total, curr){ return total += curr}));
doesnt work either
>>
File: stallman.jpg (16 KB, 690x460) Image search: [Google]
stallman.jpg
16 KB, 690x460
>>54706062
>atom
>>
>>54706133
That is kind of cool. My next terminal emulator is going to run on HTML and JavaScript...
>>
>>54706166
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.
>>
>>54706240
I can't predict how many arguments are gonna be passed
add(1),(2),(3),(45), yada yada
>>
>>54706255
then how the fuck do you know when to return a result?
>>
File: pajeet to csv.png (24 KB, 1036x518) Image search: [Google]
pajeet to csv.png
24 KB, 1036x518
>>54705974
>>54706090
It Just Werkz™
>>
To whoever suggested I learn Makefiles instead of CMake: thank you. U da best
>>
>>54706276
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 ???
>>
>>54706240
>>54706255

>>>https://www.sitepoint.com/currying-in-functional-javascript/

Read towards the end
>>
>>54706255
Function add (x) {
If x undefined return 0
Else return function (y) {return x+add(y)}
}

Then do add(1)(2)(3)
>>
File: defeat_me_john_romero.gif (5 KB, 57x87) Image search: [Google]
defeat_me_john_romero.gif
5 KB, 57x87
>>54705199
> 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."
>>
>>54704918
I'm starting to learn Swift after being a longtime objc user. Anyone else learned it?
>>
>>54706337
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<float> hodor_dies_in_s06e05_the_door;
hodor_dies_in_s06e05_the_door.resize(20);
std::cout<<hodor_dies_in_s06e05_the_door.capacity();
std::cout<<std::endl;
hodor_dies_in_s06e05_the_door.resize(10);
std::cout<<hodor_dies_in_s06e05_the_door.capacity();
>>
>>54706337
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.<anonymous> (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)
>
>>
>>54706348
Why no, I don't give fellatio to Apple execs. Thank you for asking
>>
>>54705199
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.
>>
>>54706377
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.<anonymous> (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)
>
>>
>>54706370
>Haskell
>GHC garbage collector literally tells everything to fuck off while it does its thing
>dropped frames everywhere
>>
>>54706370
Depends on the kind of game. You may end up having to write a wrapper around some graphics library, but you should do it!
>>
>>54706377
>>54706395
No shit, you're add a number to a lambda. That was just pseudocode
>>
>>54706290
>underscores in parameter names
Disgusting
>>
>>54706379
Wow! never heard that before! Thanks for the new and original perspective.
>>
>>54706415
I usually make my parameter names capitalized, and the constructor just uses lower-case alternatives.

I wanted to stick with what that anon had in his code example, so I just went with it.
>>
>>54706218
>MIT license
>not the best OS license.
>>
>>54706405
really? I was under the impression that the Haskell GC was generally able to do its thing very rapidly. Any links to read about this?
>>
>>54706340
>There's no such thing as "bug-free code."
This is what non-OpenBSD cucks believe.
>>
>>54706425
Do you think this was a witty retort when you typed it out?

Is this the kind of shit that gets upvotes on that other website?
>>
>>54706405
>>54706407
I'm thinking about doing something graphically simple, and turn-based like Civ.
>>
>>54699592
Still need help.
I guess i'l just bite the bullet and do definitions rather than declarations. Will not look good but i guess it works..
>>
>>54706461
I feel like the only issue is whether there is access to the graphics libraries that is not a pain in the ass to use. I think its totally plausible from a technical standpoint.
>>
>>54706459
Did you think that your comment was interesting either? I was the one who initially posted something actually related to programming.
>>
>>54706488
I'm sure there must be something around. Even if it's really basic.

I suppose I could do the game logic in Haskell, and the finicky IO stuff (drawing, getting input) in C.
>>
>>54706320
still doesnt cover
add(1)(2)(3).....
unless its predefined add(1,2,3)
>>
>>54706519
So it looks like you could actually access OpenGL from Haskell (see: https://wiki.haskell.org/OpenGLTutorial1), so it should be doable if you're serious about it.
>>
>>54706559
I'll check out that tutorial. Thanks!
>>
>>54706374
Anyone?
>>
Somebody mentioned (in another, now deleted) thread a problem to compute the number of palindromes between a and b. I wanted critique on my solution to the problem, but the thread no longer exists so I'll post it here and hope he sees it.

>>54705380
>>54706008
Seems like it would be easy to just take the number of combinations of half a number (since the other half will be a mirror copy).

So say your upper bound is 65535, you know that all palindromes under this number will be of the form:

XXYZZ where XXY are picked and ZZ is a mirror of XX. So you only need to count the number of combinations of XXY which make this number be below 65535.

Quick proof of sketch implementation:

import Control.Lens
import Data.Char (digitToInt)
import Test.QuickCheck

-- Is a number a palindrome?
isPalin n = show n == reverse (show n)

-- Number of palindromes of exactly length n
palin10 n = 9 * 10 ^ ((n-1) `quot` 2)

-- Number of palindromes below n
palinLim n = base + rest + errors
where s = show n
l = length s
-- All palindromes strictly below n's length (easy to compute)
base = sum [palin10 n | n <- [1..l-1]]
-- All palindromes of length l, additional requirement that p <= n
half = take ((l+1) `div` 2) s
rest = read (half & _head %~ pred)
-- Account for two errors with the above estimations:
-- 1. handling of 0 (it's also a palindrome)
-- 2. is half ++ reverse half below n or not?
errors = 1 + case compare s (half ++ reverse (take (l`div`2) s)) of
LT -> 0
_ -> 1

-- Testing
propPalin n = (n > 0 && n < 100000) ==>
palinLim n == length [ p | p <- [0..n], isPalin p ]


λ quickCheck propPalin
+++ OK, passed 100 tests.


This runs in O(log(n)), which is fast enough for all practical numbers. Is there an O(1) solution?
>>
File: 1376637742250.jpg (38 KB, 539x460) Image search: [Google]
1376637742250.jpg
38 KB, 539x460
>trying to do a linked list
>haven't done that shit in years
>tfw forgotten the basic concepts

oh god just fucking kill me now
>>
>>54705149
>Atomica
I know you said Python but I really hope you're not using the Electron shell.
>>
>>54706688
Oh, also note that this is also a solution for “palindromes between a and b” since that's just palinLim b - palinLim a.
>>
>>54706692
>Forgot how a linked list worked
What? What did you forget?
>>
File: ghc.png (174 KB, 918x563) Image search: [Google]
ghc.png
174 KB, 918x563
>>54706447
https://blog.pusher.com/latency-working-set-ghc-gc-pick-two/
>>
>>54706692
pointers
there you go
>>
>>54706543
>>54706412
>>54706312

All right, I fucking did your homework for you (in ES5 though, can't into ES6)
function add() {
var result = 0;
[].forEach.call(arguments, (function(arg) {
result += arg;
}));

return result;
}

function curryVariadic(func, terminalValue) {
return function(x) {
if (x == null) {
return terminalValue;
} else {
return curryVariadic(func, func(x, terminalValue));
}

};
}

var addC = curryVariadic(add, 0);

console.log(addC(1)(6)(8)())
>>
>>54706374
Because it's not guaranteed to shrink the container with resize.
>>
>>54706692
data List a = Nil | Cons a (List a)
>>
>>54706719
setting up the class for the linked list. I know functions and pointers for shit in linked lists but I had completely forgotten how to set up the class itself.
>>
>>54706749
What the fuck does that even mean? It's not guaranteed. This is computing not fucking quantum physics. How the fuck do I make it guaranteed to change the size?
>>
>>54706726
This is really interesting, thanks!
>>
>>54706745
b-but senpai i really wanted to get something out of this
const _ = require('lodash');
let addRaw = (...args) => _.reduce(args, function(total, curr){ return total += curr});
let add = _.curry(addRaw);
console.log(add(1)(2));

It says "add(...) is not a function"
>>
Is dependent types a meme?
>>
>>54706811
nigga your lodash curry function won't work with variadic functions, you gotta roll your own variadic curry with a terminal value parameter like I did right there.
>>
>>54706776

here's what I have:

 class list{

list *next = NULL;
int val;

public:
list();
~list();
void insertnode(list *root, int val);
void removenode(list *root);
void printlist(list *root);


};


how do I improve it? I will add templating later on. For now I want to relearn the basics.
>>
>>54706200

I'm no VBS expert but that doesn't look wrong. What kind of error/result are you getting?
>>
>>54706844
You inserts and removes only work as a push and pop. You should be able to specify index.
>>
>>54706824
I think dependent types have real potential to be a new paradigm in programming, but they could easily get skipped over and just be a forgotten meme.
>>
>>54706370
Games generally have interactions that make doing everything functionally very hard. Possible of course but it's very hard.

Also games shouldn't allocate during their run generally. You have an asset load and you know what it is, so you malloc all the shit at the start and you're set. Asset streaming is reusing memory, not allocating new memory.
>>
>>54706870

I was assuming a sorted list would it be wiser to use an index/iterator?
>>
>>54706841
but senpai-kun
add(1,2,3,54,45,,56,46,2,456,4,6,54) works.
>>
>>54706987
are you actually retarded? Of course that will work, it's a variadic function. But you can't curry a variadic function like you would curry a normal function because you need to know how many arguments there are. So instead you do a different kind of currying where it collects the arguments and spits out the result when the terminal argument (null or undefined, in the implementation I showed you) is passed.
>>
>>54707021
nigga i still dont get it
https://lodash.com/docs#curry
>>
>>54707064
they're currying a non-variadic function there. You're trying to curry a variadic function.
>>
>>54706908
>I was assuming
You see, I didn't know your assumptions. I guess you don't really need to index, just to see if an element is there, but a binary tree would be a better data structure for this.
>>
>>54707088
gotcha nigga, this is the shit u film me
http://www.codewars.com/kata/539a0e4d85e3425cb0000a88/train/javascript
bitches be like "oohhh super simple solution great shit" but i can't seem to find it properly "simple" and it bugs me
>>
File: 1460915074494.jpg (21 KB, 466x359) Image search: [Google]
1460915074494.jpg
21 KB, 466x359
/g/, do me a favor and give me one good reason why i shouldn't start making mobile apps with Lua, while using a php web framework?
>>
>>54705919
>C++
>Not among the best programming languages
>>
>>54707133
post a screenshot if you want to show it, I'm not signing up for some gay ass shit to see that
>>
>>54707184
Wat. Why would you use a web framework to develop mobile apps, wtf dude.
>>
>>54707184
do it faggot
>>
>>54707197
C++ is great, but for that particular use-case, it's 10,000 times easier in something like C# or Python.

Sure, you can hammer a nail in with a monkey wrench, but you might as well just use a hammer if you've got one.
>>
>>54707206
pretty gay indeed
>>
>>54707214
direct compatibility?

this is my first mobile app using the web, if you can't tell.
>>
>>54707090

BST was next on my to dos on relearning after linked list, stack and queue.

I got the linked list working well enough I will add the iterator as well since that is useful.
>>
>>54707238
ok this is fucked up.

If add(5) return 5, then add(5)(5) is equivalent to 5(5) which is retarded because 5 isn't a function. Unless I'm missing something, this should be impossible.
>>
>>54707226
>C# or Python
they're disgusting languages, it's better to use whatever you're comfortable with or learn based java
>>
>>54707267
2k fuckers got this, and they even linked some gay ass video from youtube explaining:
_.curry()
>>
>>54707238
>>54707267
I'm late to the party.

What's the difference between what you're doing and just having a function with as many arguments as you want?
>>
>>54707280
>Recommending Java over C#

C# is literally Java, except they took nearly everything that makes Java shit and fixed it. Plus, comfy features like LINQ.
>>
An imageboard from scratch. infinity-chan is fucking riddled with bad code and horrible functional design mistakes that can't be fixed anymore and I want to have something to do on weekends.
>>
>>54707297
cuz in the task its written
add(1)(2)(3); // 6
add(1)(2)(3)(4); // 10
add(1)(2)(3)(4)(5); // 15
and so on

i can make add(1,2,3,4,5) but it tests even further before submitting
>>
>>54707297
Variadic function:
add(1,2,3) // => 6
add(1) // => 1


This weird fuckery
add(1) // => 1
add(1)(2)(3) // => 6


I'm not him but I have no fucking clue how this is supposed to work either.
>>
>>54707340
>I have no fucking clue how this is supposed to work either.
You're the perfect candidate for Javascript.
>>
File: ktMhEcr.png (10 KB, 881x226) Image search: [Google]
ktMhEcr.png
10 KB, 881x226
>>54707331
>>54707340
Yeah, I was thinking Variadic functions like pic related.
>>
>>54707385
Why would anyone ever, ever, ever, EVER

EVER
V
E
R

need this?
>>
File: Screenshot_20160506-091530.png (527 KB, 1080x1920) Image search: [Google]
Screenshot_20160506-091530.png
527 KB, 1080x1920
I'm finding a hard time in my understanding of General programming...

I seem unable to make the connection between how writing variables and assigning them values like numbers strings or bullion classes excetera actually translates to the final product...

How does doing all of that writing all the functions variables objects classes Etc turn into a website or a video game?

How does writing these lines of code turn into an animation or give a character model it's jump ability or shoot Rockets or make a website happen?

All that ever happens for me is the console returning a value or set of values after operating everything...

How do I take the code and turn it into something???
>>
>>54707409
Variadic functions are useful because it can make your programs nicer (see: printf). They are never strictly required.
>>
>>54707431
God damn it, /g/. I thought this was a board for people who worked in the industry. Instead all I see is kids figuring out how to make arrays and making useless methods. Step up your fucking game.
>>
>>54707326
they took nearly everything that makes java good and fucked it up. plus, disgusting shit like LINQ.
>>
>>54707448
What did you expect? It's still office hours in the US right now.
>>
>>54707450
>>54707326
They're practically the same language.
>>
>>54707434
Nope. Not prettier at all. In fact, if you use this shit for anything other than debugging you've got a long way ahead of you.
>>
>>54707409
>>54707385
>>54707340
Help be out biatches
WE CAN DO IT /G/
and i find it pretty useful cuz like
addTen = add(5)(5);
addTwenty = addTen(10);
>>
>>54707448
My industry is in ui design and level design utilizing already established engines. But I am branching out into actual programming to further educate myself on the backend. When I make the design and graphics for an interface I am always amazed at how the programmers turn it into a functioning product. I want to learn how that happens.
>>
>>54707485
java is like a cleaned up C++. C# is like the retarded bastard child of C++ and python
>>
>>54707448
I just finished work

A game is made from APIs on top of APIs, abstractions and optmizations of code other people made which can interact with hardware like your screen. On top of those abstractions is the logic you use, using their APIs, in order to instruct things to do other things.

It's like a computer itself. Building one from parts is easy, but there were people who dug deeper who were able to make the parts from silicon and other materials.
>>
>>54707509
Then why are you on here? Learn it. Don't discuss how to learn it. Literally just go to a directory, git init and do something.
>>
>>54707517
You're so wrong it's depressing.
>>
>>54707495
tried
let addRaw = (n, m) => n + m;
let add = function(...args){
return _.reduce(args, _.ary(addRaw, 1));
}

but once again im clueless and it returns me shenanigans
>>
File: s6lPsxOzSk.png (5 KB, 449x105) Image search: [Google]
s6lPsxOzSk.png
5 KB, 449x105
Mother

FUCKER

I fucking HATE apache I HATE IT I HATE IT I HATE IT I HATE IT I HATE IT
>>
>>54707561
>unironically recommending C# and python
you're depressing
>>
>>54707538
That is why I said the below post
>>54707431

I am a few weeks in and all I've learned so far is how to write math problems and equations and proper syntax which is fine but I'm just not seeing how any of this turns into a final product.

Like I get that if I want to define a characters jump height to 20 units, I can write the code that describes that, but how do I make it function how do I make anything happen with it?!

I know I'm fucking retarded.

>>54707526
These are the kind of answers that help
>>
>>54707599
I'm not. I'm saying that Java and C# are just two sides of the same crappy coin. I think Python is worse than both of them.
>>
>>54707252
Well, linked lists are supposed to be iterable. It's part of why people use them.
>>
>drinking coffee in hot weather
fml
>>
>>54707655
Why not not do it?
>>
add(1)(2) dude here, found the solution on the net
/srughs
function add(n){
var f = function(x){
return add(n+x)
}
f.toString = function(){
return n
}
return f
}
>>
>>54707668
coffee withdrawals and a lack of sleep makes me useless, gotta hit that coffee
>>
File: 1399516217014.jpg (111 KB, 500x667) Image search: [Google]
1399516217014.jpg
111 KB, 500x667
>>54707602
ur fucking retarded
>>
>>54707682
what the fuck
>>
>>54707655
Coffee is delicious though.
>>
>>54707655
Do you not have AC. Why not have iced coffee.
>>
>>54707682
was this supposed to be a subversive code competition? This is a retarded function.
>>
>>54707682
Stop. Just stop dude. Learn some fundamentals before you go any further. Please. You're fucking with your own progress right now. You aren't learning anything when you do this shit.
>>
>>54707728
>can't understand simple JS
It's a function that takes a parameter, and returns a function that takes a parameter, adding both parameters together. The inner function, as a string, is the 1st parameter
>>
>>54707682
So this is the true power of functional programming in weakly typed languages. Interesting... Disgusting.
>>
>>54707724
No. Shit.

Still looking for anyone who can help me understand how coding translates/turns in to final products.
>>
>>54707431
like if positions on the screen are mapped to values between -1.0 and 1.0 and if you want to draw some shit on the right side of the screen like at 0.5 you make it so that the value in the drawing API you're using ends up at 0.5
>>
>>54707773
I understood it just fine dude, but it's completely useless.
>>
>>54707728
>>54707748
>>54707760
I honestly don't know either, it just passed all assertions...
I don't want to submit this pile of dogshit cuz i found it on the net
>>
how would you guys handle this situation? Working on a scraper with a few components

One component requires the use of a Session. When the entire thread is running, this Session needs to remain persistent. I think I can get away by this by encapsulating the whole program in a 'with urllib.Session as c' and exporting the c through the various functions I need to run through.. I think. Anyways is there a different way I should do this? Like spawning another thread to handle those things needed for the Session and exporting commands to that
Dunno which way is better
>>
I want to attempt to code my own version of a booru. What would I need to know? Just your standard web stack + database stuff?
>>
File: 1407426387294.png (550 KB, 902x831) Image search: [Google]
1407426387294.png
550 KB, 902x831
>>54707776
Read SICP.
>>
>>54707790
Only in the context of that guy's retarded code

JS frameworks are built on this kind of fuckery, which is why it's so flexible
>>
>>54707744
>Do you not have AC
no, it's not common to have AC in sweden

>Why not have iced coffee
hadn't thought of it, i was thinking ice tea maybe but i don't want too much sugar, guess i'll look up iced coffee
>>
>>54707776
You can see the last readable step in the translation to machine instructions yourself:
gcc -S foo.c


Alternatively if you want to understand CS at a more theoretical degree follow >>54707796
>>
I asked in the /fglt/ but got no replies but since it's a bit related to programming I'll give it a shot here as well. I wrote a small script that runs scrot -s, saves it in /tmp, uploads the screenshot via SFTP and copies the URL into the clipboard (similar to Hyperdesktop/Push but just bare minimum script). The problem is that when I run the script either from the terminal or dmenu, the script works fine, but when I set it as a hotkey in my DE then it fails horribly.

What's even weirder is that it worked fine in OpenBox but fails with Cinnamon.

Anyone ever experience this issue while using Python and the subprocess module?
>>
>>54707809
You could move to Norway where it's a bit cooler.
>>
>>54707794
I'm creating one, and it's easy to set up (off course things like security, etc take longer to tie in)

My stack is;
Front end:
Bootstrap

Back end:
Python/Django

Then I'm going to use Amazon S3 for cheap image storage, Apache for web server, PostgreSQL for database
>>
>>54707816
try sleeping a little bit before you run the script (in your hotkey). This is how it's done in Awesome.
>>
File: BpADQXpIEAAQqj8.jpg (70 KB, 599x750) Image search: [Google]
BpADQXpIEAAQqj8.jpg
70 KB, 599x750
>>54707812
SICP is not really theoretic. It's the transition between thinking in abstractions and writing concrete programs. It's a great read for an intermediate programmer. Of course, you shouldn't take it as the only source or as the bible, though.

TAOCP is a theory book.
>>
>>54707831
>Bootstrap
>Django
>Bootstrap
dropped.
>>
What message should I write in my git tag?
>>
>>54707864
added trans-friendly flux capacitors
>>
>>54707858
>bootstrap
>bad
What else is going to give you portability, sass, less, common powerful features, in one framework

>django
>bad
I use it for work. It's so smooth to use. If there's a bug or feature that needs to be implemented, it's out within the day easily
>>
My friend tried to teach me the difference between compiling and interpreting.

What it sounded like was a compiler translates your language into machine language, whereas interpreting only translates your inputs into another higher-level language
But is there a resource for helping me understand how to write a compiler? Because I don't know shit about it. I can write interpreters easily enough though.

And also is machine language assembly?
>>
>>54707812
people now think that SICP is very theoretical? That makes me sad.
>>
>>54707655
>eat anything
>body heats up
Surely it can't be just me.
It's ridiculous. I haven't had a meal in weeks without getting soaked.
>>
>>54707858
at least he's making something, what are you making?

... that's what I thought
>>
>>54707812
>>54707853
Thank you for the tips based anons. I will look up SICP as well.
>>
>>54707858
what would you recommend?
>>
>>54707911
Here's a cute online edition: https://sarabander.github.io/sicp/
>>
>>54707847
I tried that but it doesn't help either. The script actually does run for the record it's just that subprocess.call that spawns scrot inside of the script fails with exit code 2.
>>
File: danke.png (6 KB, 479x284) Image search: [Google]
danke.png
6 KB, 479x284
>>54707876
> not writing commit messages in imperative form

get out
>>
>>54707900
machine language is assembly, but you've got the interpreter vs compiler thing wrong.
A compiler generates a binary file that can be run at any time.
An interpreter continuously reads and runs the source code. The program is run at that time only, and no binary is generated.
>>
>>54707853
Yeah. I was using the term theoretical to mean "abstract," as opposed to what other books teach, cookbookery. But theoretical has other meanings.
>>
>>54707900
I meant lower level sorry
>>
>>54707942
>not writing commit messages in haiku
Are you some special kind of faggot or something?
>>
>>54707945
Even then, SICP is just sort of abstract programming, it is much less abstract than the most abstract parts of CS.
>>
>>54707900
>machine language assembly
Generally maps 1:1.
Machine language isn't microcode though (which is what the processor ACTUALLY uses). But you never (i hope) have to touch that as a software guy.
As for writing compilers I don't have much of a clue. I've heard there's a book with dragons on it that's supposed to be good.
>>
>>54707897
Django's fine, but Bootstrap's too bloated for what you're doing.
>>
>>54707964
I'm not trying to speak in the superlative man. I'm talking comparative, i.e. SICP vs HTDP.
>>
>>54707980
While you may be right, portability is a HUGE bonus, Sass/less is icing on the cake. Customizable common features too. It means I'll worry less about front-end and worry more about the fun tasks of back-end, security, and server-side optimizations
>>
>>54705021
http://it-ebooks.info/book/375/
>>
>>54707957
> not following erlang specifications widely used and taken for granted in the industry

go back playing katawa shoujo neet
>>
>>54708022
thanks
>>
>>54708024
hwæt cwæþ þu?
>>
What do you guys listen to while programming? I like to listen to that faggot Ken Ashcorp. I know he's a furry piece of shit but his songs always get me pumped up.
>>
File: 1451754656610.png (15 KB, 418x359) Image search: [Google]
1451754656610.png
15 KB, 418x359
>his git comments aren't written in functional form
>>
>>54708051
Ken pls go
>>
>>54708051
https://www.youtube.com/watch?v=O4NH8mxmypo
Nothing like a cheeky mashup
>>
File: 1368120029629.gif (1 MB, 320x240) Image search: [Google]
1368120029629.gif
1 MB, 320x240
>>54708051
https://www.youtube.com/watch?v=N2bZwM-2FBQ
>>
>>54708051
https://www.youtube.com/watch?v=ASv-gMuiYk8
>>
>>54708051
https://www.youtube.com/watch?v=0x5ZRAVXxr8
>>
>>54708051
https://www.youtube.com/watch?v=YcsYSJwewWk
>>
How can I make this code more aesthetic? It's so fucking ugly.

def load_settings():
'''
Load config specified in sys.argv.
'''
global settings
args = sys.argv
if len(args) < 2:
e = "{0}\nCorrect usage: {0} config_setting".format(args[0])
raise ValueError(e)
config = args[1]
if config not in settings:
e = "entry \'%s\' not found in settings" % config
raise ValueError(e)
else:
settings = settings[config]
print "Loaded settings."
>>
>>54707900
a compiler is a program that converts one language into another. Colloquially, that usually means converted into machine code, but it could technically be any language. There's a couple compilers out there that take one language and convert it into javascript to ensure portability, for instance.

A decent way to start making compilers is to try compiling simple languages using a functional language like Lisp or Ocaml

An interpreter is more like a compiler that does its work at runtime. It compiles and then executes instructions on the fly.

Here's a couple textbooks I had in my compiler classes in college. I can't tell you if they're any good (I barely read them), but they might.

Engineering a Compiler:
https://mega.nz/#!VBMABKxL!H0dUyTWmKa665wbTF_95d7_4ZBGVUDOjxJeLCrf7U2k

Essentials of Programming Languages
https://mega.nz/#!dAVkCBAR!4pwKc5gWMSkGtUOWimG3CZ-drtP3biCBS2ioZ2s2Cfk
>>
>>54708119
i might try this later
>>
>>54708051
When working like all day on a project I usually listen to Synhpop and EBM, otherwise my usual alternative stuff.
>>
>>54708051
I'm quite partial to Dj Cutman:

https://www.youtube.com/watch?v=Q79j4LI3yWI

https://www.youtube.com/watch?v=9nYQIWbl_VY
>>
File: awwyeah.gif (229 KB, 200x200) Image search: [Google]
awwyeah.gif
229 KB, 200x200
>>54708051
https://www.youtube.com/watch?v=-4KIoz_g0V0
>>
>>54707931
Thank you!
>>
>>54708051

https://www.youtube.com/watch?v=KbVHbEGerRA
>>
>>54708051
http://asoftmurmur.com/
>>
>>54708142
double enter between each block, ya dingus
>>
File: 1458540600334s.jpg (2 KB, 125x91) Image search: [Google]
1458540600334s.jpg
2 KB, 125x91
>all this meme music
Thread replies: 255
Thread images: 32

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.