« first day (1521 days earlier)      last day (3428 days later) » 

11:01 AM
@FlorianMargaine sorry to bother but myVar[idTarget] == '1' this worked :) turns out the value of idTarget was wrong.
 
#2 in the network-wide ranks now :P
 
@Cerbrus You're the one spending the most time chasing hats on SE and you pretend you don't have time to play a few games in the Tribo World Cup ? :\
 
Sorry, but I kinda lost interest in tribo... :-/
 
@FlorianMargaine My money's on last year's #1.
 
0
Q: Is it possible to set a proxy server with JavaScript/jQuery?

minimenI'd like to set a proxy for some reason. But how do I do that with JS or jQuery 1.11.1? The $.proxy() method is not that what I want.

 
11:12 AM
I'd appreciate not being laughed at for this question: I have a collection of nodes(?) with querySelectorAll(), what's the correct way to attach and event listener to all of the matches? Should I loop through them and attach each listener individually? Not sued to doing this as jQuery has previously been taking care of this for me!
 
@Dan The same event?
 
@SecondRikudo who was...?
 
@dystroy tell him to try $.fn.proxy
 
[].forEach.call(document.querySelectorAll("something"), function(node){ node.addEventListener'('someEvent', function(){...
 
@FlorianMargaine LoganM
> The $.proxy() method is not that what I want.
 
11:14 AM
@SecondRikudo Yep, when a button is clicked the script will need to take into account parents and siblings, but essentially it's the same function.
 
Never heard of him
 
@Dan You could loop and add event listeners if there aren't too many.
If there are many elements or you may want to add eligible elements live, use event delegation.
 
@SecondRikudo So if there were many, say 100+, would I attach the listener on the document and filter to see what was clicked?
 
@Dan Correct.
 
@dystroy Is this code "borrowing" the forEach method from the array prototype?
 
11:15 AM
@Dan Correct.
 
@Dan yes
 
@SecondRikudo Ah, this is a revelation of sorts to me. Would you always do this "filter" thing when dealing with a large amount of elements/events?
 
In the future we'll have Array.from() to convert array-likes to real arrays
 
ES6 has Array.forEach
@SecondRikudo Array.from
 
@Dan Don't delegate too often if you don't dynamically add elements, it's costly and more complex
 
11:16 AM
@Dan It depends, what @dystroy just said ^
@mintsauce Right, thanks
Got mixed with isArray.
 
np
And Array.of, but that's more niche.
 
@SecondRikudo In some ways it seems a bit crazy to filter through potentially many functions when the document is clicked. You've got to understand mu position so far: I can use getElementByID() and jQuery has been taking care of classes and stuff..
Because my admin area only needs to be IE8+ I'm starting to write more vanilla jS, because it's "safer"..I think...
 
It's not safer...
 
Well, safer to use certain methods which don't exist pre-IE8.
I was going to use getElementsByClassName() and realised it's IE9+
 
That's easy enough to shim.
 
11:21 AM
For now I'll use the loop though, as none of this is dynamic. the [].forEach.call() looks great to me.
 
@Cerbrus Congrats on your #1 spot :)
 
hey does anybody has experience with SVG elements and adding/removing classes in IE without jquery?
 
@RalitsaNikiforova 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.
 
@Dan: yeah, or [].slice to convert into an array.
 
@mintsauce To clarify, this would turn a nodeList (?) into an array?
 
11:24 AM
Yes.
 
That's great, thanks. All great info'
 
Array.from = Function.call.bind(Array.prototype.slice); // if you don't abuse it
It's sad that Array.from has to even exist, but that's history for you.
 
ADG
hey i have a little prblem, I need to output 15!=1307674368000 strings what should I do?
 
@ADG Depends, have a bit of time on your hands? Like say, several years?
 
ADG
seriously do you think it'll take that much time?
 
11:32 AM
To output 1307674368000 strings, it wouldn't surprise me honestly
What do you need to do?
You're trying to output all string combinations?
 
ADG
permuattaions of a string
 
For what scope? You mean to find a particular permutation?
 
ADG
of say ahggasdghajdsjgdhlasgdjhasgk (think there are 15 letters)
 
If you don't output the strings, it'll go much faster
 
123456789012345
 
11:35 AM
It may still take a long time though
 
Those are 15 characters ^
 
@SecondRikudo Some are repeated though, it'd have to be more like 0123456789abcde
 
@Neil I'm not aware of the context :P
 
ADG
would you like to see my code?
 
@SecondRikudo All permutations of 123456789012345 wouldn't be 15!, it'd be more like 15!/2^5
@ADG Still trying to understand the point :P
More important than code
 
ADG
11:38 AM
my ide says "too much output to (a word i am missin)"
 
Yes, but what is the point? Why would you need to print out all permutations of a string?
You trying to brute force a password (not that it is any of my business)?
 
ADG
i am trying to find no. of strings that follow a particular property for a maths question @Neil
 
@ADG Please describe the problem, you aren't clear.
 
ADG
i have a string for example "aaaaabbbbbccccc" i want to find the no of strings that have no two letters of same type adjacent to each other.
@Neil actually 15! seconds=41438.5853 years
@SecondRikudo am i clear now
 
@ADG I think the result would be something close to 2^15 (32768)
Because it's a tree-like structure
  c<
a<
  b<
 
ADG
11:51 AM
@Second maybe i should adopt an intelligent way?
 
Where each node always has 2 options
I'm not a math expert though, @BenjaminGruenbaum is your best bet.
 
Thanks, @Neil
 
Oh yeah that's a counting problem.
 
@BenjaminGruenbaum Given a string AAAAABBBBBCCCCC find all permutations where there are no same letters adjacent.
Or rather, find the number of permutations where...
 
11:53 AM
Yeah, number, finding all is expensive :P
You can solve it with inclusion-exclusion but that'd be kind of ugly
 
ADG
@second I understand what you say, I thought that once but if you start at (0,0,0) and adopt one step in any of the 3 directions(consider 3d) you will reach (x-5)(y-5)(z-5) not (5,5,5)
 
Actually, it's pretty simple to solve
With inclusion exclusion like that - if you can use code.
Otherwise you end up with a mathematical expression which isn't fun to simplify.
 
ADG
see this for more info
 
PermutationsWithNoAdjacentLetters = AllPermutations - (PermutationsWithAA + PermutationsWithBB + PermutationsWithCC) - (PermutationsWithBothAAndBB + PermutationsWithBothAAndCC + PermutationsWithBothBBndCC) + (PermutationsWithAAAndBBAndCC)
@ADG that's your formula, all of those are rather easy to calculate
@ADG Here is the general technique. Useful to know
 
Is there a service which can make my code cross-browser by automatically identifying the things which need shimming and adding them?
 
11:58 AM
When people say cross-browser you usually mean "also works on IE" since most of us don't use features that don't work on FF Chrome and Safari the same way anyway since most of what we need is either very experimental anyway or already does.
 
@BenjaminGruenbaum opera mini
 
And when you do write cross-browser code for IE9+ for example you usually use libraries that normalize this sort of stuff
Opera Mini still runs on presto lol, didn't realize that.
 
Shimming for Opera Mini is more difficult than for IE9.
And really a lot of people use that crap browser.
Specially in India.
 
Then no - there are no automatic tools for that afaik.
 
ADG
@BenjaminGruenbaum but that's 15!/5!^3-3*(??)+(??) you just can't calculate the last two
 
12:03 PM
o_O Are you doing P&C?
 
@ADG yes you can...
 
Guys, if I can get 2 more upvotes on this answer, I get a silver badge -> another hat :D
23
A: HTML5 canvas background image repeat

CerbrusUse the canvas' createPattern function var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"), img = new Image(); img.src = 'https://www.google.nl/images/srpr/logo3w.png'; img.onload = function(){ // create pattern var ptrn = context.creat...

Shameless, I know xD
 
wtf you have like 12 badges already :O
 
ADG
@BenjaminGruenbaum try finding it
 
I have one answer at 24 and 2 at 23 but they'll get there.
 
12:05 PM
@BenjaminGruenbaum I have one at 47 :P
 
@Cerbrus How are you planning to get the gold?
 
No idea
 
Asking for even more upvotes
How many do you need? 50 or 100?
 
@ADG I have, I've found it, however I feel like I've already thrown you a clue and you should attempt to solve it yourself. There are plenty of examples of inclusion exclusion that describe very similar problems.
 
12:06 PM
@SecondRikudo Oh.
ah, 100, not 1000 :p
 
@Cerbrus you could go for Reversal
 
I don't want to do your homework and I don't think solving it for you right now would help you learn.
 
Yea, that's not gonna happen xD
 
I got a secret hat \o/
 
+20 answer on -5 question
 
12:07 PM
hmm
 
You can get that one on meta if you are observant enough
 
ADG
@BenjaminGruenbaum you'll think it's 15C2*13!/(5!^2*3!)
 
I just got a "fascinating" hat. What's that about?
 
Why is the secret hat not appearing here in chat? :(
 
ooh, same one
Any idea why you got it?
 
12:08 PM
@BenjaminGruenbaum no idea :/
I can get a lot of hats easily on sites like Hinduism and Area51. It is very very easy on Area51 :D
 
@BenjaminGruenbaum: Upvoting a answer with lots of upvotes
 
@Cerbrus oh cool
lol, you have all of them :P
 
ADG
???
 
Hehe
 
@Cerbrus Brb, finding a Jon Skeet answer
 
12:10 PM
@Kippie ahahaha
the triage queue is empty because everyone wants to complete there 10 reviews ASAP and get the hat :p
 
@AwalGarg They should go to close queue
 
Seriously, though, it looks like he has a bunch of stalkers that automatically upvote everything he answers
 
@SecondRikudo why?
 
Because there's 9k questions there?
No need to compete
2
But I guess Triage is lower on the rep requirement
 
haha, not errbody got the close vote privilege though :p
 
12:13 PM
if I raise 243 helpful flags, I'll get a gold badge :P
 
@Cerbrus It's actually possible.
On Stack Overflow I'd even say it's not that hard if you put enough time into it.
 
-5
Q: How to gain the time lord hat (winter bash)

Paco AbatoFor the new Winter Bash feature I've seen a time lord hat that is an image of the Tardis (from Doctor Who show). In the description it says that it is a secret. If it's not abuse, I would like to know how to get it.

Upvote for reversal please xD
That, is, upvote the answer xD
Hm, Chameleon --> change profile pic...
let's see
 
I'll probably get gold for this so that's one badge.
I think there are a few more
 
Oi, @SecondRikudo!
 
@Cerbrus If my suspicions are correct, I should get the Time Lord soon.
 
12:18 PM
I don't think I'll go hunting this year though like I did last year
2
 
Don't be messing with my answer mon :P
lemme know if you did
2
Ugh, that question needs to stay below -5
 
@Cerbrus Ah, no hats in metas
Hold on
 
I just got my silver badge, so a hat soon :P
Hhahahaha
I'm seeing top tier users in the rankings with gravatars
@Cerbrus change your profile image. I have chameleon on SO without creating any new account :) — Infinite Recursion 6 mins ago
related?
 
ADG
@BenjaminGruenbaum i guess that would be "15!/5!^3-3*((15choose 2)*13!)/(5!^2*3!)+((15 choose 2)*(13 choose 2)*(11 choose 2)*9!)/(3!^3)"
 
12:23 PM
@BenjaminGruenbaum da hell? @Cerbrus
 
I'm not sure - would you like us to downvote that? Is that intentional?
 
You can delete that answer and get a badge :p
 
No, @Cerbrus
Peer pressure
 
I wanted 1 downvote there, yea
and I got it
 
12:24 PM
Yeah, 6 times :D
 
It was on -4 already
 
ADG
@BenjaminGruenbaum and that isn't 7188 please tell how to get that?
 
Do hats work in chat as well? Because I'm not seeing any
 
I got 5 hats now \o/
 
@Kippie on chatwindow yes... on userlist no it doesn't
 
12:28 PM
I can't answer that :
1
Q: event loop model in javascript

Aljoša Srebotnjakbased on: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/EventLoop stack frame is empty before next event is processed. So why in folowing snippet alert displays 1 instead of 0 because alert function should run before callback var a=0; var b={}; $(b).on("event", function (){ a...

What am I missing ?
 
@dystroy Technically can't answer? As in the site won't let you?
Because I can apparently.
 
No : I think it's a good question : why does it alert 1 ?
 
Oh, like "I don't know the answer" kind of "can't answer"
 
yes
From the MDN on dispatchEvent :
> Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order
what's a "appropriate order" ???
 
Because it's jQuery
 
12:31 PM
@dystroy am not sure if that follows with jQuery...
 
@BenjaminGruenbaum I tested with dispatchEvent, it's sthe same
 
Can't top that.
 
Looks like jQuery custom events fire sync
 
12:33 PM
@dystroy yeah, just tested too with:
    var a = 0;
    var b = document.createElement("div");

    b.addEventListener("click", function (){
      a++;
    });
    b.click();
    alert(a);
Seems like MDN is quite simply wrong.
 
Looks so. events not involving anything outside JS might not be always asynchronous
 
@Cerbrus Wait, aren't you at work?
 
@BenjaminGruenbaum I think this is quite the expected behavior... no?
 
@AwalGarg No, the entire idea of events is that they are async.
 
@AwalGarg Just a reminder : you're expected on the TWC1 ;)
 
12:35 PM
@SecondRikudo dammit yes.
 
I also don't like that some events might be synchronous :(
 
hi all, how do i scroll to an offset Y using jQuery?
 
They aren't async, they can be async. It's just a handler that gets called when something happens, if you call it yourself, then obviously it's going to be synchronous. Isn't that to be expected?
 
@SecondRikudo That's not the idea of events :P
They can be async, but I don't think it is a requirement
 
@martynas Have you tried googling?
 
12:36 PM
0
A: event loop model in javascript

Benjamin GruenbaumLet's ignore the fact you have jQuery events here and not native DOM events since this reproduces with native DOM Events has dystroy has shown in his comment. Simply put MDN is wrong. Quoting the DOM Events specification: Events which are synchronous (sync events) must be treated as if they...

@dystroy
 
I think it is because of the manual triggering if the event.
 
@AwalGarg I think you're right
 
^^ That is what makes it synchronous in the current event loop iteration.
 
IIRC, I have discussed this with Zirak previously. As always he linked me to the spec.
 
@dystroy TWC1?
 
12:37 PM
@dystroy :p
@SecondRikudo tribo world champship one
 
@SecondRikudo It's a Miaou thing : the Tribo World Cup One
 
@Neil SEE EVERYBODY??? THIS GUY AGREES WITH ME FUCK YEEAAAHH!!
 
@AwalGarg Lets not get carried away, now. ;)
 
:P
everyone post some interesting stuff so I can star it and get the hat :p
 
12:50 PM
Hey dudes
Have any of you ever used DropzoneJS?
 
@sippy_bizzle not me
 
I dunno if I'm being retarded but I can't find the documentation for it anywhere
I'm being retarded
Although the website for it is also retarded.
 
@sippy_bizzle In the home page.
Scroll down
 
Yeah
Thank you :)
 
1:09 PM
LOL, I was such a noob in JS 2 and a half years ago:
2
A cleaner way to do this? jQuery — Benjamin Gruenbaum Jun 10 '12 at 16:32
lmfao
 
@BenjaminGruenbaum You just tripled my confidence in myself :P
 
I'll keep those comments up for a little for people to mock me and then delete them :D
 
Don't let SecondRikudo see it. He'll go on a jQuery-hating rant again
 
ahahaha
 
SecondRikudo was a noob in JS 3 months ago don't forget that :D
 
1:12 PM
@BenjaminGruenbaum really?
 
@BenjaminGruenbaum It wasn't 3 months ago
 
Sep 11 at 21:09, by Benjamin Gruenbaum
@SecondRikudo so does it work now mr. JS gold badge?
 
@Kippie And I don't necessarily hate jQuery. I hate it when people use it when they shouldn't.
 
You were still a noob back then, to be fair you caught up pretty quickly and I think you're a pretty competent JS developer now
 
It was me, who was a JS noob 3 months ago...
 
1:13 PM
Sorry, 3 months and 4 days my bad :D
 
@BenjaminGruenbaum Seriously? For a typo?
As if you don't make typos.
Who am I kidding, you're not human, of course you don't make typos.
 
That wasn't a typo common :P I'm giving you a compliment don't be a jerk about it
 
Now I am 0.1 times less noob than before.
 
As if anyone in here except you and @Zirak make typos!
@BenjaminGruenbaum =P
 
I never make Tpyos
 
1:15 PM
I remember once, I wrote 300 lines of JS, straight without stopping for some feature of some kind. I ran the code, it worked perfectly. I ran JSHint, no error. I was proud of myself, that day.
 
When that happens I'm scared
 
console.log(1,

// ...

2);
 
yeah, I tested a lot.
 
Although JSHint would probably throw a warning about empty lines
 
@Cerbrus oh, you meant 300 lines in the middle
sorry, didn't get your joke.
 
1:18 PM
Yea :P
 
Folks, your advice.
 
I'm making an API to be used internally for my apps
But also, it would have a public facing endpoint.
 
I want internal apps accessing to it via localhost:1234 to not require authentication (and have god-mode access), and requests to the public endpoints to require authentication, and have access based on the user.
Can I rely on the X-FORWARDED-FROM header that nginx is supposed to add in the reverse proxy?
And also, how would you approach this in general?
(It's my first time writing a full blown REST API :P)
 
1:21 PM
lol what a horrible q and a stackoverflow.com/q/23465407/1348195
 
@BenjaminGruenbaum Considering closing it against my canonical.
 
@SecondRikudo by all means go for it
 
if your app has no other entry point than nginx, yes, you can rely on it. Make sure nginx overrides the header if it already exists though. I don't like the dependency on nginx though... I'd just make 2 app entry points, i.e. index-internal.php and index-external.php, and have 2 virtualhosts.
 
I downvoted the answers
 
Hm, anyone got some bounty-worthy answers?
 
1:23 PM
@FlorianMargaine I don't use PHP, I use Node
 
@Cerbrus Look at some of mine, I'd like to think that I have some high quality stuff.
If you don't find any, look at @tereško's top answer.
 
mine are funny but suck :P
 
@FlorianMargaine I have several node apps running on the same machine, and I use nginx as a reverse proxy to map them into subdomains
 
@SecondRikudo yeah... wondering if I'd make 2 apps
 
I think I would
 
I can only award it in 24 hours? o.O
 
@FlorianMargaine Two apps?
@Cerbrus Yup
 
@SecondRikudo yeah
the worst it could do would be forcing you to refactor so that you can use your code in 2 apps
 
That sucks
Still, now I'm only 1 hat away from having 2 more hats
 
1:26 PM
@FlorianMargaine I don't understand how two apps come into play, when the only thing that changes is the authentication scheme..
 
@SecondRikudo it's a big thing...
wait
 
@Cerbrus how come you have the "Gelt" hat o_0?
 
unless you mean the API is exactly the same, except one has every permission, the other has none
 
Yea, I just noticed that already can be obtained
 
@FlorianMargaine Exactly that.
 
1:27 PM
ah..
 
#11 here has it
 
One will never get 403, the other might.
 
My Node questions in the past couple of days have been really stupid, but I wanna show that it's paying off! I've learned stuff about npm, grunt, and general things about node's api, and stuff about express.
 
Oh cool I'll start a bounty on something
 
1:28 PM
@NickDugger did you learn about node-inspector?
@SecondRikudo got it.
 
Now to find an answer I 2.9
 
@FlorianMargaine no... what is it? lol
 
Or maybe I'll give it to one of Zirak's horrible jQuery questions :P
 
@NickDugger use chrome debugger on node apps
 
1:29 PM
Ooh, that would be helpful
 
That's actually pretty clever :D
 
@SecondRikudo yeah... I'd set a header in nginx indeed. Be careful to throw 403 if the header already exists though.
 
There you go, I'll leave it hanging for a week so you get more attention for your answer.
 
@FlorianMargaine Yeah, I mean. If I'm accessing locally, I won't add the header
So if the header exists at all, whether it was set by the user or by nginx, it will be there
At least that's what I'm thinking and hoping I won't be horribly hacked in a few months
 
@SecondRikudo yeah but if the user sets it, he has access to all your API... is what I mean
 
1:31 PM
Can someone please upvote
312
Q: What is clearfix?

H BellamyRecently I was looking through some website's code, and saw that every <div> had a class clearfix. After a quick Google, I learnt that is for IE6 sometimes, but what actually is the clearfix? Could you provide some examples of a layout with clearfix, comparing to a layout without clearfix?

Eh, second's answer there
 
@FlorianMargaine No, I'm checking to make sure the header doesn't exist
 
yep, we agree
 
If I access it via localhost:1234 the header won't be there at all
 
So if the user sets it, it will still exist, therefore, public endpoint.
 
1:33 PM
Aww now my rep shows -52 :/
 
@BenjaminGruenbaum Fix it.
 
Well, two downvotes for that "use jQuery" thing and a bounty so there's that :P
 
I know :3
Leading by 2 hats :D
 
Aww, I was #11 and now I'm #30 because people are actively hunting :D
 
1:38 PM
#2 has the waffle
I wonder how many bounties were raised today for the flag XD
 
I am number 133 :P Still great for me xD
@SecondRikudo All those who get the bounty ... oh yeaah!!
 
@KendallFrey nobody cares about KSP
 
@FlorianMargaine uh oh ..
Kendall he didn't mean it!
 
nobody cares about KSP
 
1:48 PM
cc @Loktar @SomeKittens
because fuck you, Florian
 
Man. Bacon, cheese and caramelised onion
nom
 
@Sippy Not a big fan of man in my cooking
 
@KendallFrey Sweet
 
@Neil faku niel!
 
1:50 PM
(I don't own it yet, but I've been considering getting it)
 
^_^
 
how would one create readable stream in node from array of integers, where each new chunk is new (just one) number from array
 

« first day (1521 days earlier)      last day (3428 days later) »