« first day (1869 days earlier)      last day (3081 days later) » 

9:03 PM
How to access static methods from instance methods ?
 
like you do from anywhere else
 
How can I use my <div> element on my other HTML pages?(e.g.: my navigation menu bar)
I've tried load (jquery) but apparently I can't set that to work
 
use server side templating
 
My google skills seem very weak today ;/ .. Mind linking an article that describes the technique you are referring to Florian?
 
@FlorianMargaine example ?
ClassName.staticMethodName ?
 
9:15 PM
@Abhishrek yes
 
okay
shouldn't that be classReference.staticMethodName ?
 
9:30 PM
CL-USER> (mod (reduce #'+ *edid*) 256)
0
I really like this kind of elegance.
 
@FlorianMargaine basically it should work as long as i have reference to the class right ?
 
@Abhishrek ah
that can work too, yes
 
:->
 
@Abhishrek but static methods are usually called with the class name
 
9:59 PM
code in movies. dem facepalms tho
 
crl
10:29 PM
men, some code to convert a #2278a1 to rgb(84,172,210)
!!> parseInt("a1", 16) ok thx nvm
 
@crl 161
 
10:47 PM
@FlorianMargaine needed a one for a simple hack
removed it in favor of a named method
 
@Zirak I did, I think
 
11:11 PM
@SomeGuy (the playlist : youtube.com/…)
 
11:22 PM
@BenjaminGruenbaum hint hint, nudge nudge
 
11:39 PM
@Zirak ?
 
I believe you owe him $4
 
@BenjaminGruenbaum If I were to fart in that answer's general direction, where would that be?
 
What's the question again?
 
oh yeah
Use promises and race.
You want to throttle it or to queue the requests?
You want a monitor by the way. It's a known concurrency primitive, heck - in Java every object is a monitor.
I think when even has a built in function for it.
 
11:44 PM
I want something in the middle
 
Basically:
- Create an empty resolved promise - call it queue.
- If someone makes a request and queue is resolved , return the promise for that request and queue `Promise.all(delayOneSecond(), apiCall())`
- Otherwise, do whatever logic you want that's "in the middle", return a promise for that result.
Oh, I think I understand your question - you need the promise constructor/deferred here.
 
// turn a bunch of:
something(4);
something(7);
something(12);
// done in a certain time window into:
preciousResource([4, 7, 12]);
 
It only makes sense, there is no way to obtain a promise for a future operation since a promise is a value - if you already have the promise from the API the action has started.
It's unreasonable to expect APIs to behave differently.
@Zirak oh, q-connection does that.
 
The code snippets I here may clarify
 
It even has a nice diagram github.com/kriskowal/q-connection
But yeah, do you just want to time box it? Anything else?
 
11:47 PM
Time box a bunch of requests into one and distribute back the results
Not much else
 
So another request doesn't make it wait longer right? Just one second?
 
crl
it's a bit like a throttle(..., 1000) (bad comparison, but thinking of it)
 
no, because it aggregates rather than just throttle.
 
There can only be one call to preciousResource per second, that's the rule
 
crl
ah
 
11:48 PM
Do you want to wait the full second even if there is only one request?
 
That's a tricky question, to which I don't know the answer. My heart says no, but my brain says "what if"
 
There is no backoff growth I mean right? It doesn't wait 100ms, 200ms and then the rest or anything?
Ok, so let's start with the whole thing:
 
Also, go to sleep, you have a flight to catch
 
Naa, I just got back
 
Hi.
So I am trying to solve deep-linking and refresh button issue with ajax, and wonder what the best way for that is. Is localStorage an option, and if so how would I go about to do it?
I have been thinking I need to get the current state somehow, or pathname from my url, as these are practically the same visually. And I have also been thinking, that it can't be so much I am missing, as everything I read, points to the pushstate as a sollution for this.
If I am mistaken, maybe I should just start to use jQuery or something, but in that case, what would I need to add from jQuery, when I alr
 
11:54 PM
var pending = [];
var loop = Promise.resolve().then(function(recur) {
     return Promise.delay(1000).then(sendRequests).then(recur);
});
function sendRequests(){
    if(pending.length === 0) return;
    var toSend = pending.splice(0, pending.length);
    makeRequestToPreciousResource(toSend.map(x => x.id).then(results => {
         for(var i = 0; i < results.length; i++) {
             if(results[i].success) toSend[i].resolve(results[i].value);
             else toSend[i].reject(results[i].value); // or something like that.
@Zirak typed in chat so sue me, or something like that
@sunto look into the html5 history api
 
Surprisingly there was only one syntax error
 
I didn't sleep much :D
 
I have been trying to understand the html5 history api, but maybe not gotten it correctly..

var url = element.getAttribute("href");
history.pushState({'url': url}, '', url);

This is the way I have my pushstate now, would I ahve to specify all my states, and url's?
 
(and another oddity, because unless you actually pass recur as a parameter...)
 
no, that's a mistake of typing in chat
 
11:57 PM
lwoudl I have to do it like this for every page I have that is loaded in ajax?

history.pushState(stateObj, "page 2", "bar.html");
 
I thought of something like that, just not exactly a forever-going loop (since there could be long times of radio silence). Was so-so satisfied.
 
Basically, do a setInterval, push to it, execute things when it's ready.
@Zirak why? Spinning off a single interval is cheap.
Especially if it's one whole second.
 
Just didn't think of it as a forever-loop, more of a regular start-aggregating-on-first
 
You can "wake the timer" and "make it sleep" if there is no activity. It's not hard to add that logic - or add exponential backoff and other nice stuff - but usually it's not really required for application level stuff.
 

« first day (1869 days earlier)      last day (3081 days later) »