« first day (1937 days earlier)      last day (3005 days later) » 

10:00 PM
yeah, so you technically have 9 cases. 0-22.5 and the last one is 360-22.5
that's just an implementation thing, both return N
 
But my problem is my grid isn't a circle
its x,y coordinate squares
 
@SterlingArcher doesn't matter, you have an angle
 
so east is 90 degrees exactly
If it's anything above 90, it's SE
 
but it's not 90 exactly in real life
 
But this isn't RL
 
10:01 PM
if you have fat fingers and you point east, it's an inch wide at your finger, 10" out a few feet, etc
 
!!> (-22.5 + 360) % 360
 
@Luggage 337.5
 
Hmm, but a more realistic sense would make sense...
 
you have the angle, break it down into the 8 segments, each with 45 degrees of the compass (offset 22.5 from 0)
you're not longer returning east, you're returning east-ish
and north-ish
saying "yeah, it's exactly to the east" makes NE and SE useless, because they cover 89 degrees each
keeping each of the 8 directions uniform (45 each) is almost certainly better UX, probably more challenging, and definitely less cheatingy
 
Ohhhhh ok I totally get it now
I just drew it out
 
10:04 PM
....That's what I gave you.
 
Yeah but drawing makes me learn better
 
If you're using a grid of squares, you should have a ratio of how many blocks up or down and how many blocks left or right the target block is compared to the current block, you should be able to use that ratio to create an angle, think of a grid with an x and y axis and squares. getting an angle from that is relatively easy, am i missing the problem?
 
Well fine.
 
Plus I have the original NSEW lines I was looking at :P
 
@KevinB we gave him that math a week or two ago, it just wasn't clicking
 
10:05 PM
@KevinB angle is already calculated, just converting angle to a compass bearing now
 
he kept trying to make the four main directions into 1 degree each
 
Ah, ok.
 
which, on a grid world, breaks the game pretty bad
 
My trig-fu is weak
 
Hey
What a long day
 
10:10 PM
["N", "NE", "E", "SE", "S", "SW", "W", "NW"][(angle + 360 / 16) % 360 / (360 / 8) | 0]
 
That's actually surprisingly readable.
 
yeah, only way to get confused is operator precedence
 
I'd kill the indexology, but I can definitely read it.
 
ey, rep cap for the day
that ASI question was way too many votes
 
10:13 PM
10
A: Why "TypeError: f is not a function"?

ssubeIn your example, f is not a function. If you change the example, it is: var f = function(x) { alert(x) }; (function() { f(1) }()); You've run afoul of automatic semicolon insertion (or a lack thereof). Because of the ASI rules, if a line does not end with a semicolon, the parser can co...

 
oh cool, that'll be trending for sure.
definitely worth my upvote
 
it is a fun mix of initialization order and ASI/whitespace, but not worth that many votes
 
@copy that's fucking brilliant
Can you explain the math behind it though?
 
@ssube stackoverflow.com/a/35210525/1348195 the promise constructor ignores return value. That code actually emits a warning in bluebird - just so you know
 
@BenjaminGruenbaum oh, you have to call resolve?
it will catch sync exceptions though, yeah?
 
10:18 PM
@ssube resolve won't, I added an answer, bluebird ships with a try method for this use case
With native promises, you'd Promise.resolve().then(...
 
@SterlingArcher jsfiddle.net/vdgjbqk3
crap, @copy's is shorter
 
@BenjaminGruenbaum why not do it in the new Promise((res, rej) => { ... })?
 
@SterlingArcher You divide by 360 / 8 in order to get an index for the array from 0 to 7
 
@ssube that's just a longer way to do Promise.resolve and you can't use return value, half the value proposition of promises is that you can return and throw rather than pass callbacks.
 
So you just split the ranges, divided by 8 to yield a freaking index??
 
10:19 PM
@SterlingArcher And (angle + 360 / 16) % 360 only puts the middle of north on degree 0
 
That's awesome
 
@BenjaminGruenbaum Is that in general or just for this case?
Like, would you recommend never using the long-form new Promise and always using Promise.try or Promise.resolve?
 
By rotating by half a sector
 
And the bitwise or is to truncate the decimal
 
Yeah, you should probably use Math.floor
 
10:23 PM
they're the same for values below 4 billion and some
 
Aren't they the same result regardless
 
Non-negative values below 0x80000000
 
bitwise ops in JS are limited to 32-bit values and will overflow
the function calls can handle full 64-bit numbers
we ran into that at work when we added some space between IDs in the database, jumping from like 3 billion to 4.5, and some code broke
 
ohhhh yeah this will be safe. I fix my angle decimal toFixed(2)
 
user3047181
how much slower than c++ is js?
 
