« first day (2286 days earlier)      last day (2664 days later) » 

user6438653
11:00 PM
distance: function (a, b) {
    var c = a.x - b.x,
        d = a.y - b.y;

    return c*c + d*d;
  }
 
user6438653
How often should the server update?
 
distanceSquared is better
 
@rlemon damn i'm only on 480 steamcommunity.com/id/ctrlfrk/games/?tab=all
 
how close is 0.15?
if it's not under 1 hour, i'm playing some 0.14
 
probably more than 1hr :(
 
11:01 PM
friend invite sent
 
lol you kids and your drugs
 
nuclear power plants thought! uranium!
 
factorissimo re-interested me in the game
it's the only mod I run, but it changes the game so much
 
user6438653
@david So many games...
 
It's a pretty amazing idea, but I don't know how you'd balance it so it doesn't end up being OP
 
user6438653
11:02 PM
@towc Yeah, true.
 
Infinite nesting is pretty mad
 
I haven't nested any factories yet....
YET
but I've been reading a lot about designs on reddit
some people are crazy
 
can you move an existing factory into a factory
or do you have to rebuild it
 
It's like crack for a programmer's mind though... complete compartmentalisation and reusability
 
minecraft had a mod that did what you're talking about
you could spawn these.. cubes, that were the size of any other block in the game
 
11:04 PM
I am scared off by the known bugs with robots and factorissimo
 
this is probably my most complex factory so far
 
@KevinB you can pick up and move factories and all of their contents.
 
I'm admittingly not that good at factorio
 
user6438653
@SterlingArcher What is the import from stuff why not require?
 
I got no friend requests, if you were talking to me.
 
11:05 PM
@WATERYMEL0N import is ES6
import > require
 
user6438653
Ohh, right okay.
 
but literally nothing supports it yet
 
you need to compile
 
i'm good up until the launcher. I have never scaled up fully for that.
 
11:06 PM
guys do you thing this is a valid link where to study es6 new features? github.com/lukehoban/es6features
or I should choose another source?
 
that's good
don't limit yourself to one source
2ality.com is an excellent blog
talks a lot about new js
 
@rlemon hmmmm... I think that factory does too many different things?
 
@david sure does
 
@rlemon thank you
 
this map is pretty early.
 
11:07 PM
kangax.github.io/compat-table/es6 what.. where is import/export???
 
I just got robots
 
I don't see any support tracking for import anywhere
 
1 min ago, by rlemon
but literally nothing supports it yet
 
how?!?
It's so handy dandy
 
no one could decide on how to implement the details
is what I heard
like TCO
 
11:08 PM
Oh yeah, it says the specs still aren't done
 
i thought it needed an implementation before it was part of the standard..
 
Jeez my hair is getting long again
 
user6438653
@SterlingArcher Damm.
 
Brilliant.
 
Brillant
Paula Bean? it's an old meme but a golden one
 
user2620028
11:13 PM
jsfiddle.net/hatterismad/4kqsrqgp Can anyone explain why this bounces back and forth while resizing the window?
 
I need to stop using my laptop on the couch..
 
resize fires like a jillion times
debounce that shit
basically, you're stacking a shitload of timers by registering them in that event like that
so it freaks out
 
user2620028
is that not what settimeout does?
 
@HatterisMad ahahaah that's some crazy ass code
 
11:15 PM
every time it resizes you register a new timeout
 
user6438653
 
user2620028
looked up the debounce code and basically what i boiled down to was calling settimeout on function
 
(re the minecraft mod, had to stepa way) you could then teleport into them, and they'd be cubes that had space in them for you to build systems. Within that space you could put more factories, that you could recursively teleport into indefinitely
 
@HatterisMad no, not unless you start cancelling those timeouts
 
Hmm, didn't notice that
 
11:16 PM
debounce only calls it if it's not already in-flight.
 
@HatterisMad at the very least you can do something like this:
var t;
window.addEventListener( 'resize' , function() {
  t && clearTimeout(t);
  t = setTimeout( moveFooter, 25 );
});
 
user2620028
i think i just had read a shitty debounce article
 
you don't even need to check for t really
if you don't have anything else you care aabout
 
ah, i didn't know if clearTimeout(undefined) would throw a wobbly or not
i guess it's fine
 
user2620028
nah it doesn't
 
11:19 PM
it would call it on 0
just not sure if a timer starts with id 1 or 0
 
user2620028
i updated it like david said
 
user2620028
and now it doesn't freak out, but it is still seemingly randomly bouncing between the condition being true and false
 
user2620028
just not doing it shitloads of times a second
 
user2620028
is that a condition issue or something else
 
I vote to guard the clearTimeout(), but I can't think of any reason you would NEED to.
 
11:20 PM
@rlemon 101 hours on planetbase... did you manage to do the 4th planet? I gave up because it was too small and shitty
 
yea I've got them all done
it's a pretty fun little game
 
did you keep trying seeds till you got one with a decent area for building?
 
very chill but you still have to pay some attention to it
I'd always try the landing area, but yea sometimes I had to restart pretty early on
you always think you need more area than you do
(to get sustainable base, not to 100% all buildings)
 
but to get all the milestones you need like 300 inhabitants though right?
and that takes up a fair bit of space
 
Can you guys take a look at my code snippet and give me a few pointers. I'm trying to simulate ajax requests via timeouts and use promises to make the data flow. Imagining this in my real application I want my final array to be something that I would store on a file. It's currently simulating that by logging the values. But how would that work if it were saving them to a file.
 
11:22 PM
only 1/4 of the population needs to sleep at once
or like 1/5th
can't remember
 
By which I mean, how do I know when the array "is full"?
 
(almsot forgot to paste the snippet ) jsbin.com/toqaka/edit?js,console
 
I don't understand the question
 
Let's imagine that the console.log is saving to a file.
It's currently saving the file with [value1]
then overwrites with [value1, value2]
then overwrites with [value1, value2, value3]
 
user6438653
11:24 PM
I promise.
 
so you want it to append?
 
But that's not very smart...
I want it to say "ok, there's no more data to add to the array. Time to save it all in a file".
 
      if( final.length === Arr.length ) {
?
 
Basically In my real example I need to do 1 ajax request. Then if I get a 200 I push the result to an array. If it's a 404 then that I means I need to make a second request. The second request is a promise and when it finishes...
 
There's a firetruck just chillin outside my apartment
 
11:27 PM
sounds like a promise chain could solve your problem
 
@Thaenor Promise.all(Arr.map(name => requestFactory(name))).then(result => console.log(result));
 
I probably should've started from the beginning...
 
@Thaenor the X Y problem
 
Doesn't even need a promise chain, just Promise.all
 
Ok, so the first guy had a simpler issue, he needed to iterate an array of keys and make a request to the server for each of those.
Problem: the server is shitty and crashed because node made the requests too fast. It queued some and discarded others.
Because he couldn't changed the server, he made the function recursive. So each time it made the request, the resolve would increment an iterator and call itself again.
 
11:31 PM
That can be handled by chaining .then()s. you don't need to get into the promise contructor
 
Ah, in that case @KevinB was right, you want to chain the promises. At the moment you're still making all the requests at once.
 
I'm stepping in and I need to make yet another change to the code... when the request is made the server doesn't check if that data already exists, and issuing new ones overwrites the data which we don't want. Again the server guys won't fix it... in time.
So my change means, make a requests (GET) to check if data already exists. If so, then store it to an array, if not then make send out a second request (POST).
I've added a promise so the GET request waits on the POST one.
 
a function that returns a promise, that calls itself in the promise's .then if it needs to make another request. the promise returned will resolve when they're all done.
 
But now I'm struggling because the recursive chain of events is independent. I have access to the array where data is being pushed, but no way to know when data will be there.
I also believe that I can, and should, reffactor, and switch the recursiveness for an iterative method, now that there's promisses to prevent async behaviour.
I was almost inclined to use this - npmjs.com/package/sync-request
 
if you want it to happen one at a time, and don't know how many there are, it can't be iterative
 
11:36 PM
Bluebird's Promise.map(inputArray, { concurrency: 1 }); sounds perfect, if you don't mind the dependency.
What promise implementation do you use (if known)?
 
@KevinB I know how many requests I'm making, after all I start with an array of keys, for each of those I need to make at least one request. two depending on the server answer.
 
Also, lets use some new names for this sample. requestFactory, requestMaker are so generic sounding, i can't tell what is desired.
 
right, but that's the problem. you don't know the server answer. you could be making 10, or 20 if all 10 fail
 
But yes, the Promise.All seems to have solved it, thanks @david : D
 
Thaenor yea, you could just count the responses, but a pre-made promise helper for this very common need might be better.
 
11:39 PM
but if you handle that in the promise that fails and ensure it always ends up being resolved you ought be fine
 
@Thaenor it makes your code work, but it doesn't do what you think it's doing. It's making all the requests at once...
 
@david so they're assynchronous?
 
75
Q: Resolve promises one after another (i.e. in sequence)?

XåpplI'-I0llwlg'I  -Consider the following code that reads an array of files in a serial/sequential manner. readFiles returns a promise, which is resolved only once all files have been read in sequence. var Q = require("q"); var readFile = function(file) { ... // Returns a promise. }; var readFiles = function(f...

maybe relevant
 
@Thaenor yes... everything in javascript is asynchronous unless you're doing something very very wrong
 
I might be missing something here, but I think this could easily be iterative, same way as it is in the pen... I start with an array of keys, for each of those make a request - since I need to wait for an answer I know I'll either get a 200 or a 404. In which case the second promise is either made (404) or just pushed to the array (200)
 
user6438653
11:42 PM
@SterlingArcher Got a tip for your game use String.fromCharCode to compress data that is sent, like .send(String.fromCharCode(this.type, this.score, this.x, this.y, this.rotation, this.velocity));
 
Sounds like unnecessary micro-optimization to me
Besides, I store everything dynamically in redis for speed as is
 
@Thaenor as long as you realise that that loop finishes instantly, all the requests happen at the same time, and the function returns an array that is empty initially.
 
user6438653
It may me a micro optimization, but it will be low on data usage, so you might be able to get a few mobile users who are on data. I've played diep.io on mobile, it chews your data up. I haven't used redis.
 
@david I don't see how the requests are happening at the same time... the first request requestFactory filters some of the data (returns "done" instead of the name).
And that is still happening.
 
@jake I have an MRI that the doctor will look at tomorrow...
 
11:45 PM
@WATERYMEL0N @SterlingArcher github.com/google/protobuf
 
Best of luck! It's a shitshow
(healthcare that is)
 
right.
 
@WATERYMEL0N show metrics
 
@Thaenor shouldn't your responses be coming back with 5~8 seconds between them then? Instead of all at once?
 
11:48 PM
omg
 
> new String.fromCharCodes(...) plumbs through to the JavaScript expression:

String.fromCharCode.apply(null, array)

There is no other way of building a string from a list of character values (other than calling String.fromCharCode repeatedly, which is slower for large strings).
 
user6438653
@SterlingArcher Ehhhh? What?
 
@david for my use case I don't really care. All I care is that the second request is only called on some of them and that the final array has all the entries.
 
BTW, watch the first episode of Mind Field. It's free. Michael lives in an isolation room for three days. Need I say more?
 
user6438653
@SterlingArcher String.fromCharCodes?
 
you should care that it's a sloppy use of promises that's bound to bite back one day.
 
@Thaenor I thought the entire purpose was to not overload the backend server with a bunch of requests at once?
 
@david ahhh wait... so they're all going at once? So promise.all become asynchronous?
 
argh. it's all asyncronous.
 
the .all calls both timeouts simultaneously?
 
user6438653
11:51 PM
@SterlingArcher fromcharcode apply wins.
 
It's simultaneous that's the problem.
 
I don't see how converting a string to a char code compresses data
 
I'm so confuse... >.<
 
@Thaenor Your code calls it all simultaneously too... How long have you been programming javascript?
 
11:52 PM
Seems like an extra step that would just even out the performance
 
So, I had a nice talk with this JavaScript programmer classmate of mine. She's good at JS.
And then I woke up.
 
@david not long enough apparently...
 
@littlepootis imgur.com/OCriTOp
 
user6438653
Because instead of converting a number, say 100 to a string. Which is 3 characters. It creates one chararacter.
 
@littlepootis damn
 
11:53 PM
this charCode things sounds useless for sterling unless he planned to re-write to use something like protocol buffers
 
@david :S
 
and it doesn't sound like he is.
 
it's not the gif
👎
 
@KendallFrey i can't let it die
 
user6438653
If you have a lot of data, it would make a large difference.
 
11:53 PM
> When Is JSON A Better Fit?

There do remain times when JSON is a better fit than something like Protocol Buffers, including situations where:

You need or want data to be human readable
Data from the service is directly consumed by a web browser
Your server side application is written in JavaScript
You aren’t prepared to tie the data model to a schema
You don’t have the bandwidth to add another tool to your arsenal
The operational burden of running a different kind of network service is too great
 
what do you think of this - npmjs.com/package/sync-request ?
 
@SterlingArcher I think @Loktar knows that better than anyone
 
since what I'm going for is literally synchronous code that propusefully waits...
 
yea but fast
 
user6438653
JSON is in string format when sent, there are too many characters.
 
11:54 PM
The issue is overhead for SourceUndead, the data being sent is minute, and most of the time it's just a single property update
 
@WATERYMEL0N you worry about completely the wrong things
 
user6438653
I know. I just want a game that doesn't chew up my data, lol.
 
so use a binary format
 
downloadable
 
bson
 
11:55 PM
singleplayer
 
user6438653
@SterlingArcher If so, then you don't need this micto optimization.
 
micro-complication
 
user6438653
@rlemon Binaray formatatate?
 
json+gzip
 
user6438653
11:57 PM
I'm using ws, so I'll make it binary and un mask it.
 
You could just use redis and manipulate a key => val store
 
@rlemon what a misleading name
 
without JSON
 
are you actually using ws or are you using uws?
 
Most of us are jsut talking about file formats as a spin-off conversation.
pretty sure
 
user6438653
 
so this has plagued me for years... anyone else notice when you come back on tab and move your mouse real fast it turns into a taco?
 
...no?
 
it's only for a split second
 
@rlemon you've got to be pulling our collective leg
 
11:59 PM
I'm going to try to find it in the sources tab
there has to be an image
 

« first day (2286 days earlier)      last day (2664 days later) »