« first day (106 days earlier)      last day (4852 days later) » 

12:03 AM
@finneycanhelp or jsfiddle or just the console
I need to read more open source javascript (the good ones)
 
12:22 AM
jsfiddle ? cool!
got to go..
 
@finneycanhelp there's a simlar thing for just about anything, C#, PHP, node.js etc.
 
@Raynos find a project for yourself yet?
 
@Loktar thinking about writing a math library but if you have recommendation please give them.
Going to see if I can write set algebra library for infinite sets.
Currently reading annotated source code. If anyone has any good annotated source code to recommend please do
 
12:48 AM
@Raynos You may want to get to know blog.james-carr.org (link broke? looking. 1 moment plz)
 
@finneycanhelp tab to autocomplete
 
@YiJiang nod Thanks!
 
Links broken! :(
 
better link: twitter.com/#!/jamescarr He is a continuous generator of great source code, does presentations, and someone I recommend.
He is a master of JavaScript.
 
I see
Thank you. I will look into this
 
12:53 AM
nod
Enjoy!
 
@Loktar Were you thinking of a project?
 
1:09 AM
Im still working on a game engine
then ill make a game :P
thats my project
 
Is using an array as an unordered set bad?
I like using for in on an array
 
@Loktar let me know how you handle the canvas
@IvoWetzel good to see that you wake up when I ask a stupid question
 
I should go to bed...
 
@Loktar I plan to write an engine but getting good framerate on a generic not hand optimised engine sounds like a b****
 
1:12 AM
or better, I shouldn't sleep till 5pm
 
@IvoWetzel Seriously is using [] and for ... in for un-ordered sets bad?
 
for in on [] alone is bad, as for the unordered set thingy no idea
I'd rather say use a {} for that
 
@IvoWetzel I like set.length :(
apart from the hasOwnProperty thing why is for ... in bad?
@IvoWetzel
3
Q: Recommended JavaScript annotated source code for learning.

RaynosI have recently found annotated source code for underscore.js and backbone.js I'm currently going through these reading them to learn how other authors structure and write javascript code. It's a good learning experience. Can anyone recommend other high quality annotated source code that is wor...

Mention how your own source is a great read! (If it isn't, then write some source that is or refactor)
 
my code rarely has comments
 
@IvoWetzel >:(
Sure it does // dirty hack, // Magic below, // dont ask, // here be dragons
 
1:20 AM
that's only the kitten
good luck
 
h8u
 
I rarely write comments dunno
I try to keep the code self explanatory
 
Just learned that void 0 === undefined
@IvoWetzel leave a note in the garden saying void 0 is a safe way to generate a non overwritten undefined
enc += tok[3 + add] + tok[data >> 16 & 0xffff]
                                        + tok[data & 0xffff];
Bit shifting & magic numbers. Self explanatory my ass
 
I wasn't talking about BiSON
 
:)
 
1:25 AM
NodeGame Orbit / Shooter are a "easier" read
 
Is orbit done?
 
No
Just tech demo stage
 
orbit?
 
@Loktar his game. Check github
 
sounds cool
 
1:28 AM
also, with latest node there's a stack overflow somewhere
 
:(
 
I have no real idea where though
Need to fire the thing up with the node debugger
let me see, I want that fixed
I love how great the networking of the game works
And I should get around making the content for my website...
now let's wait until it crashes...
I hope the debugger catches the stack overflow
of course
attach the debugger
and you nothing breaks -.-
 
1:45 AM
:D
Debugger fixes it.
Did you not write down a bug report?
 
Elections page updated: se.awio.com/election.html now 100% more fancy
3
 
Yay for 100% more un-renderable unicode symbols
 
@YiJiang dont see a difference
 
@Raynos Flush your cache, maybe. Try checking a site still in the Primary phase, like say Programmers
That's basically CSS3 gradient + text shadow + drop shadow + rounded corners
 
1
Q: How long would it take to learn Python?

JoshHi all I have decided to take the time out after work to learn Python. Python appeals to me because at work (Web and eLearning Company), I have to follow out very repetitive tasks like delete all these tags, rename all these tasks and even more advanced repetive tasks. Additionally it would be g...

> After this I may choose to learn PHP, because that is mainly what we use for web development at work.
He'll either cry or get a different job :D
His comment is great too
> I have learnt how to use HTML, CSS, little bit of jQuery..
 
1:59 AM
Do you get good PHP in companies? Isnt all hacks?
 
No idea
 
2:10 AM
Oooh orbit
I didnt realize that was its name
yeah that was pretty fun, played it the other day
Ill have to check out your source, might help me improve my insanely laggy unstable game
 
@Loktar his one is event driven and hides latency by being turn based.
Networking is hard.
 
Hard Networking is even harder.
 
@IvoWetzel is Infinity cross-browser ?
 
MDN says JavaScript 1.3
So yes, it should be >=IE6
 
2:26 AM
var mid = (low + high) >> 1; vs var mid = (low + high) / 2;
 
djangoproject.com web framework for python
 
Aha. >> n is (/ 2^n then .floor)
 
@Raynos Haha, reading the title and quickly posting $.ready :P Only to then see that it's tagges XUL and FYAddon :D
 
2:44 AM
@IvoWetzel >_>. Stop looking at my mistakes. I was like wait, what. Shit. delete.
 
:D
I had that too one or twice
 
Less ambigious titles please!
 
indeed
 
hit 2k rep. going to graphitti your answers :) introduces subtle typos into @IvoWetzels answers
 
:D
Just remember, I've got enough rep to down vote you to 0
will take some time though...
 
2:50 AM
>:(
Not if I waste all my rep to downvote you to 0
1 : 5 ratio is just enough rep to kamikaze.
You only have 400 answer/questions so I can only dent you by 1.6k
 
You'll most likely get banned before that for the down voting, as would I
 
:P
Now look here. All your answers are shit and deserve -1
Its nice to see rep creep up as you sleep :)
 
I've got some problem in RL..
that means less time on SO
 
@IvoWetzel want me to fix your problems. Agony aunt or something
 
That won't help much
 
2:56 AM
@IvoWetzel want me to send you some cash?
 
That won't make me happy
 
Can't have it all.
some of this underscore.js stuff has real "Oh, that's pretty clever" moments.
 
3:44 AM
could i get one of you experts to give me some quick help via yahoo messenger?
 
4:20 AM
What is your question WillingLearner?
 
Ab
4:38 AM
how to find height of text in current page and then convert it to em format
 
@Ab Which element on the current page?
 
Ab
yes
 
em is always relative, so you're going to need two element here
 
Ab
what i tried doing on friday was to create a span element, add inner text 'M', then find the height of that span element. that gives me how many px are 1em.. please advise if i'm fooling
 
Well, that's not a very good method
Look, em is a relative unit. That means that lengths measured with that unit is always going to depend of the length (font size) of another element. Which two elements are you looking at here?
 
Ab
4:42 AM
well i need height of text in canvas and there's no method to know find that, my canvas code would only receive the text height in terms of em.
canvas would be dropped on to a DIV element. let me call that parentDiv
based on parentDiv's dimension, i'd create a canvas and then do some drawing, leaving enough room at top and bottom of canvas for text placement. the size of text(baseFontSize) would be passed as parameter
 
@Ab Go on...
 
Ab
lol. i just did
 
That's not nearly enough information there for me yo give you an answer
 
Ab
the height and width of canvas are deduced from the Div its within.
in the canvas, i'd be dividing the height into 3 parts, top(for title 2em), middle(drawimage of dimension as per the available in canvas), bottom (for label)
 
Do you actually understand how em works? Like I said, you need to calculate it relative to another element - for instance, if this p has a computed font size of 12px, and the body is set to 16px, then the font size of the p element is 0.75em relative to the body
 
Ab
4:52 AM
yes i do, thats why i mentioned the DIV container
what ever em measures in that DIV is my headache.
 
So you want to find the font size of that div element, in em, relative to?
 
Ab
yes
 
Relative to what?
 
Ab
oh! i'm confused, i 'm now understanding what u meant
wanted to find how many pixels is 1em
in that div
 
You can get the computed style for that element
If you're working with jQuery, then the css function should get you the computed style. The font size of that element should be how many pixels one em is
 
Ab
5:00 AM
jq is not available
any way of finding computed style
 
Ab
(function fontsize() {
var offsettext = '';
if (!document.getElementById("tempspan")) { var offsettext = '' + Math.random() }
var s = document.createElement('span');
s.setAttribute('id', 'tempspan' + offsettext);
s.setAttribute('style.font-size', '1em');
s.innerHTML = 'M';
var parentDiv = document.getElementById('container'); parentDiv.appendChild(s);
var tempSpan = document.getElementById('tempspan' + offsettext);
document.getElementById("input").value = msg;
var fs = tempSpan.offsetHeight;
parentDiv.removeChild(s);
i could only see offsetHeight. so used that. does that makes sense
@YiJiang thanks Yi, i see there is method getComputedStyle()
 
 
9 hours later…
2:13 PM
morning
 
2:28 PM
Would anyone like to recommend high quality open source code (stackoverflow.com/questions/4840420/…) The kind of stuff that's not hacked but is elegant?
 
3:13 PM
The annotated source of underscore and backbone makes a good read.
 
@DavidPadbury yes it does :) Going through underscore atm.
12 hours ago, by Raynos
some of this underscore.js stuff has real "Oh, that's pretty clever" moments.
@DavidPadbury Have you used underscore.js?
 
3:29 PM
Yeah - mainly with backbone.
Funnily enough - I found out yesterday underscore is the most used package in npm (the node package manager). search.npmjs.org
 
@DavidPadbury thats pretty neat. Its good to see it has gained proper popularity :)
Wait what, the MDC docs are a wiki? Awesome!
 
Hi! :)
 
3:50 PM
@Nyuszika7H hey
 
How can I get an object's property names? (in ES3, I know ES5 has a new method Object.getOwnPropertyNames())
 
for (var key in obj) { alert("I'm a property name : " + key); }
 
@Raynos for(var key in obj) { if obj.hasOwnProperty(key){ alert(...) } }
 
@MathieuRavaux pedantic! he said property names not own property names.
@MathieuRavaux everything in the prototype should be non-enumerable. If it isn't use good code :). Wait that requires ES5. He wants an ES3 solution.. Fine use the hasownproperty check.
 
@Raynos Agreed, but maybe he should be hinted a the difference between both, if he asks the question in the first place.
 
4:01 PM
I'm making my own JavaScript library… (probably not as powerful as jQuery :P)
 
@Nyuszika7H Have you come accross the "Let's make a framework" series by Alex Young ? Could be of interest to you dailyjs.com/tags.html#lmaf
 
> If you taught someone JavaScript with jQuery, would they even realise browsers don’t have $()?
:P
 
@Nyuszika7H good luck. If you want give me a link and ill review it a bit.
@MathieuRavaux that is an awesome series.
 
hates NoScript
 
@Nyuszika7H dont support noscript users
 
4:11 PM
@Raynos Yes ! I enjoyed a lot "10 Things I Learned from the jQuery Source" (paulirish.com/2010/10-things-i-learned-from-the-jquery-source) and "11 More Things I Learned from the jQuery Source" (paulirish.com/2011/…) by Paul Irish.
 
@MathieuRavaux seen those. They were good
 
@Raynos I've used to use it, but I've removed it, because it's just… annoying!
 
Also, reading the sources of Backbone, Docco and CoffeeScript in literate programming style, by Jeremy Ashkenas
Got to go, bye !
 
4:29 PM
@MathieuRavaux wanted to avoid coffeescript. It mutates javascript too much
 
01
hello, how are you?
so we have character limits, good to know
 
0
Q: Are two functions equal?

RaynosHow do I determine equality of functions? lets say we have function f() { // black box code. } function g() { // black box code. } We take a mathematical definition of a function. So if for all x in domain, f(x) === g(x) then f === g How do we handle domains? How can we otherwis...

@01 hey.
 
01
@Raynos What are you trying to do? Why you need that information?
@Raynos P.S. I have added some tags, that is my thing.
 
Defining infinite sets
infinite set is isomorphic to its acceptance function
Set equality on infinite sets checks whether their acceptance functions are equal
I.e. take Set(All evens) === (Set(all integers) / Set(all odds))
 
01
@Raynos good to know, however I don't know how it works, so can't help you.
 
5:17 PM
0
Q: Function equality on restricted functions

RaynosI already posted a question about function equality. It quickly concluded that general function equality is an incredibly hard problem and might be mathematically disprovable. I would like to stub up a function function equal(f, g, domain) { } f & g are halting functions that take one ar...

 
5:29 PM
Hi there! :)
_.isNaN? What about the built-in isNaN() function in JS?
 // Is the given value `NaN`? `NaN` happens to be the only value in JavaScript
  // that does not equal itself.
  _.isNaN = function(obj) {
    return obj !== obj;
  };
 
@Nyuszika7H congrats on making yourself look foolish
 
Huh?
Oh, I got it. Underscore's _.isNaN() checks if the object is NaN, and the built-in isNaN() checks if the object isn't a number.
Anyway, _.isNaN({}, {}) will return true
 
5:45 PM
...
 
And you're calling the function wrong...
it's _isNaN({});
so obj = {}
obj !== obj
makes sense? No? Good
 
interesting
var obj = {};
obj !== obj;  // true
_.isNaN(obj); // false
 
...
 
Underscore seems to do the same check…
_.isNaN = function(obj) {
    return obj !== obj;
  };
 
ivo@ivo:~$ node
> obj = {}
{}
> obj !== obj
false
 
5:51 PM
ooooh
I thought that function checks if two objects are equal… but not. I got it!
 
@IvoWetzel @Nyuszika7H you guys are funny
@IvoWetzel solve my problem with function equality!
 
funcA.toSource() === funcB.toSource();
and don't come me with mathematical equality stuff
 
@IvoWetzel
 
@Raynos blame you! :P
 
function odd(n) {
     return n % 2;
}

function odd2(n) {
     var val = n % 2;
     return val;
}
Dont make excuses -.-
 
5:54 PM
convert it to an AST
 
That makes you look more like an idiot
It has language-agnostic tag on it
@IvoWetzel whats an AST?
 
Abstract Syntax Tree
 
@IvoWetzel can it be done if the source code is unavailable?
 
then parse the tree to see if the operations can be reduced down to the same set... then make it work for infinite sets. And then head to Stockholm to grab your Nobelprize
@Raynos Sure, just add some magic. No. Then there's no chance whatsoever
 
5:56 PM
@IvoWetzel No, it's actually Alaska Standard Time. :P
 
@IvoWetzel you've got the compiled machine code!
 
Then dissamble it, make an AST check that with your magic(tm) thingy and grab your Nobelprize
 
imma do it!
 
alert                            (                                                        '                                              hello                                                                         '                                    .                               trim                                       ()                                     )               ;
 
Thats really annoying. and doesn't even work!
 
6:46 PM
Number.prototype.minus = function(amount) { [native code] }
No, it isn't a native function, I've just hidden the code. Now let's see it in action.
> (10).minus(1);
9
It's simple. So here's the code: return this - amount;
This is the code. Or not?
> (2).minus(1);
2
WTF?!
[revealing code in 5 minutes, try to guess it – in meantime I'll provide more examples]
> var two = (3).minus(1);
undefined
> two;
2
> two.minus(1);
2
> (3).minus(2);
1
Now, we have another function called .plus(), that's simple too.
> (1).plus(1);
2
> (2).plus(1);
3
It seems that function behaves correctly. Or not?
> Infinity.plus(1);
"Infinity1";
1 minute remaining – Ok, if nobody is there, I'll let you guess it while I'm away.
[time extended by +5 minutes]
> var one_or_two = (2).minus(1);
undefined
> one_or_two;
2
> one_or_two.plus(1);
2
Now it's even stranger. Can anyone guess the code?
[ please stand by – copying the correct codes to my clipboard ]
@kyj112 Hi there! Can you guess it? (scroll up to the beginning!)
 
@Nyuszika7H stop being silly. I shant indulge
 
7:01 PM
@Raynos then tell me the correct code :P it's not hard
@Raynos shant? what does that mean?
 
@Nyuszika7H shall not
 
7:16 PM
@ircmaxell next weeks code bowling. isOdd(n)
 
7:51 PM
Hey, guys.
Does Firebug automatically break on error?
 
01
8:12 PM
@Zarel by default it doesn't, but you can enable that in options, but it will break even when code is in try-catch.
 
@01 Thanks.
 
8:40 PM
hello
anybody here?
 
@Mirgorod what do you need?
 
i need help with jquery)
i have such html: <div class="_button demo_button"><div class="_button_inner"><a href="isbn:{$i.ISBN_norm}" title="посмотреть книгу «{$i.name}»"><span>демо</span></a></div></div>
{$i.ISBN_norm} is 9785911807221
and i want to change demo_button css property with help of $("a[href^=isbn:"+isbn+"]").parent().parent().css("display", "block");
 
Hi! :)
 
but it doesn't working
 
@Mirgorod First, there are no variables in HTML. And what are these characters (посмотреть книгу)?
 
8:46 PM
it's smarty
it's cyrillic chars
 
@Mirgorod Second, for the god's sake, press Ctrl+K after entering your code (and enter it separately!)
 
it's like "read book"
:)
ok
and i have on code line before:
$("a[href^=isbn:"+isbn+"]").attr("href", bookInfo.preview_url);
and it's working
i test it with help of firebug
but
alert($("a[href^=isbn:"+isbn+"] span").text());
donesn't working
 