10:24 PM
Speaking of -- is the angle different severe if I simply truncate the angle as well?
 
@MeltyButter typically faster
JS is quick now, but won't rival C or well-written C++
 
@ssube in general.
 
user3047181
@ssube but is that only because it's easier to make bad mistakes in c++?
 
That's not really a good reason though
Bad JS can be slow too
 
@BenjaminGruenbaum misread the intent of the question.
 
10:25 PM
@MeltyButter JS is a mushy language. Those tend to be slower. JS is damn fast for what it is.
 
@ssube only use new Promise when creating a new combinator or when converting a callback API to promises. My code has exactly zero new Promise calls - heck, I'd rather do something in a nodeback and then Promise.promisify it most of the time.
 
C++ has to do less work and dynamic figuring-things-out, so it tends to be faster.
 
@MadaraUchiha ah
C++ isn't faster than JS in general, it's just much much more determinstic.
It's a very deterministic language, which is super good for some specific things.
 
oh son of a bitch
I fucked up my bukkit
I used player session id as a key, which I can't access for another player -_- oops
 
session IDs should be meaningless
use some abstract random or counter for the actual IDs
 
10:28 PM
Yeah, I guess I was thinking connection authentication
 
user3047181
so i just need to know for resource intensive tasks like machine learning, is c++ more than 3 or 4x as fast?
 
Outside of that I use player IDs
 
session will eventually become a pseudo-random, encrypted, timestamped, salted bit of data stick to a single node
it's not good for much after the load balancer
 
@ssube you're a .net guy, what do you use identity providers for?
@MeltyButter no, you'd use a simple language and a wrapper around a fast one.
 
@BenjaminGruenbaum I haven't used .Net in years (I just like it better than Java).
 
10:29 PM
@MeltyButter most ML is written in Python, I have a node wrapper if you'd like.
@ssube ah, cool.
 
ermahgerd wait im fixin mah bukkit
 
@SterlingArcher Derp
 
@BenjaminGruenbaum ya sry
 
user3047181
@BenjaminGruenbaum yeah I'll have that, friend :)
 
10:29 PM
@SterlingArcher what are you using for sessions? You should look into Passport and JWT
 
Um, I reinvented the wheel on that one I guess
 
that's the worst wheel to invent
 
You're telling me
 
essentially, your "session id" becomes a small encrypted bit of JSON with the user's player ID, timestamp, and whatever
 
@MeltyButter github.com/datascience-js/numjs.linalg it's very experimental thoguh
*though
 
10:32 PM
your server decrypts it and if it makes sense, you know which player you're talking to
so "login" just gives the app a token and every API call sends it as a header
super simple, super clean, client has a string and server sees JSON
 
jwt is awsome.
 
I'm planning on using those three together for a project soon, with a key on the server side, which should be damn secure.
Plus not doing my own identity management, just OAuth from FB and Google, so I'll just have internal ID, fb ID, goog ID, and timestamps.
 
jwt doesn't solve a real problem
stop solving problems that don't exist
 
it's vaguely nice to have a standard on encrypted JSON session tokens, but no, it didn't add much
@SterlingArcher you can also skip the JWT stuff (most complicated part) and just use an encrypted token as your session header. When the player "logs in," take a JSON object with their ID and the time they logged in, encrypt it with a private key, and send it to them.
When you get an Authentication header back, decrypt it, then attach that object as the context of the request.
 
That sounds extra fucking complicated
 
10:39 PM
oh no, it's super easy
 
To the guy who doesn't know basic trig?
 
you don't do the encryption yourself
you never do encryption yourself
that's PhD shit
 
@SterlingArcher what's the problem you're actually trying to solve here?
 
I wouldn't really call it a problem atm -- I just did some custom session hooks so I can pass my player object into a socket request and not just the node session
It's worked great actually
 
10:43 PM
I was encouraging he not roll his own auth
 
oh my god the bearing works!
Now let's see if I can make it flash
 
@ssube You seem to be encouraging rolling your auth though
 
@copy no? Use Passport to do the header stuff, then just decrypt the payload into JSON.
That's a pretty normal way to do semi-stateless API auth.
You shouldn't need to roll much, just provide a codec to passport and attach it to express.
 
Lol PhD shit. I wish one day I too was capable of PhD shit.
 
user3047181
@ApathyBear i know some phds, they aint shit
 
10:48 PM
@ssube The latter part is a bit vague
 
@MeltyButter I know some PhDs who do shit.
Every morning
 
@ApathyBear I have a PhD. A Perfect HotDog. now excuse me I'm hungry
 
how do you guys not get bored coding all day
 
Lol.
 
reddit
 
