« first day (1528 days earlier)      last day (3420 days later) » 

8:00 PM
It annoys you, so yeah, it's funny
 
perfect then :P
 
Not in itself. Needs a running gag related to it
 
I don't find most xkcds/smbcs funny :/
 
You don't need dark humour to be funny. exocomics.com for instance is fun to read, and it's full of fluffyness.
 
@Zirak wtf is that site
 
8:02 PM
 
I want my 2 minutes back
 
wait... india is officially GMT+5.5?
 
@Loktar Civ: Beyond Earth is todays draw
 
is that even a thing?
+.5???
 
GMT0530 yeah, what's wrong?
 
8:05 PM
new foundland is -3.5
 
ok...
 
crazy newfies
 
@towc convert to bases
 
I don't expect to come into another nation and have to set the minutes on my clock
@darkyen00 you don't have 24 hours?
 
There's even some +X.75 time zones.
 
8:06 PM
As per this
 
Nepal is UTC+5:45
 
according to that
earth has different gravity zones
and hence forth speed of time varies for all of us :P slightly so nope nobody has 24 hours exactly.
 
Can't be any more than one part in a thousand
probably less than that
 
alas, it was pulled from the site
but it still remains on the interwebs
 
@TomW but still ;-) not exactly 24 hours eh >
 
8:09 PM
@darkyen00 but I mean, as a system
 
> Apparent gravity on the earth's surface varies by around 0.7%, from 9.7639 m/s2 on the Nevado Huascarán mountain in Peru to 9.8337 m/s2 at the surface of the Arctic Ocean.
 
you use the 24 hours thing, right?
 
Wat. That sounds a lot more than I expected
 
 
@TomW you can literally buy gold at 2 different points
 
8:11 PM
sup with all those 1/2 and 3/4???
 
and make more money by selling on two different points
 
@darkyen00 or something more precious than gold...
 
uranium ?
 
As much as it'd cost you to fly from Peru to the Arctic?
 
but it will decay by the time you travel.
@TomW depends on how much you are buying ;-)
 
@KendallFrey youtube.com/watch?v=y97rBdSYbkg&feature=youtu.be you should program a model of this
use some 3d game engine or something and make the domino crush the surroundings
 
@rlemon do it in canvas ?
there are physics libs in js to do this :3
but ... hey doing htis in minecraft should be so much fun
 
another question. How do I check if some variable is a member of an array? A function that would return true if it is?
 
MLM
@macroscripts You can not check. There is no way to tell a is inside an array var a = 1; var list = [1, a, 3];
 
@MLM no way ?
 
8:22 PM
@MLM u sure?
 
MLM
@macroscripts If you know the list. You could loop through the whole list and compare the item
 
for( var i = 0; i < arr.length; i ++){
   if( a === key ){
      return true;
   }
}
return false;
that should do it no ?
 
function contains(array, item) {
    return array.indexOf(item) >= 0;
}
 
hehe so simple thanks
 
MLM
I was thinking you wanted to know if it was in an array, without having access to the array.
 
8:24 PM
@MLM How could you not have access to the array?
 
@darkyen00 ew
 
MLM
Not know of. Some user or 3rd party script
 
@AwalGarg .contains is ES 7
 
@darkyen00 indexOf is what, ES3?
 
!!mdn Array.prototype.indexOf
 
ES5
 
@AwalGarg indexof returns index not checks if exist ;-)
 
@darkyen00 and if there is a negative index, it doesn't exist ;)
 
4 mins ago, by Retsam
function contains(array, item) {
    return array.indexOf(item) >= 0;
}
 