@Mirgorod isn't working / doesn't work. what is your primary language? :)
 
my language is russian :)
and ukrainian :)
east european languages
any idea?
 
Try this: alert($("a[href^=isbn:] span").text());
 
8:55 PM
result is демодемодемодемо
 
Now try this:
 
coz there is 5 elements a with attr href=isbn:
but number after isbn: is different
 
var isbnText;
$("a[href^=isbn:] span").each(function() {
    isbnText += $(this).text() + "\n";
});
alert(isbnText);
 
undefinedдемо
демо
демо
демо
 
Hmm, it seems all spans inside the links (<a>) have the same text?
What do you want to get?
 
8:59 PM
it's like buttons
 
@Mirgorod paste your code to JS Bin
 
they are not displayed at start but i use google book api to check isbn's and if it equals than i display button
 
@Mirgorod first line looks like this o_O
> Access 2000. ??????? ?????????? ??? ???????? ????????? ??? ??????????
 
JS Bin don't working fine with cyrillic that's why ?????????
?????? is some word
)
 
@Nyuszika7H it doesnt work with the character sets.
@Mirgorod try pasting it into jsfiddle. It might like the characters
 
9:03 PM
@Mirgorod Specify the charset in the HEAD, like this: <meta http-equiv='Content-Type' content='text/html; charset=CHARSET-GOES-HERE' />
 
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
but it seems like not supported
but u can try preview
 
