« first day (1718 days earlier)      last day (3224 days later) » 

2:00 PM
best song ever xD
half life 1 graphics
 
am I going to hate you for it?
 
@FlorianMargaine omg
that's it!
haha
awesome, thanks man
 
@ssube So basically, there can be up to N elements in a single node, before it's subdivided?
 
@MadaraUchiha Depends on how you balance it. That implementation has a limit on levels (how many times the tree will subdivide) and a limit on capacity within each leaf.
 
@ssube So basically, the leaves are lists/sets
Of a defined maximum size
 
2:03 PM
Yep. Looking up an element or set of similar elements is quick, because you get the list(s) that fall within those bounds.
Updating an element can move it to another node, but again, you walk up the tree to find the containing node, walk down to find the most specific, and insert.
 
And insert is self-balancing
 
In a game context, you can keep track of which nodes are dirty and save them every so often.
 
@ssube Why do I need to save them?
Any other reason other than the general reasons to persist data? (Game crashes, etc)
 
To your DB, to broadcast to other players?
 
@ssube I can do that without a database with socket.io
 
2:05 PM
If you're lazy, you can also force the tree to be N levels deep on all nodes, which gives you very predictable traversal and database size.
That's slightly less efficient for very large, sparse maps, but easier when things move around a lot because you avoid rebalancing.
 
@ssube In agar, food is static, players are not
However, there's likely to be a LOT more food than players
 
That's roughly how a Minecraft-like game handles blocks. You have chunks (or tiles or what-have-you) of a fixed size and save/load blocks in units of a chunk.
You can load multiple chunks, you render based on which chunks are nearby and visible, you persist by chunk (and can compress the contents of a chunk using RLE, which is pretty efficient in that case).
 
@FlorianMargaine any tips on how to make the constructor a bit more elegant? so it's not just some empty constructor?
(also my question is open to any one :p )
 
Function d() {}
Alternatively, use babel
class D
 
@Cereal in vanilla js :p
oh
I can put all my variables inside there .. function D() { D.var = "etc. etc."; }
 
2:14 PM
this.var even
 
@Cereal this refers to the global scope, no?
 
@AaronHarding not in a ctor
 
ah because of function scope
DERP
omg control + k let's me down again
 
@AaronHarding Please don't post unformatted code - hit Ctrl+K before sending, and see the faq.
1 message moved to Trash can
 
this doesn't work for me tho
i know caprica jeez
 
2:16 PM
Are you hitting ctrl+k or command+k
Pretty sure half the people here use macs, and they don't have a problem
 
@Cereal well, they don't have that problem ;p
 
@Cereal it's copying in multiline code that breaks it
 
@Cereal I don't think so
 
0
Q: javascript function is undefined but my script is being loaded

Raiding_riderSo I'm tying to master JavaScript and to practice I'm trying to make a reaction time test. The idea is very simple you click on a button and after a random period of time the background changes colour and you have to click on a second button which then calls on a function that calculates your rea...

I just did:
function derp() {
    console.log(derp);
}
 
I guess people hit the CTRL+K problem if they try to format an already indented code.
 
2:22 PM
in my console and it printed the function fine. Are these answers all wrong or is the console scoping it?
I'll brb but I'm curious, ping me please
 
@Cereal most of us have computers
what with needing to do actual work
 
@JanDvorak yeah, i think this is it
 
Can't functions have naming conflicts with variables?
 
@Gemtastic Of course they can.
!!> var foo = "bar"; function foo() { return "baz"; } foo
 
@MadaraUchiha "bar"
1 message moved to Trash can
@Gemtastic Please don't post unformatted code - hit Ctrl+K before sending, and see the faq.
 
2:26 PM
lol
 
>_>
 
format ye'r code!
Also, needs a little more context
 
user1596138
*yer
 
function start() {
    start = new Date(); // wat?
}
Grossly simplified ^
 
Wasn't jsperf down last week?
 
2:30 PM
And the context is the question posed here
 
Is it still down?
 
