« first day (537 days earlier)      last day (4394 days later) » 

12:01 PM
slow morning?
 
@rlemon you can add some extra to the mousemove event
if( !(e.which & 1) ) {
//unbind mousemove
}
 
right now i'm mostly concerned about page resize bug :/
 
instead of the hacky document mouseup
but then the dragging will be much more robust :P
 
what does that code actually do
& 1?
 
bitwise and to see if the first bit is set
 
12:06 PM
what does that mean? "to see if the first bit is set" ?
 
no bits are set if no mouse button is held down while moving
so basically if neither left or right mousebutton is down, unbind the mousemove and stop the drag
before that I have always been using the document mouseup hack
 
cool
i'll check it out
 
Bitwise AND	a & b	Returns a one in each bit position for which the corresponding bits of both operands are ones.
Bitwise OR	a | b	Returns a one in each bit position for which the corresponding bits of either or both operands are ones.
Bitwise XOR	a ^ b	Returns a one in each bit position for which the corresponding bits of either but not both operands are ones.
I don't get it -_-
 
You need to think of numbers in binary
for example 3 is actually = 0000 0011
which means the 2 first bits are set
the 1's on the right
so now if we do 3 & 2... what is actually happening:
0000 0011 & 0000 0010
now we go through each bit to see the result
0 & 0 for the last 6 bits
so we have 0000 00xx
1 & 1 = 1
0000 001x
and then 1 & 0 = 0
 
so it returns 10 ?
 
12:12 PM
so it is 0000 0010 which means 2 in decimal
so 3 & 2 === 2
 
dafuq did I just do
 
what's wrong?
 
I think the html is fucked up
 
12:14 PM
@Esailija: thanks, really nice explaination :)
 
no i saw it
i moved the container size crap to the end but I ref the container size.
fixed!
 
@FlorianMargaine if you are on windows 7, you can use the default calculator in programmer mode to easily convert between hex, binary and decimal
it also has all the bitwise operations in that mode
 
@Esailija: if I understand correctly, 3 | 2 === 0000 0011 | 0000 0010 === 0000 0011 === 3
 
yes
 
nah it's alright, I can translate decimals into binary
windows xp has it too btw IIRC
confirmed
 
12:16 PM
but once you learn that you need to learn it in hex
 
in scientific mode, you can choose "binary"
 
because hex is used almost always
not decimal or binary
 
123456789ABCDEF ?
 
ye
 
12:17 PM
in javascript ( 0x03 | 0x02 )=== 0x03
though you need parentheses lol
cos the bitwise operation priority is really low that always catches me
 
@Esailija I still have to handle that whitespace at the end.
when resizing i'm ending up dragging the page down.
 
if( !(e.which & 1) ) means if NOT '1'
 
yea
if mouse not held down
 
why not use if ( e.which !== 1) ?
 
well it's a logical and bitwise operation mixed up
because that would return false when e.which === 3
e.which & 1 returns true for when e.which = 1 or when e.which = 3
because 1 and 3 both have their first bit set
 
12:20 PM
genius
 
so that means 0 and 2 are ok for e.which ?
 
2 means middle button and 0 means no buttons at all
 
it should be more robust than document mouseup flags because that sometimes bugs out and the mousemove won't unbind even if you are not holding down any buttons
 
so basically you're gaining a little speed (but hurts readability for me :p) just to replace if (e.which !== 1 && e.which !== 3)?
ok
 
12:25 PM
well it doesn't use bitwise flags so yes you could use that as well
I thought it would use flags from 1 to 7
like 111 would mean all 3 buttons are down at the same time
and 101 means left and right
but it only reports 1 at a time
 
yup, so it'd be || instead of &&
ok
now I'm starting to remember my course about boolean :D
I'm stupid for not remembering this :(
& is just the AND operator and | is the OR... -_-
 
yea
 
any use for the XOR operator?
:p
how faster are bitwise operators btw? Is it really worth it?
 
not for speed
in javascript they aren't fast because we need to convert from Double to (u)int32 and then to Double again
 
for what then? don't tell me readability :p
 
12:29 PM
for manipulating bits :P
 
hmf
stupid answer :p
 
for example, 32 true values can be represented by a single number
true/false
 
> 32 true values can be represented by a single number
 
or instead of mousestatus being like this:
 
12:30 PM
var mouseStatus = {
	button1: false,
	button2: false,
	button3: false
};
it can just be a single number between 0-7
0xFFFFFFFF = 32 true values :D
 
> it can just be a single number between 0-7
example?
 
var mouseStatus = 5
would mean 101
which would mean
true, false, true
for the object
 
oh
ok
reminds me of permissions on unix :p
 
7 = 111 = true, true, true
yes exactly
then if you wanna see at least mouse1 is pressed use mouseStatus & 1
mouse1 and only mouse1 = mouseStatus === 1
 