@Mirgorod Try jsFiddle. There, you don't need the html, head, body elements, jsFiddle automatically adds them. Things inside <script> should be placed in the JavaScript part, without the <script> tags. Stylesheets to CSS.
 
hmm
but what i need to do with
<script src="http://books.google.com/books?jscmd=viewapi&amp;bibkeys={$content.bibkeys}&amp;callback=ProcessGBSBookInfo">
    </script>
 
@Mirgorod In the sidebar, click Add Resources. Paste the text inside src="" (without quotes!) and then click [+].
 
?
 
9:12 PM
@Mirgorod do you understand it?
 
yep
good service
i never used such services :)
 
nice
I see the problem, the variable isbn is not defined
anyway what's that www.my.qqq?
 
but it seems like google send it
it's local addr
 
> Oops! Google Chrome could not find www.my.qqq
 
look at this
.demo_button {
    float: left;
    margin-top: 7px;
    margin-right: 3px;
    display: none;
}
i can change it to display: block;
hmmm
it seems like something wrong
there must be alert
 
9:19 PM
@Mirogorod this line is wrong $("a[href^=isbn:" + isbn + "]")[0].text()
correct code: $("a[href^=isbn:" + isbn + "]").eq(0).text()
still no alert
> Port error: Could not establish connection. Receiving end does not exist.
 