hey guys
why am i getting an error with this
 
ctrl+k
 
1 message moved to Trash can
@AlexanderSolonik Please don't post unformatted code - hit Ctrl+K before sending, and see the faq.
 
object literal syntex ?
 
2:30 PM
the error usually explains why you're getting an error
 
told ya
 
@Gemtastic That's the error he's getting
 
SyntaxError: missing ; before statement
 
@KendallFrey Only bad programmers need to read errors
 
animations 	:   {
					0	: {

          }
        }
 
user1596138
2:31 PM
I'm a bad programmer then
 
What language is ShaderToy using?
 
@AlexanderSolonik WTH is that???
 
@JanDvorak A valid part of a JavaScript object.
 
@MadaraUchiha not really
 
2:32 PM
@AlexanderSolonik That's not how to assign a value to animations
 
@NickDugger for the shaders? GLSL probably
 
whats the error though
?
 
it's such an ugly language compared to HLSL :(
 
Never even heard of either
 
harder to optimize, too, since it's more specific about weird details
 
user1596138
2:33 PM
Haha wtf
 
user1596138
animations: {
    0: {

    }
}
 
This is my first time trying to get into 3D programming
 
@AlexanderSolonik "Uncaught SyntaxError: Unexpected token :"
 
(Open)GL Shader Language and High Level Shader Language
 
user1596138
I thought you said it was an object literal
 
2:34 PM
It's pointing to 0:
 
I can do 3D modelling, but fuck me arse if you expect me to make it do anything
 
user1596138
@KendallFrey ... wut
 
you can't put a : after a number
 
user1596138
Oh there's that too
 
@MadaraUchiha Like I said, I only glanced at the code itself and that's what I saw and wondered if that wouldn't cause a name conflict
 
2:34 PM
spoiler: it's not an object literal, it's a code block
 
!!> ({a1:2})
 
@JanDvorak {"a1":2}
 
user1596138
I was looking at the lack of brackets
 
@JanDvorak You can't use a digit at the start of an identifier, pedant.
 
because animation is a label because it has a : after it, so it expects a statement, not an expression, and { is the start of a code block statement
 
user1596138
2:35 PM
 
user1596138
You lie
 
user1596138
!!> var animations = {0: {}};
 
@Jhawins "ReferenceError: assignment to undeclared variable animations"
@Jhawins "undefined"
 
@Jhawins nope, I was right
you can't change the code and say I was wrong because the new code doesn't behave the way I said the old code did
 
user1596138
The old code was broken.
 
user1596138
2:36 PM
> You can't fix the code
 
and I was explaining why
 
@KendallFrey i am not following what your saying ?
 
user1596138
Ok wait, I'm not trying to be a dick but I don't understand
 
*you're
 
> Kendall: your code is broken
> * Jhawins changes code
> Jhawins: no it's not, ur rong
 
user1596138
2:37 PM
@KendallFrey jsfiddle.net/aqr01shd/2 it's not that he's using 0..
 
@KendallFrey if instead of 0 i put 'test' , i still get a error
 
user1596138
3 mins ago, by Kendall Frey
you can't put a : after a number
 
@AlexanderSolonik The root of your problem is that animation: is a label, not a variable
You should know how to assign a variable
@AlexanderSolonik Because 'test' isn't a valid label either
it thinks you have a block of code, not an object literal
 
Whoo, just got my travel itinerary for Utah
 
if you assigned it to a variable, it would treat it as a literal
 
2:39 PM
problem still persists
 
user1596138
@KendallFrey That's what I meant to say...
 
user1596138
lol
 
@AlexanderSolonik you can't assign a variable to a label
animations: is a label
you don't want a label
 
user1596138
@AlexanderSolonik an object looks like this {key: value}
 
or {key : { key : value } } ?
 
user1596138
2:40 PM
Not key: { value: {} }
 
user1596138
Yessir
 
@Jhawins , kwoool !
;)
 
user1596138
(;)
 