I just met a genius, who thought operator precedence only applies is there are brackets
Otherwise, left to right all the way!
 
12:34 PM
;o
 
which would mean that inside the object, it'd be var mouseStatus = function(nb) { var button1 = (nb & 1), button2 = (nb & 2) etc
 
yea button1 = &1, button2 = &2, button3 = &4
 
kkk, I get it
 
button32 = &2147483648 lol
 
lol
question about <<
say we're on 8 bits for the sake of the example
0000 0101 << 2 === 0001 0100
right?
 
12:37 PM
yea
 
but if I do 0101 0000 << 2, is it equal to 0100 0001 ?
 
No, why would it?
 
it's equal to 0100 0000 if you are doing it on a 8bit integer
 
if there is no more bits at the end, it doesn't go back at the beginning then
that's my question :)
 
You move right, shave off extra, pad with zeros
Of course not. Numbers aren't circles
 
12:39 PM
yes it's a shift not rotate
 
0
^ that one is
 
I see an eclipse at worst, zero at besr
 
also, say we're still on 8 bits integers, the last bit is the sign bit, so the sign can be changed?
 
bah, to that i scaleX(0.66)
 
yes it can
it's not special in any way, except in javascript where we have to use >>> for normal behaviour
 
12:41 PM
normal behavior?
 
in javascript we have <<, >>, and >>> instead of just << and >>
 
why? oO
 
because >> ignores the sign bit while >>> shifts it anyway
 
so >>> acts more like <<, moving the sign bit like it's a normal bit
i.e. normal
 
12:44 PM
ok
well, thanks a lot
I finally feel less ignorant about bitwise operators :p
and can even see a use for them :)
 
yep
 
mostly flags
 
how about that ~String.indexOf
 
screw you
 
or !!~String.indexOf
:P
 
12:46 PM
so
~ is not
String.indexOf means does the string exist
 
it returns -1 when value is not found
and 0 or more when a value is found
-1 is 1111 1111 1111 1111 1111 1111 1111 1111
so the not of -1 will be all zeros
 
it's not 1111 1111 1111 1111 1111 1111 1111 1110 ?
 
no that's -2
 
so 1111 ..... 0111 === -16 ?
 
Remember how you count back in decimals
 
12:50 PM
-9
 
ok
I don't get why, but well... why not
I mean, I see why, but it's not plain logic
 
back to !!~String.indexOf
~String.indexOf means 0 if it returns -1
 
yeah
 
!~String.indexOf means true then
and !!~String.indexOf means false
 
12:53 PM
yes !!~ ends up being false if no result was found
and true otherwise
 
if it's not -1, !!~String.indexOf returns true because (~ (>= 0)) > 0
 
ye
 
well well well. That was fun :D
 
! converts to Boolean, then negates. The second ! is to negate the negation
 
yup I already knew that, even though the hack is hard to grasp at first
 
1:02 PM
it's the epitome of elegance
:D
 
Aren't my hips the epitome of elegance? :(
 
no sry
 
1
A: Speed and memory benefit from declaring variable outside JavaScript loop?

tobyodaviescommented: @Raynos if anyone can write cross-browser JS without dozens of feature/browser detection tests and/or re-implementing most of jQuery that is clearer than the same features implemented with jQuery I'd be impressed. Browser compatibility is a big part of what makes vanilla JS ugly, that and the ugliness of DOM interfaces. It's easy to write vanilla JS that reads how you are doing something, it's much more difficult to make it read as a description of the result you get. jQuery does the latter reasonably well IMO.

Haters gonna hate
 
I liked the part of your answer that wasn't opionated jquery hate
:D
 
Didn't anybody say anything about hoisting?
 
1:15 PM
that question is just ridiculous
 
@Zirak: first thing I thought about... and no, there is no answer about it
 
he is frigging using functional iteration on a single element jQuery object and asking if declaring variables is a performance problem..
:D
 
I have an idea of question, I'm just wondering whether I should flag it as CW, or if it would be closed. I'd like to ask for practical examples that the new methods ES5 provides allows us to use with the DOM/browser etc
 
It's not even a worthy question on its own...people just want to "optimize" for the sake of optimizing
 
like for example [].forEach.call(NodeList, callback)
 
1:18 PM
all the iteration functions take any array like object
 
ES5 has nothing to do with the DOM
 
NodeList.forEach doesn't work tho
@Zirak: no, but it provides new handy methods
 
no because it's in Array.prototype, not NodeList.prototype
NodeList.prototype.forEach = Array.prototype.forEach
but it's better to just use .call
 
@Esailija: yup. So I was wondering if opening a question asking for examples of this kind would be closed
 
What does the dom have to do with it?
 
1:19 PM
@Zirak: it's what we use everyday.
"practical examples that ES5 new methods provide"
 