i use jquery and i add it in field "Shoose Framework"
 
@Mirgorod no you didn't select jQuery. you should for it to work
 
i added it
 
@Mirgorod then press Update
 
i added it
			$("a[href^=isbn:]").each(function() {
				if ($(this).attr("href") == "isbn:"+isbn) {
					alert("yahooo");
				}
			});
and it's working
i think i find way
 
9:34 PM
@Mirgorod You don't need to include jQuery inside the resources, it's enough to select it at Choose Framework.
 
oh thanx to all!
i solve it
      // Function to process GBS info and update the dom.
      function ProcessGBSBookInfo(booksInfo) {
        for (isbn in booksInfo) {
         var bookInfo = booksInfo[isbn];
         if (bookInfo) {
			$("a[href^=isbn:]").each(function() {
				if ($(this).attr("href") == "isbn:"+isbn) {
					$(this).parent().parent().css("display", "block");
					$(this).attr("href", bookInfo.preview_url);
				}
			});
         }
       }
     }
ah, it's very cool site
Thanx! yahooo! it's working and i can go to sleep :D
 
@Mirgorod And another tip: use this.href instead of $(this).attr('href'). :)
      // Function to process GBS info and update the dom.
      function ProcessGBSBookInfo(booksInfo) {
        for (isbn in booksInfo) {
         var bookInfo = booksInfo[isbn];
         if (bookInfo) {
			$("a[href^=isbn:]").each(function() {
				if (this.href == "isbn:"+isbn) {
					$(this).parent().parent().css("display", "block").end().attr("href", bookInfo.preview_url);
				}
			});
         }
       }
     }
 
@Nyuszika7H thanx
 
Also take a look at .end()
 

« first day (106 days earlier)      last day (4852 days later) »