user1596138
@KendallFrey sorry bruh I'm sleepy. I didn't realize what you were trying to say I get it now
 
I need to jsperf something, where can I do that?
 
2:48 PM
@KendallFrey clone the source and run your own
it's open source w/ instrucitons on how to build
 
im lazy
 
@KendallFrey or invent a time machine
 
@KendallFrey huehuehe then keeping asking people if they have hosted their own clone online somewhere
 
I love all the Kocoum gifs on imgur right now
 
i'd google "jsperf clone -jsperf"
somethig like that
(so then jsperf.com is omitted"
 
2:50 PM
@KendallFrey Time, loop, and make sure you have a consumer function to break optimizations.
 
@AaronHarding hahahah 4 results
 
@KendallFrey haha, yeeeeeeeep
hahaha
 
I don't think self-contradictory queries work so well
 
what about
jsperf clone -jsperf.com
!!!
success
(kind of)
 
2:55 PM
What does that do when you search for a term and then also exclude it like that jsperf example above?
ohh, excluding the domain. nevermind durp
 
@rlemon for you bro, for you.
 
@NickDugger You can go troll the mormons.
 
I'll only be there a few days for work
 
troll fast
 
@Luggage Did someone say trolling Mormons?
 
3:00 PM
haha, i've seen that. goods stuff.
 
0
Q: how to script if argument corrently

Ross AndersonI'm trying to figure out what to do with this. I want a separate css/ file for mobile and desktop. I have modernizr and the detect.js plugin enabled but can't quite figure out how to do it properly. Also from what I have at the top - my three vars, is that the best way to do it? I'm putting it di...

dat title
how to script if argument not correctly?
 
Elder Packer shared his insights on the subject in his seminal conference address titled "For Young Men Only."
I hope 'seminal' was used on purpose, because it's brilliant.
 
@Luggage Ah, right, because women are incapable of masturbation
 
it's abount nocturnal emmisions
 
Women are non-sexual beings donchaknow
 
3:03 PM
but the point is it works well with both definitions of 'seminal'
 
@Kbi I downvoted because you are wrong. Ease the sarcasm and try it out. — Sterling Archer 3 mins ago
le sigh
 
Wow, 3+2i will be valid JavaScript soon :D
 
huh?
as in multiplying the 2 and i?
 
Integers? :D
 
@BenjaminGruenbaum please tell me that means complex numbers
 
3:05 PM
Or imaginary numbers?
 
@KendallFrey yes.
Operator overloading + literal suffixes
 
What's 'soon'? ES2016?
 
@BenjaminGruenbaum god damn son of a C++ they've ruined the language
 
@Luggage Hopefully :D
 
oh, hmm. interesting. would that be anything like f#'s units?
 
3:06 PM
The lack of operator overloading is the only reason I like JS :(
 
@ssube C++ is actually officially unruined since c++11 :D
@Luggage yes, also immutable.
 
dang, I just pulled a @Loktar
[].map.call(str, function (x) { return x; });
 
@BenjaminGruenbaum eh. It got slightly better.
 
Operator overloading only works for value types through a new system for multimethod dispatch.
 
@KendallFrey you bought all the games?
 
3:07 PM
@BenjaminGruenbaum es7? ( the complex numbers )
 
Units of measure would make sense.
@afonsomatos there is no ES7
 
how there is no es7???
 
@KendallFrey why not str.split('')?
 
The'll call it ES Vista
I mean ES 2016
 
@afonsomatos that "living standards" hippie bullshit
@BenjaminGruenbaum where's the proposal for that?
 
3:08 PM
ES6 is officially ES2015. We jsut call it ES6 out of habit.
 
1 min ago, by Kendall Frey
dang, I just pulled a @Loktar
 
nice, babel supports ** exponential
 
@ssube exactly
 
@ssube NOWHERE haha. In more serious tone - this is what was presented by BE at the last TC39 meeting.slideshare.net/BrendanEich/…
 
@BenjaminGruenbaum after the thread you showed me about "es features" last time, these slides are ridiculous
 
3:10 PM
@FlorianMargaine haha
 
So, I'm suspicious that charCodeAt etc. are less efficient than they could be, because they seem to be matching the performance of substr. Is there anything else I should consider for fast string parsing?
either that or substr is really fast
 
@KendallFrey they both have to do stupid unicode stuff
 
ahhhh right
 
unicode is slow
 
argh. i want that new version of VSCode with es2015 support to come out
 
3:14 PM
I already gave up on vscode and went back to atom
 
user1596138
So how would one export a stash in git..
 
It's gotten much better (readas: actually usable now)
 
yea, i'm on atom at the moment
 
user1596138
Security is stealing my computer and I don't want to lose shit.
 
but i have a JS + c# project. VSCode seems perfect.
also the debugging looked half-way decent.
IF you are referring to atom's slowness.. i uninstalled some plugins a few weeks back and that greatly increased it's speed
 
3:16 PM
I'm strongly against debuggers
 
@Luggage there's a thread on HN right now about Docker, I know you were wondering about it earlier
 
@Jhawins as a patch
 
if your DEBUG logs aren't good enough to repro, you're screwed already
 
You don't NEED a debugger. I've gotten away with it this long, but they can be really useful
 
get a good logging library with levels and use that
 
user1596138
3:16 PM
@KendallFrey lol oh right
 
log copiously and discard later
 
You don't gotta tell me, i argue to my friends that they can work without it
 
So is .split("") a decent approach to eliminating that Unicode cruft from string lookups?
 
bit.. it's a nice tool to have available.
Why not have the option
 
Even REBEL has a debugger
 
3:17 PM
@SomeKittens what's HN stand for?
 
HackerNews probably
 
Hacker News
 
ah
 
@ssube debuggers have nothing to do with repro
 
news.ycombinator.com
 
3:19 PM
i hack u wit java scripts
 
@KendallFrey if you can't repro with logs, fixing bugs that only show up in prod isn't gonna be fun
you can't exactly attach a debugger to a prod server
 
@ssube you can, in lisp
 
@ssube right, but the Venn diagram with that and "I'm strongly against debuggers" looks like two circles beside each other
 
monring
 
So a friend of mine asked what was the "double slash division" in javascript. 1 // 0
 
3:26 PM
@ssube That's why my main concern is making sure that 1. Code is environment agnostic and 2. Dev and prod environments are as close as possible.
Sure, it doesn't solve all problems (like traffic or stress), but it really irons out 90% of weirdness
 
@KendallFrey Relying on a debugger makes you less likely to pay attention to logging correctly and logging correctly makes a debugger unnecessary.
 
Yes to the first part, no to the second
 
You should be able to diagnose and reproduce an issue from the logs alone
 
@ssube Logs can't pause and change variable values in runtime
So no, logs are not a replacement for a debugger.
 
@MadaraUchiha you should never need to do that
 
3:28 PM
debuggers can do things that a logger can't, and the debugger lets you inspect only the state you need, without having to look at all the state
 
@ssube Is that so? And what if my application has a 60 second boot time?
 
Then fix that?
 
Would you really expect me to kill the process and start again for new values?
 
@ssube What if it's not broken?
 
The logs from the environment where the problem occurred should have everything you need to set up data to reproduce the issue.
turned up to debug level, at least. Day-to-day, you don't want to log that much.
Debuggers lead to really lazy "it works on my machine" diagnoses of problems.
 
3:30 PM
@ssube True, but reproducing the issue isn't the same as diagnosing it
 
The logs should contain most of your significant data points and let you trace execution to a within a few lines/the function where things broke, giving you enough to reason about the problem.
 
@ssube You're implying that most verbose level of debug should output entire stack traces for every function, and the state of every variable on every statement
 
If you can't reason about the problem, then your code is too complex.
 
@ssube That's a very easy thing to say
 
@MadaraUchiha It very well could (if you have a trace level below debug). Debug should at least note when it enters and probably when it leaves a method, with parameters that would affect program flow.
 
3:32 PM
What if the problem is very complex?
@ssube How do you do that? Do you sprinkle log statements everywhere?
 
@MadaraUchiha Yep. We've got a class that looks at per-class log levels and every class has a method like static get logger() { return getLazy(ServiceConfig, Logger.property, () => Logger.create(ServiceConfig)); }
ConfigurationDAO.logger.debug('Listing projects under', project, 'from', url);
return rh.get(url).then(data => data.project);
logging erywhur
 
@ssube We do that, and jesus christ is it impossible to find anything meaningful
 
@KendallFrey do you run it through kibana or splunk?
We used to use splunk, but it kinda sucks, so everything goes to fluentd (tdagent) and from there to logrhythm and elastic search/kibana
 
@ssube PostSharp
 
user1596138
3:37 PM
So security stole my computer and they told me to use @Loktars computer. I'm gonna install so many rootkits
 
user1596138
^ not true, don't fire me
 
@SterlingArcher I like baby boys and I cannot lie?
 
var o = Object.defineProperties({}, {
    ONE: {get:function(){return Math.random() * 2 | 1; }},
    TWO: {get:function(){return Math.random() * 3 | 1; }},
    THREE: {get:function(){return Math.random() * 4 | 1; }}
});

for (var i = 0; i < 100; i++){
    switch(3){
        case o.ONE:
            console.log('one');
            break;
        case o.TWO:
            console.log('two');
            break;
        case o.THREE:
            console.log('three');
            break;
        default:
 
@KendallFrey jesus dude
 
@KendallFrey Phrasing!
 
What...
 
ok, minijsperf is broken as fuck
 
when are switch case statements actually used and preferred over if-statements ? I don't ever use them plus never seen them in production
 
And I can't find another perf tool
 
@KendallFrey well, "a code-golfed jsperf clone" can't end well
 
3:48 PM
@afonsomatos more than three or four options
 
@FlorianMargaine it didn't
 
It includes the setup and the teardown in the snippets
 
JS makes any:any maps easy enough, though, that switches don't have a great use
 
@ssube At that point I usually make an object of functions and grab the right action from that
 
3:49 PM
true, thanks
 
@ivarni exactly. Most languages don't allow that or make it easy, but JS encourages it.
 
@ivarni aka truth tables
 
so switch isn't really too useful in JS
 
check("123")
    .case("323", () => /* .. */)
    .case("911", () => /* .. */)
    .case("121", () => /* .. */)
    .case("123", () => /* .. */)
    .default(() => /* .. */)
What about this ^
I think I saw that somewhere
 
switch never does anything you can't do without it. It's kinda just there for lazy people
 
3:52 PM
same for while in C++
 
@NickDugger I was once on a project where we made a DSL in Ruby for non-technical people to tweak a rule engine, switch was the construct they grasped most easily
 
@NickDugger i dunno, it's quite readable
 
I never said not to use it, I said that it doesn't do anything special
 
switch(true) { case regexMatching.test(..): .. }
is quite useful too
if you had to test like 10 advanced statements
 
so what's the solution to check many values?
 
3:54 PM
in array
 
var table = {
    323: function() {},
    911: function() {},
    121: function() {}
};
table[number]();
 
but for objects
and to include a default as well
 
fallthrough is also something switch allows
might be doable with objects, dunno; never tried
 
@ivarni a lot of coding styles specifically tell you not to use that
 
@ivarni that's not that useful
 
3:57 PM
Yes I know, but there might be usecases where it applies (rule engines)
it's a pretty narrow usecase, I admit that
 
I still like the chainable solution
 
you can also process an array/hash of rules and just not stop iterating
@afonsomatos that's the worst option presented so far
why the hell would you use closure and chaining to do something that's built into the language in two different ways?
 
If you have to check for multiple objects, and if you want it to be extensible, why not?
Plus it looks pretty.
 

« first day (1718 days earlier)      last day (3224 days later) »