10:52 PM
Code is like 'encapsulated thought'. It's fascinating if you can believe that shit.
 
honest answer: have something you can switch too if you're feeling bored/burned out
 
@NathanJones building games and loving where you work?
 
we also masturbate eat cheese occasionally
 
like right now when I'm sick of dealing with project A, I just pop off some bugs on project B or something
 
10:52 PM
how do you strikethrough?
 
or go vape in my car
---a---
 
user3047181
i just go and eat a magnum cos I get free food and sweets. not braggin or anything
 
thank you
 
@MeltyButter every place I've worked that boasted free shit like that lacked in other key areas. free shit was their fixall
 
@MeltyButter fattie spotted
 
10:54 PM
we get bagels on friday which is nice because bagels come in packs of 6
 
nothing comes free here
 
@copy I imagine Passport has a provider for it. If not, it's a 10 line class.
 
except water
 
there is only 8 of us, so all drinks are paid for and most lunches
but it is also a family business (I'm not the family)
 
till u get with the daughter
 
user3047181
10:55 PM
@rlemon pfeh all the 'key areas' are determined by the employee's political ability :P
 
Can anyone help me linking my external js file in html? I have a global variable that uses getElementById() function, however, when I link the file in the head the variable returns null because the DOM hasn't loaded yet. How should i link it so that the DOM loads first then the JS code
 
@helloMundo Welcome to the JavaScript chat! Please review the room rules. Please don'task if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
btw, trains in canada:
Meanwhile trains in Canada https://t.co/2ykqEO3fG9 vía @Earlsimxx
 
it's the coding itself that I find boring, not the distractions
 
find a new job then
 
user3047181
10:56 PM
@helloMundo do like, an onload() thing at the end of your js code!!!
 
Have you tried drinking alcohol before you code?
 
user3047181
i answered first!!
 
@towc old video
but still good
@MeltyButter eh
 
@Meredith I'm in Utah lol
 
WELL THAT'S WHY
 
10:56 PM
better to just include the script in the proper place (before the </body> tag)
 
@rlemon well, I guess I'm one of today's lucky 10000?
 
hence the name running a train through it
 
then the DOM (unless dynamic) will exist when the script is parsed
 
var a = new Error('test');
console.log(a); // from where following representation comes? => [Error: test]
taking into consideration that typeof a === object, clearly it is not from a.toString() which will output Error: test without []
 
devtools
it is decoration for your benefit
 
10:57 PM
@Srle from the constructor name.
 
@melt
@MeltyButter the window.onload() = function thing?
 
i have no other skills (not that i have many in what i'm doing now), and you can tell i'm pretty shit-for-brains by what i post here. i'm scared to try to find another job, when this one pays pretty well.
 
1 min ago, by rlemon
better to just include the script in the proper place (before the </body> tag)
 
@helloMundo window.onload = function()
 
user3047181
@helloMundo yep thats what I was thinking
 
10:59 PM
@rlemon what benefit?
@Benjamin how constructor name affect it ?
 
I don't like adding listeners if I don't need to actually listen for anything
 
@Srle meh, rtfc
 
@BenjaminGruenbaum bmad
 
yeah I don't know, it's an interesting thing to read and I really don't feel like walking someone through the source right now.
 
@Benjamin at least new term learned! rtfc "Used when a person gets their hands on code and doesnt know what it does." :D
 
11:03 PM
It's just "read the fucking code", rtfc is just the initials.
 
I was expecting you to understand that and floor me, but bring me another drink.
 
@Zirak might be up for it and he knows where it is - but I doubt it.
 
Guys I almost have a hearing sense done!
It's giving a wrong bearing, but the blinker and shit is working. Gotta debug at home. So close!
 
You could add a layer of difficulty by making the direction less accurate based on the distance from the target
 
I don't know what you are talking about but \o/
 
11:05 PM
@MeltyButter yeah, that didn't work. :[
 
@rlemon the map blinks when a player who moves is close to you (and within your range of hearing)
 
ohh your game
I thought maybe you were fucking with hardware
 
And it blinks (currently wrong) direction of said player that moved
git commit
fuck
 
lmao
 
no commit message?
heathen
 
11:07 PM
I do my message in the prompt
See
 
git commit -am 'commit your messages like aboss'
 
ew no way
 
@rlemon I'll hit you if you do that in front of me
 
!!afk home time @Meredith stop laughing at me
 
git commit -am 'your french slaps do nothing to my rugged canadian moose body'
really tho, I'm bad at git
I should work on that
 
crl
11:32 PM
github.com/bokuweb/react-resizable-and-movable#ondrage-func onDrage, nice mix between Drag and Doge
 

« first day (1937 days earlier)      last day (3005 days later) »