Yeah, but then you said DOM...maybe I just need sleep...
 
practical examples === ES5 methods to work with the DOM can be practical examples (like the forEach call on a NodeList)
 
[].filter.call( document.myform.elements, function(input){
    return input.type == "text";
});
 
uh, yeah, this kind :D
 
there is infinity possibilities
 
1:23 PM
I don't think so :/ Many won't be useful
 
map, reduce, filter, some, every
with those you can do anything and everything
 
List manipulations are indeed numerous
 
exactly, with these new methods, a lot can be done today. I'd like to see js code using this :) so having a community wiki with this can help people I think
 
well most people are just using the implicit jQuery iterations
 
but I can't ask a question as a community wiki
 
1:24 PM
when a question is not tagged jQuery (rarely) and it requires some kind of iteration of nodes, I always find a good way to use those
but in practice I am using jQuery to work with nodes
and dom
 
you can mix jquery with ES5 functions tho
 
yes but jQuery already has the methods... .filter, .is, .each, .map are already in jQuery
 
yeah, how slower are they compared to the ES5 functions?
I avoid $(this).attr('id') when I use jQuery, I'd be glad to avoid this kind of method too if possible :)
 
I hate how people promote games by putting females with giant boobs and even bigger cleavage just stacked in a window...
 
but did u still play it :P ?
 
1:32 PM
Female gear in games is ridiculous. The better it gets, the fewer it covers...no soldier would go "oh look, boobies!", but "oh look, weak spot!"
Bullet in the breasts, silicon leaking everywhere...it's a mess.
And there also needs to be a way to either sleep and do something else at the same time, or just get along with no sleep at all
 
<3 github's new auto generated pages
 
Anyway... Array.reduce is the best. Most building problems are solved with either that, or Array.map().join()
 
@rlemon: love'em too
 
GAAAHHH STOP HAVING THE CONTENT BE ONLY 30% OF THE PAGE
LESS FUCKIN WHITESPACE, MORE ACTUAL THINGS
 
also, did you know that if you point your domain name to github (and a CNAME file in your repo), ALL your repo use this domain too?
 
1:37 PM
If anything, these tests show that jsperf cannot be trusted at all. The results should be equal because the work actually done in the tests completely shadow nano optimizations such as variable declarations. -1 for you and everyone thinking this prooves anything – Esailija just now
 
ralt.github.com is one repo, ralt.github.com/My-small-library is another, and still both use the same domain name (margaine.com)
@Zirak: what I didn't know is that once installed for one repo, it worked for all the other
 
It's silly how people just blindly dump things into jsperf...most of these results are either contrived, non-relevant or subject to random flunctuations
 
wonder what that will do if I create a folder in the root repo that has the same name as another repo :/
 
it's fucking retarded, the tests has 400 operations vs 800 operations with only difference in variable declaration
 
1:39 PM
@FlorianMargaine that is a very silly question :P
 
yet you can easily declare 200 million variables in a second
 
To make a real benchmark, you need a massive amount of both tests and test runs
 
and the benchmark must not have code like expensive dom manipulation that will always shadow what you are trying to testy
 
@FlorianMargaine NodeComposite.forEach ;)
 
@Raynos: yeah, I just hope someone will turn this into a CW...
haha yeah, I saw that
 
1:41 PM
@Esailija you use jQuery, I no longer like you :(
 
well I have always used jQuery and you have never liked me :)
 
@Raynos: you're being silly using $ in your doc tho :D
 
:D
 
Always? Came out of the womb by jQuery('#vagina').slideOut()?
3
 
@FlorianMargaine y u blog in french ;_;
 
1:44 PM
well ok not always
 
@Raynos: coz that's my target
 
@Zirak lol
my mom was using IE6 in quirks mode so I had to come out a non standard way :?
 
;o
why do so many accounts have pradeep or sandeep etc in them
 
popular names
 
in SO, and whenever you see those you will know that the question or answer is bad
like I just need to see pradeep and I know I can skip it
lol
 
1:55 PM
thats racist
I think the same about people who haven't set a gravatar ;)
 
:D
 
gracist?
 
it's just an observation that can be proven to be true
objectively
 
about people who haven't set a gravatar? I agree.
 
yea
what noobs
@Esailija noob
 
1:56 PM
they don't know how to use the web
 
:P
 
lol
 
meh
 
i mean look at @Loktar - he's all like "WAZZZZ UPPPP HOMIES?!?!?!?!" in his gravatar.
you're all like "Look at my geometric pattern... i'm boring"
 
1:57 PM
exactly!
Ive considered changing it actually, to my facebook image
 
@Esailija cause they indian?
 
ok let's see if there is a good pic of me
 
unprofessional?
 
I'd say scary
 
1:59 PM
haha
 

« first day (537 days earlier)      last day (4394 days later) »