if (![].includes) {
  Array.prototype.includes = function(searchElement /*, fromIndex*/ ) {
    if (this === undefined || this === null) {
      throw new TypeError('Cannot convert this value to object');
    }
    var O = Object(this);
    var len = parseInt(O.length) || 0;
    if (len === 0) {
      return false;
    }
    var n = parseInt(arguments[1]) || 0;
    var k;
    if (n >= 0) {
      k = n;
    } else {
      k = len + n;
      if (k < 0) k = 0;
    }
    while (k < len) {
      var currentElement = O[k];
includes not contains.. sorry
 
8:28 PM
Did someone hijack darkyen's account or what?
 
!!> "".indexOf.call([1,2,3,4,5], [2,3])
3
 
@copy 2
 
Neat
 
very neat.
 
!!> ([1,2,3,4,5].toString()).indexOf([2,3].toString())
 
8:29 PM
@rlemon -1
 
@AwalGarg indeed i have hijacked his account.
 
@rlemon 2
 
^^^^ what copy's code is doing for anyone interested
 
Ah, fucking JavaScript
 
@copy ?
 
8:30 PM
@rlemon I've wanted to make a domino game for a while, kind of like Phun but 3D
 
Just to keep in mind:
!!> "".indexOf.call([1,"2,3",4,5], [2,3])
 
@AwalGarg 2
 
but still neat
 
@AwalGarg it isn't a problem. you just have to understand how arrays are coerced into strings. and then not do that ;)
 
@AwalGarg 2
 
8:32 PM
@rlemon agreed, problem ain't the right word.
 
!!> [1,2,3,4,5] + [,6,7]
 
@rlemon "1,2,3,4,5,6,7"
 
!!> [1,2,3,4,5,] + [6,7]
 
@rlemon "1,2,3,4,56,7"
 
this is more interesting imo
 
8:33 PM
:D
 
what is that common alternative to codepen that i see used around here pretty frequently?
 
and more useful to know (albeit, it is pretty useless)
@PatrickQ jsfiddle.net
 
thank you much!
 
@rlemon WTF...
 
@PeeHaa it converts the left side into a string, then the right
 
8:34 PM
And trailing comma is ignored
 
^^^ I was getting to that ;)
 
@rlemon "1,2,3,4,5"
 
m59
Any of you guys using proxyquire? Isn't that the only way to avoid breaking the Law Of Demeter in node?
 
ohkay. I see that now still stupid :)
 
because JavaScript.
I read somewhere that some old browsers throw an error for that trailing comma.. I think.
 
8:35 PM
@m59 I've used proxyquire before, not extensively.
It's pretty neat.
 
@AwalGarg Only old?
 
m59
In other words, it's proper for things to require what they need rather than having them passed in (in most cases), because otherwise something is requiring a service it doesn't need as to be able to pass it to something that does.
 
yep
lemme find the link, in case I understood it incorrectly.
 
@Zirak Good, I was about to work but you saved me
 
8:37 PM
IE8 throws for the trailing comma
 
@copy Always a pleasure to help
 
I thought FF would also do that?
 
ok, it is for objects: stackoverflow.com/q/7246618/3459110
I guess it would hold for arrays as well
 
!!rum and coke or beer
 
@rlemon rum and coke
 
8:39 PM
more than one trailing comma is terrible.
 
8:51 PM
@AwalGarg (@PeeHaa) IE8-
 
Huh, a "correct" solution to the "".indexOf.apply([1,2,3,4], [2,3]) problem turned out to be an interesting recursive problem.
function checkSequence(array, sequence) {
    if(!sequence.length) return true;
    if(!array.length) return false;
    return array[0] === sequence[0] && checkSequence(array.slice(1), sequence.slice(1));
}

function indexOfSequence(array, sequence) {
    if(!sequence.length) return 0;
    if(!array.length) return -1;

    if(checkSequence(array, sequence)) {
        return 0;
    }
    var indexOfRest = indexOfSequence(array.slice(1), sequence);
    return indexOfRest === -1 ? -1 : 1 + indexOfRest;
^ Best I could come up with.
 
wat
What are you trying to do?
 
Find the start index of one sequence within another array. Like "".indexOf.call([1,2,3,4,5], [2,3]) //returns 2 but without the string conversion pitfalls.
 
Thank you all. I solved the issues and made a working script.
 
@Zirak hangouts ?
 
9:01 PM
I g2g in ~1 hour, but sure
 
@Retsam dude.... use Array.prototype.reduce.
 
@Zirak
 
@AwalGarg I was deliberately solving it recursively, if that's what you mean.
 
@Retsam reduce is also a loop...
 
@AwalGarg I know. I didn't want loops because I was doing it recursively. That was the point.
 
9:04 PM
k.
 
Does anyone know anything about Karma?
@AwalGarg Haha
Oh you were serious
 
ok.
 
I am using bootstrap and with the dropdown menu, I have a little badge that displays the number of pending notifications. Upon clicking the dropdown, I want to run some code in addition to the dropdown being shown. Problem is, if I add an a click event handler, then my custom piece of code is the only thing that executes, because that code overrides the default event (set by bootstrap js file to open the dropdown).
Anyway to extend the dropdown click menu and execute my code too?
 
@Starkers You've already posted your question in here multiple times; if you didn't get a response the first two times, I'm skeptical that you're going to get a response a third time.
 
@Retsam I'm not posting my question
 
9:10 PM
Why would they name their project religiously?
 
Okay.
Because it's a cool name?
 
Ok, so i'm not allowed to ask a quesiton on stack overflow, but i need to know is it possible to attach a promise to a self executing anonymous function, and if so, how may i do that?
 
@r3wt Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@Caprica Six ok thanks, i am reviewing the rules
 
Does the HTMLFormElement have anything similar to :focus css pseudo class?
 
9:15 PM
$('formselector > *:focus').length
i made a fiddle for my problem, if you can help me understand the promise api would really appreciate that.
 
@r3wt You use Promise.resolve() to construct an already resolved promise, not new Promise(), and you can call .then directly on the returned promise.
.done is a jQuery-ism; your fiddle isn't using jQuery promises, it's using the ES6 promises browser implementation, supported by Chrome and Firefox, I think.
 
@Retsam ew done
 
@Retsam thanks man. first timer with promises.
 
@r3wt No, that's now how you do it.
32
Q: How do I convert an existing callback API to promises?

Benjamin GruenbaumI want to work with promises but I have a callback API in a format like: 1. DOM load or other one time event: window.onload; // set to callback ... window.onload = function(){ }; 2. Plain callback: function request(onChangeHandler){ ... request(function(){ // change happened }); 3. No...

@Retsam that's as incorrect :P
 
should i call the promise done inside the last iteration of the for loop?
erm, resolve i mean
 
9:27 PM
@r3wt read that post I just linked to - it explains how to convert a callback API to promises.
 
m59
Hey guys, I'm wondering what the proper architecture is for the 400 status code
Say api/stuff is going to be handled by function foo
 
@BenjaminGruenbaum Yeah; forgot to mention that there wasn't any wiring between the setTimeout and the Promise itself. I just fixed the obvious syntax issues.
 
m59
and foo will throw an error if the parameters passed to it are bad or missing
how does the thing that calls foo decide to send 400 rather than some other error?
 
@m59 try/catch and have foo throw an exception if the parameters are invalid?
Throw a subclass of Error instead of an Error
 
m59
Cool, that's one of the way I had in mind.
 
9:29 PM
@BenjaminGruenbaum holy crap thats callback hell for me
 
@r3wt what's callback hell (in this context)?
 
me getting confused about the execution flow
 
22
Q: Aren't promises just callbacks?

Benjamin GruenbaumI've been developing JavaScript for a few years and I don't understand the fuss about promises at all. It seems like all I do is change: api(function(result){ api2(function(result2){ api3(function(result3){ // do work }); }); }); Which I could use a librar...

 
@r3wt What is your intended execution flow? Do 90 things, then call the resolution once they're all done?
 
yes
its just for a test function, so i have no events to hook into
 
9:32 PM
Ah, you can use Promise.all
 
@r3wt You're going to want to create a Promise for each of the 90 things, then use Promise.all to control attach logic for when they're done.
 
Today is a good day for me. All my css is looking clean, and cross-browser :D
 
i think i just need to read some more about it. i clearly am not understanding it
thanks for your help guys
 
@BenjaminGruenbaum thanks sir
 
9:34 PM
@AwalGarg [Sir](http://sir.urbanup.com/2647129) A way to address a male, since females tend to take offence.

A respectful greeting
@AwalGarg Nothing in that index. The last one is:
[Sir](http://sir.urbanup.com/3723455) A male whom is cool and a ladies man.
Also a polite way of addressing a male gendered person.
 
m59
app.post('places', function(req, res) {
  foo(req.body.stuff).then(function(result) {
    res.json(result);
  }, function(err) {
     if (err.name === 'ArgumentError') {
       res.status(400);
    } else {
      res.status(500);
    }
     res.send();
  });
});
@BenjaminGruenbaum that? ^
 
@m59 bluebird has typed catches
So if it's bluebird - it can be easier
 
m59
It isn't clear.
 
Generally - that's the idea, though you can extract it into a function and pass the function
 
m59
How would the routing code there know about ArgumentError?
 
9:42 PM
app.post('places', function(req, res) {
  foo(req.body.stuff).then(function(result) {
    res.json(result);
  }, errhandler(res));
});
Or something like that
You can of course generify it further
 
m59
Yeah, I see what you mean there.
!!> throw Things;
 
@m59 "ReferenceError: Things is not defined"
 
m59
That's what I don't know how to handle.
 
var oldPost = app.post;
app.post = function(a, handler){
    var wrapped = function(req, res){
         var result = handler.apply(this, arguments);
         Promise.resolve(result).
                     catch(ArgumentError, function(e){ res.status(400); res.send(); }).
                     catch(function(e){ res.status(400); res.send(); }).
    };
    var args = [].slice.call(arguments);
    args[1] = wrapped;
    var res = oldPost.apply(this, args);
};
@m59 something like that in general
 
Hola guys
 
9:46 PM
This would let you do:
 
m59
Yeah, np there, but where does ArgumentError come from? It will be undefined.
 
function ArgumentError() {};
ArgumentError.prototype = Object.create(Error.prototype);
 
m59
My mind is saying this (seems wrong):
`var ArgumentError = require('../errors/ArgumentError');` in both files
 
Yeah, although it can subclass a more generic error type, and then you only have to include that.
 
m59
Oh, heh, well I guess not so wrong, then! I've just never seen that before....
 
9:48 PM
app.post('places', function(req, res) {
  return foo(req.body.stuff).then(function(result) {
    res.json(result);
    res.send();
  });
});
 
m59
I mean, all the code I have ever seen is just throw('the things')
 
If you override .post like above, and return a promise - if the promise is rejected you can centralize error handling.
So you get error handling for free since promises are throw safe - your global error handler (which you declared in your overriding .post catches resolution errors and automatically returns the status code based on that.
It's not a one size fit all - it's just one way to approach the problem... now imagine Node did that on its own :D
Letting everyone know I kicked user3027531 for pinging me 3 times in a row without response and for asking his question 3 times in a short time span.
Please, read the rules.
 
@user3027531 He said no. No means no
 
See you in 5 :)
@copy how's Germany? Christmasy?
 
10:01 PM
That describes the world outside of my apartment well
 
(See deleted message above that)
 
@BenjaminGruenbaum hi!
 
@phenomnomnominal Hi Craig.
 
What happens if you try to kick a RO?
 
I donnu, what happened @phenomnomnominal ?
 
10:02 PM
Same as a regular user
 
My neighbours are funny. One of them threw away a plant that was in the hallway (it was stinking anyway), but it was the heirloom of another neighbour
 
@Zirak READ THE CHAT OMG
 
READING IT OMG
 
@Zirak Apparently deleted messages are not shown in the transcript any more
 
10:06 PM
@BenjaminGruenbaum :)
 
I am trying to load my js with $.getScript("js/jsfile.js"); but sometimes it doesnot load and keeps on loading any idea how to put timeout on it so the ajax request gets re initiated? In firebug it shows that the requested jsfile with $.getScript("js/jsfile.js"); is on loading and the loading doesnot stop there. I have to refresh the page or click on the link again to reload the js again properly. Any suggestion how can this be fixed?
 
can i use javascript .getTime() method or Date.now to get a unique ID which can be used in the database?
 
@JoeSaad only if you know you're never going to get two transactions at the same time.
So no.
 
And good night here too
 
10:09 PM
@phenomnomnominal i'm going basically to use Date.now + Math.random()
 
Third time's ice cream.
 
Hangouts works pretty well on android, I have to say.
 
@JoeSaad What if two clients make the same request at the same time?
 
@Zirak you're still sexy
 
it's only two computers which are going to use that small application
they won't get the same random number
 
10:09 PM
@FlorianMargaine rawr
 
Date.now + Math.random() + Math.random()
 
If you want something that's usually random use uuids
 
can javascript use uuids
 
Yes sir
Look up node-uuid, it works client side too
And if you use browserify, using it is very simple
Cya
 
@rlemon I dare you make a meta.stackoverflow Q&A on how to pick up chicks on stackoverflow using rep.
7
 
10:16 PM
browserify? i have to look this one up
 
m59
@BenjaminGruenbaum is there or would it make sense for there to be some collection of error classes on npm?
I don't see anything like that, but it doesn't make sense to me, though simple, to make a ArgumentError file in every project ever :)
 
the prob with uuid is that it has characters in it
i want only numbers
 
@m59 there was one, not sure what it was
 
@BenjaminGruenbaum Jon Skeet will get all the chicks then :(
 
@AwalGarg I have more points in the promise tag than Jon Skeet, just sayin
 
10:23 PM
dat no matter. Chicks don't see if you have a euro or two dollars.
 
@AwalGarg wanna see my jQuery silver badge?
 
@BenjaminGruenbaum eww
 
@AwalGarg it's all Jake now
 
:D
He doesn't seem to have a gold badge in javascript, which many do! :P
owwait, I have 93 points in the javascript tag :O
 
Guys, is it possible to use npm install to install my own library/project without having to deploy it to the public NPM repository?
 
10:28 PM
@SecondRikudo oh this please!
 
@SecondRikudo yes, iti s
 
how?
 
@BenjaminGruenbaum Is it practical to do so?
I mean, bower lets me simply specify a git repo to install
 
Why so complicated :(
 
10:30 PM
Replicating the entire npm database is hardly practical...
 
^
I think we just have to get the db design and stuff, and not the packages in the db.
 
@AwalGarg But then without special configuration, you won't be able to read the publicly published packages...
If I understood what they say correctly
 
@SecondRikudo don't replicate the whole thing -_-
i don't want my package published in the official registry. it's private.

Set "private": true in your package.json to prevent it from being published at all, or "publishConfig":{"registry":"http://my-internal-registry.local"} to force it to be published only to your internal registry.
 
@SecondRikudo I think not.
Sidenote: I really like this thing in some websites - no capitalization.
 
@BenjaminGruenbaum And then how do I tell npm install to get it if it's not published...?
 
10:34 PM
Capitalization of first letter of the sentence should be removed entirely, imo. It is technically useless.
 
@AwalGarg I don't. It feels weird.
 
@SecondRikudo why?
 
Purely because I'm used to it.
 
I am also used to it, but I am more open to new things.
 
10:35 PM
@AwalGarg Citation needed
 
@copy Why would I provide a citation for "my" opinion?
 
Technically
 
@BenjaminGruenbaum doesn't look like that private but...
@copy what is it useful for, then?
 
For the reading flow
 
no
hello gentlemen! vs Hello gentlemen!
there is punctuation, for the reading flow.
 
10:39 PM
@AwalGarg Capitalization is the difference between: "I helped my uncle Jack off a horse" and "i helped my uncle jack off a horse"
 
@AwalGarg …
And you're using both punctuation and capitalization wrong
 
> of first letter of the sentence should be removed
 
A_l
how can I initialize few variables with the same value?
i want 5 variable will be a function
same function
 
@SecondRikudo if i was you i'd keep that story to myself
 
@A_l var a = b = c = d = e = function() ...
 
10:40 PM
@SecondRikudo what is wrong with the latter?
 
A_l
thanks!!
 
a = { foo: function(){}, bar: function(){} };
 
@AwalGarg I don't like jacking off horses so much, but if that's your thing, go ahead.
 
@SecondRikudo :p. I meant what is wrong with "i"?
Why capitalize "i" to "I"?
 
@SecondRikudo your example is invalid, because in the first example it would be a run on sentence Technically
 
A_l
10:42 PM
and another thing if I want function by it's string name. and this function is not in the global. I mean if I have function name(){} and I have str='name' I want to do something like str();
 
@A_l this['str']()?
 
@AwalGarg Not in the global
 
A_l
this will wrork also If I am in nodejs?
and this is a moudle
 
@A_l what are you trying to do?
 
^^^
@SecondRikudo solved
 
10:43 PM
@AwalGarg Not really...
 
@SecondRikudo weird problem, weird solution.
 
A_l
I have list of string. this string is names of functions.
 
:P
 
A_l
I want to start all of them
and not use if or switch
 
hmm, i should try to skip all capitalization for a week and see what happens.
 
10:44 PM
@A_l That's the "how"
 
self executing anonymous functions?
 
What are you trying to do?
 
@SecondRikudo trying to PHP in javascript, ofcourse.
i should also make a userscript that would .toLowerCase() any capital letter at the beginning of the sentence.
 
10:58 PM
@SecondRikudo so many globals
 
So many goats
 
why is everything inside noscript a textnode?
<noscript><div id=yoMama>soFat</div></noscript><script> el.cl('noscript').firstElementSibling===null; //true</script>
nvm, got it
 
@rlemon Definitely.
 
@rlemon About your previous question: Definitely, just use my jqueery plugin $.fixBody
 
@rlemon yeah saw that but i already own it :/
got it for free with my video card
 
11:31 PM
Are there some angular geeks here?
 
I'm a geek, but pretty un-angular
 
back
 
forth
 
I need regex help. Here is my attempt: /(\.\s+[A-Z][a-z]|^\s*([A-Z])[a-z])/gm
It matches this:
AbC
But, it should not.
Any idea?
 
It matches that, or it finds a match in that?
 
11:34 PM
$ at the end?
 
It should match Ab if I understand it
 
@KendallFrey It finds a match in that, yes. But it should not.
 
Why not?
 
@KendallFrey No I mean, I want to change the regex so that it does not.
 
If you explain your problem in terms of erroneous code, your question is by definition erroneous.
@AwalGarg /(?!)/
 
11:36 PM
/(\.\s+[A-Z][a-z]|^\s*([B-Z])[a-z])/gm
 
That won't match
copy's as well
 
@AwalGarg Change your regex to /hodor/gm. That won't match AbC.
 
three valid answers so far
 
umm, no. Lemme explain.
 
You should have done that before
 
11:40 PM
If a capital letter is found ahead without encountering any space, it should not match anything. So "CsmallettersC" won't match anything, but "Csmalletters C" should match "Cs" and capture "C".
@KendallFrey ^ @copy ^ @Retsam ^
 
So, you want to match any series of lowercase letters and a preceding uppercase?
\b[A-Z][a-z]+\b
 
shit that makes sense. yes.
Thankyou @KendallFrey, it works!
 
AArrrrrrrrrrr
 
hmm, now I need to modify the node traversal adapter I made last night
 

« first day (1528 days earlier)      last day (3420 days later) »