« first day (112 days earlier)      last day (4837 days later) » 
00:00 - 20:0020:00 - 00:00

Tom
12:51 AM
if I do a string.indexOf('\n'); is it possible that this will not hit on a carriage return (enter) but on a literal "\n" character combination?
 
@Tom No, because to get that you'll need to escape the \ backslash
gives Markdown mini the finger
So you'll need something like indexOf('\\n') to match literal '\n's in the string
 
Tom
@YiJiang alright, hmm.. I am hopeless then
I am streaming a file and checking every line by looking for the carriage return
if the carriage return is not present, I add the string to the buffer and check back later when I have more data
but with big files something goes wrong, I think it has to do with the \n search
 
@Tom Chrome has a weird problem when it won't pick up '\n' line breaks
I think the solution is to use '\r' instead.
 
Tom
@YiJiang hmm I am running this in node.js
 
@Tom Chrome uses V8, the same JavaScript engine node.js runs on
But that doesn't mean every problem in Chrome would affect node.js
 
Tom
12:57 AM
@YiJiang what does \r mean?
 
newline vs. linefeed
In other languages at least, on some OSes, "\r" == "\n" but not on others
 
Hang on, I found the question
2
Q: Newline \n problem in JS

cantbereachedI am reading a file with xmlHttp object and splitting the responseText with newlines by split method. But "\n" character literally doesn't work. It acts like an error in my code and causes my code not even function. Here is the line: var lines=myPlaylist.responseText.split("\n"); There is...

 
not sure how JS does it
 
1:57 AM
any jquery studs around?
javascript i should say
 
@Michael What's a 'stud'?
 
 
2 hours later…
4:22 AM
I hate the do it for me askers:
4
A: MySQL: Mass Conversion Script for Table Engine

ircmaxellIn pseudo code using information_schema tables: $rows = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'yourDBName' AND ENGINE LIKE 'engineA'"; foreach ($rows as $table) { $query = 'ALTER TABLE '.$table.' ENGINE = engineB'; }

 
4:39 AM
oh noz, 666 Tags
ircmaxell, New Jersey, USA
19k 2 12 42
 
4:50 AM
hi. does anyone know if FF and Chrome treat NaN differently?
 
5:06 AM
@ircmaxell Next question I ask I'm going to tag '666'
 
5:19 AM
lol
 
 
5 hours later…
10:24 AM
 
@IvoWetzel Erhm... margin of error?
But how do they calculate that margin anyway?
 
Hm shouldn't it calculate that into ops/sec?
 
@IvoWetzel Maybe they show the upper bound and use the lower bound in it's comparisons? Damn confusing though...
 
Yes they should probably do that
12% slower... when?
At worst?
13.87% of the time?
2.1342114% of the time?
 
Meh, jsperf sucks, we all know that...
 
10:30 AM
interesting
FX4 does optimize the first 3 of the cases
(and nobody cares, since Chromes "unoptimized" versions are already 3x faster)
 
@IvoWetzel Meh, these are ops per second, surely this is well into the realm of microoptimisations?
DOM operations are a billion times slower
 
Still, it seems returning / using arguments results in a 50% slowdown of the whole thing
We should probably plugin some algo into the function
just to slow things down
and to reduce the "impact" of the single arguments access etc
now where did I have that djikstra...
micro benching defeated!
 
10:46 AM
@IvoWetzel Hehe, yeah, the numbers are well within the margin of error
 
in the end all the fuss about "even creating arguments is slow" is BS
 
They should provide some sort of unoptimisable algo or function for you to plug in there to defeat microoptimisation
 
they should do that, but then... that would destroy their site :D
hm I should put my bezier thing on github
 
11:01 AM
I really need some scaffolding script for projects...
Should be a nice project for today :)
 
Just finished updating my userscript for SO
Userstyle, sorry. Hrump...
 
 
2 hours later…
12:51 PM
@YiJiang Unless they are called in a tight loop, yes
 
1:02 PM
Hi! :)
I'm always looking for jQuery syntax highlighting, since I'm using jQuery… :P
 
@Nyuszika7H You mean to highlight jQuery selectors?
 
@lonesomeday nope, but that would be nice :)
 
@Nyuszika7H How would syntax highlighting for code written with jQuery in mind differ from that of JavaScript?
 
@YiJiang In no way… except if there would be syntax highlighting for selectors.
It's not that important. I mean, I forget that what I need is JS syntax highlighting, and I'm looking for jQuery.
 
geshi?
 
2:03 PM
bored... so I'm writing yet another extending function thingy
 
Well, you can come around and test my userstyle ;) userstyles.org/styles/35963
 
0
A: Practice of checking 'trueness' or 'equality' in conditional statements - does it really make sense?

Nyuszika7HReplying to Bevan (it didn't fit in a comment): You're right. !foo isn't always the same as foo == false. Let's see this example, in JavaScript: var foo = true, bar = false, baz = null; foo == false; // false !foo; // false bar == false; // true !bar; // true baz == fal...

Anyone knows LOGO there?
 
@YiJiang Looks nice, but why is the yellow border around the vote count only on the main question page?
It's not on the tagged questions pages, at least not for me
or is that a new thingy on the site itself?
 
2:21 PM
@IvoWetzel Because of the way the thingadongdong was constructed, it's not possible to put a yellow border around the > bit sticking out to the right
Can you test the 10k tools modifications? Those are the new parts, and might have broken something
 
Do we really need the > thingadong?
10k looks great
 
@IvoWetzel Hmm... true
@IvoWetzel There was an update to the 10k tools a few hours ago, but I did made it slightly prettier, hee
 
I hardly notice the > here on my 5 year old TFT...
too low in terms of contrast
in fact I don't even care about the extra "near white" background
only thing that annoys me a tiny little bit is the reduced font-size, I already set it to a lower amount in about:config since I can't stand big text, but I can remove that easily so that's not a real problem
 
@IvoWetzel Me too, actually. But try not to change it too much, there are parts of the style that I've designed to work specifically with the fixed 11px body font-size
The bits that might break would be the delete buttons for the interesting and ignored tag list and the bounty indicator vertical positioning
 
well it doesn't reduce the font-size (besides the one in code blocks) but it leaves the line-height untouched
code blocks have tons of spacing between the lines now and the rest of the text is a bit stuffed up
 
2:30 PM
@IvoWetzel Uh, screenshot?
 
link to the question in the screenshot?
 
1
Q: When does Scala need parameter types for anonymous and expanded functions?

JPPWhen does the Scala compiler really need the type information of parameters of anonymous functions? For instance, given this function: def callOn[T,R](target: T, f: (T => R)) = f(target) then I cannot use it like this: callOn(4, _.toString) => error: missing parameter type for expand...

 
need to restart... Firebug messed with the definitions
 
Hmmm, looks the same, except that you've got a different mono font. You don't like the way it looks in there, hrm... ?
 
with my mono font and the font-size override, the font shrinks in height
but the line-height stays the same, that results in more whitespace under the baseline
 
2:39 PM
I've set my default font size to 14px, hmmm
 
Me too
 
likes LOGO
 
Hmmmm
 
@IvoWetzel bad timing :P
 
make that LEGO and I agree :P
@YiJiang Guess the MS core fonts screw it up again
 
2:40 PM
You can make global changes to the line height I suppose, shouldn't affect the script too much
 
I'm making a clock in LOGO… currently it only has a second hand…
@IvoWetzel :P
 
3:04 PM
yay for boxmodel bugs in chrome
 
Knu
Is there a mod around? I need to move a question from SO to UI
 
hi all
i need help
 
Knu
hey.
 
look at this
	var words = $("#search_input").val().split(/\s/g)
	for (var i = 0; i < words.length; i++) {
		var replaced = $(".content_area").html().replace(/words[i]/g, "!!!")
		$(".content_area").html(replaced);
	}
 
You could flag the question for attention and request a migration, or you post us a link and we vote to migrate it
 
3:14 PM
...l().replace(/words[i]/g, "!!!")...
it's not hard question
 
Knu
how many ppl to make it pass?
1
Q: What's the preferred orientation for a toggle script?

KnuIm gonna use some kind of accordion javascript (you click a button and some content appears), Id like to know from an UI/ergonomic standpoint what's the best orientation of the expanded state? the button moves down as the content becomes visible (UP) the content beside the button (DOWN) sid...

 
how to insert words[i] in regular expression?
 
/words[i]/g <- that's a regular expression literal, you need to construct a new one
new RegExp(words[i], 'g');
 
var new_reg = new RegExp(words[i], 'g');
and than
...l().replace(new_reg, "!!!")...
 
then just use it instead of the literal
 
3:16 PM
thanx
 
@Knu Hm UI is not on the migration list yet, you'll have to flag it for migration
 
Knu
ok
@ivo thx
what should i choose
it's not listed
 
I'll flag it for you
 
Knu
is it off topic?
ok but don't close i want to migrate it :)
 
0
Q: HTML5, CSS3 and JavaScript Learning Resources

Myles GrayHi guys I'm looking around for some in depth resources on HTML features such as <audio>, <video> and <canvas> and how JS and CSS/CSS3 can be used to create dynamic graphs/games and illustrations with the <canvas> tag, I have read a 2 books on both CSS3 and HTML5, they were...

:)
 
3:19 PM
@Knu But then... UI is still in beta, I don't think it's possible to migrate question to beta sites
 
Knu
smells like community wiki
@ivo then plz don't flag it
or can i delete it?
I mean will it still count as a not accepted answer in my accept rate if I delete it?
 
Uh...
 
Knu
Ill check meta SO nevermind
btw just found a new bug in the chat :)
 
@Knu what bug?
 
uh...
how broken is CSS?
the background image does not render, even though the inner div has a bottom margin
 
Knu
3:27 PM
I am reporting it right now
in the chat chan
 
3:55 PM
Can anyone recommend some JS resources for the beginner?
Straight JS - I'd prefer to understand the base before i use something like JQuery
 
@MylesGray yeah
 
http://jibbering.com/faq/
https://developer.mozilla.org/en/JavaScript/Guide
http://bonsaiden.github.com/JavaScript-Garden/
 
wow thanks :)
 
3:56 PM
Note:
> JavaScript Garden does not insist on teaching JavaScript. Former knowledge of the language is strongly recommended in order to understand the topics covered in this guide.
 
then watch the... 12 hours(?) of crockford talk available on the net
 
YUIBlog is also a good resource. It's not only about YUI, but about vanilla JS, too.
 
Cool thanks guys, and one last thing is the use of Modernizer frowned upon?
I have often though of using it, but it seems a bit hack-ish to me
 
@MylesGray Nope.
Better than browser detection anyway
 
@YiJiang thanks
Sorry, one more thing, CSS3Pie and HTML5Shiv, How are they at what they are intended at doing?
 
4:00 PM
@MylesGray and no, W3Schools isn't a good resource. see w3fools.com (which is put together by the jQuery team – according to Lifehacker)
 
hahaha, no i realise that I never use W3Schools
 
@MylesGray They add HTML5 and CSS3 support for IE < 9. you should include them in conditional comments:
<!--[if lt IE 9]>
<script src='...'></script>
<[endif]-->
 
@MylesGray I haven't used them, but since you're trying to focus on JS, i wouldn't care so much about those thing atm
learn JS, get good, then evaluate the stuff on your own, in the end it needs to fit your needs
If you're on mac / linux I would recommend to install node so you can do JS experiments more quickly
 
@Nyuszika7H Thanks
@IvoWetzel Cool sounds about right to me
 
> // Nonstandard syntax, found in GMail source code. DO NOT USE.
try {
  // FunctionDeclaration not allowed in Block.
  function Fze(b,a){return b.unselectable=a}
  /*...*/
} catch(e) { _DumpException(e) }
 
4:03 PM
@IvoWetzel im on a mac
 
Huh, why not?
 
Shouldnt use try/catch in production code?
 
depends...
if you catch some always make sure to HANDLE it(!)
everything else falls under Pokemon Exception handling
 
Huh? Which Chrome extension is logging me? If I select a text and right-click on it, the HTML source if it gets logged onto the console.
 
@MylesGray The shiv allows HTML5 elements to be styled with IE8 and below
PIE adds, AFAIK, rounded corners. Not sure which other CSS3 properties it adds
 
4:09 PM
<code>YYYY-MM-DDThh:mm:ss±hh:mm</code>. chrome-extension://mijlebbfndhelmdpmllgcfadlkankhok/js/menu.js:25
gotcha, it's Quick Note
but why is it logging?
 
@YiJiang My understanding was shiv affiliates the new HTML5 contextual tags with the div tag this making them display correctly, much like #define in C?
 
@MylesGray No, it's far simpler than that. IE refuses to apply CSS styles to any element it doesn't recognise, so what the script does is run a simple loop through a list of HTML5 elements creating each of those elements in the DOM allowing them to be styled in IE
 
Fixing FX2 is harder...
but then again, nobody uses that thing
 
@IvoWetzel At least less than IE6, which is what you should really be worried about
 
Well... I could make my portfolio site work in IE6...
by changing up half the HTML
It could be made to look nearly the same, but I don't see the point in HTML5 for IE6
Support IE6 > More IE6 stay around > More need to support IE6
 
4:16 PM
Why do we bother supporting IE6 anymore?
 
@IvoWetzel Depending on who might be viewing your profile
@MylesGray Because people still use them
 
+1 on what @IvoWetzel
 
If you're doing intranet...
 
but the people that use IE6 wouldn't aprecciate the new features anyway
 
and everything is running on IE6, then it's understandable
but I see no point in doing a site on the web over again, just for IE6. When IE7+ works with the same HTML/CSS as FX, Chrome etc
 
4:19 PM
@IvoWetzel IE7 is not bad, is that with or without IE8.js? ;)
 
without
 
For example I had a client wanting a site done, and there was an e-commerce section to be done, did it ALL in CSS3 from the rough sketch he did for me and say "It looks crap" - low and behold using IE6 as soon as he updated to FF3.6 It looked great but wanted it to work in IE6, even though the webstats were showing 2-5% of traffic was IE6 so it was scrapped and went with images... >.>
 
The only "compatability" thing is the html5 thingy that teaches IE about the elements
IE6 = more work = more money to pay me
 
I work on fixed costs not by the hour
 
@IvoWetzel The stress resulting from fixing for IE6 might not be worth any amount of money you pay me ;)
 
4:21 PM
IE7 + fading is more than enough stress already
 
what is the average IE6 demographic now? 15%?
 
@MylesGray Depending on which part of the world
 
statscounter lists 2.5% for EU
 
More than 50% for China, for instance
 
Fixing IE6 support for China is easy
just write some rants about the Chinese president on your site :) IE6 support. Fixed!
 
4:25 PM
@IvoWetzel Maxthon's next version will be Webkit/Chromium based, so hurray for that
 
hooray
 
No wait, it's already released. Hmmm
 
dun dun
 
Now let's wait for that IE stat to drop like a stone - maxthon.com/mx3/index.htm
 
US < 5%, EU <2.5%, Africa 22%
US Gov refuses to upgrade
but Youtube and Google Docs are phasing out IE6 support
 
4:28 PM
No wait, the Chinese version of the site still shows 2.5.x for the download link. /o\
 
@YiJiang I can't even access the site in the first place :P
 
Im seeing 3.02
 
> (net::ERR_CONNECTION_TIMED_OUT
 
I dont see many people using Maxathon (I'll most likely eat my words in 2/3years time) If FF implemented dual engines web-dev would be godly
Is it a bad idea to use modernizer to tell users that IE6 is balls and they should get a grip on life?
 
5:02 PM
Hey all
Dont support IE6 unless its intranet
or your targetting the correct clients
@YiJiang you use maxthon?
Oh I see maxthon has both trident & webkit build in. Pretty neat
 
@Raynos what is the advantage of IE6 for intranet?
 
@MylesGray not having to upgrade legacy applications. Rather then doing that all new web applications will be written for IE6 :)
 
5:53 PM
@MylesGray There are nothing but false-advantages
0
Q: Jquery round function

SergioHow can I round the number using Jquery? If the number is 3168 I want to print it as 32. Or if the number is 5233 the result should be 52. How can I do that? Should I use Math.round function?

ummm. It's happening...
 
Would commenting "@DanGrossman jQuery is the successor of JavaScript." be considered a good joke or bad practice?
 
(function ($, undefined) {
$.fn.round = function(num) {
return Math.round(num);
}
}(jQuery));

$('#uselessSelector').round(4.3);
 
@lonesomeday I was just about to write that as an answer
 
lol
 
6:11 PM
Hi! :)
@lonesomeday This is better:
(function($) {
    $.round = function(num) {
        return Math.round(num);
    }
})(jQuery);
 
@Nyuszika7H The pointless selection was part of my point :-)
 
@lonesomeday :)
 
0
Q: calling prototyped function in javascript without creating an object

TwidizleI am trying to call a prototyped function from another javascript file but it doesn't seem to work. BuddyList.js : function BuddyList(){ .. } BuddyList.prototype = { addBuddy : function(buddyName){...} } UserOptions.js: function UserOptions(){ .... BuddyList.addBuddy(username); } I ge...

What is he actaully trying to do? I gave him 4 different ways of doing it and have no clue what he wants to do
I think he might be treating it as a singleton. Or trying to.
 
guess he thinks that function.blabla will resolve via function.prototype
 
oh lord
 
6:17 PM
@ircmaxell ?
more jQuery goodness?
 
Is there any time after a post gets totally deleted (after someone, let's say the OP, deleted it), so nobody can see it, not even 10k+ users? I'm just curious.
 
singletons.
 
Thoughts - Good for the earlier IE6 discussion:
0
A: How important is it to follow web standards?

Myles GrayI find that HTML validation can be handy UP TO A POINT. After that point (i.e. where validation takes over from common sense) it becomes a hindrance, I believe that validation is a very useful DEVELOPMENT tool but it is not necessary to comply 100%, For example the XHTML Strict specification dep...

 
ha
 
@ircmaxell singletons are great for solving all my C++ class problems
 
6:21 PM
singleton = global state
global state = bad
 
@Raynos: for various and non-standard values of great
 
That was sarcasm.
 
Oh ok
 
@MylesGray dont post ugly code like that. I had to go and edit it.
 
@MylesGray: That jQuery is really ugly. Is that really what it takes to implement open-in-new-window?
 
6:25 PM
Sorry, was just the format I had it in, will tabulate (real word?) it in future
 
Does jQuery support XPath selectors?
 
@ircmaxell I believe so, when i used to use XHTML Strict it was the work around for the deprecated traget tag
 
ok, instead of that monster:
jQuery(document).ready(function($) {
    $('a[rel=external],a[rel=nofollow]').each(function(){
         $(this).attr('target','_blank');
    });
});
 
ahh much nicer
 
selectors are powerful
 
6:29 PM
Why are things like if (a == ( foo || bar)) not possible?
 
@Raynos It would be nice. There are two ways to do something similiar.
 
which is (a == foo || a == bar)
 
if (a == foo || a == bar) {
    …
}
 
@Raynos: because it's ambiguous
 
switch (a) {
    case foo:
    case bar:
        …
}
 
6:30 PM
@ircmaxell I know which pains me.
we need an or keyword :p
 
is it supposed to be a == b || a == c, or a == (b || c) (which is boolean)
 
(a == b or c)
@Nyuszika7H thank you for you patronising explanation of how to do if checks. You do it on purpose right?
 
but then why not create a reverse in operator
 
switch might be useful when you're using multiple checks.
 
a.contains(b or c)
 
6:31 PM
I know we have a in [b,c]
 
but that's different
 
if that returns true if a == b then it would be weird
contains shouldn't handle the case of equivelance like that
 
> var a = 1;
> var b = 2;
> var c = 1;

> a in [b, c]
true
> a in [b]
false
> a in [c]
false (!)
> a == c
true
 
I don't know. I don't find it an issue
 
I assume a to be some form of bag
 
6:33 PM
so, it's your problem to figure out :-D
 
function eq(a, list) {
    for (var i = 0; i < list.length; i++) {
        if (a == list[i]) return true;
    }
}
> eq(1, [2, 1])
true
> eq (1, [2, 3])
false

// outputs 'yippie' to the console
if ( eq(1, [2, 1]) ) {
    console.log('yippie');
}

// outputs nothing
if ( eq(1, [2, 3]) ) {
    console.log('yippie again');
}
You could also check if a is equal to b or c.
function eq(a, list) {
    for (var i = 0; i < list.length; i++) {
        if (a == list[i]) return list[i];
    }
}
 
in...
 
uhhh
 
checks for properties
so a in [b, c] == [b, c][a]
 
> 1 in [3,2]
true
 
6:40 PM
@comeonman Ctrl+K to format code blocks
 
isn't that was I just said?
 
function eq(a, list) {
    // Method 1: return true or false
    return (list.indexOf(a) != -1) true : false;
    // Method 2: return the match or undefined
    // return (list.indexOf(a) != -1) list[a] : undefined;
}
 
really?
ternary operator?
 
[1,2][1]
 
I'm wondering why will ['foo', 'bar']['foo'] return undefined.
 
6:44 PM
why not just return (list.indexOf(a) != -1)
 
returns 2
 
@ircmaxell nice
@ircmaxell It's too late to edit this message :(
Also, I've missed the ?
 
/me is going to walk away...
 
6:58 PM
Mac friendly JS IDE w/autocomplete?
 
hi
help me with this question plz
0
Q: Select words by js in search result

MirgorodHi! I am using jQuery and creating now search. And i want to change all words that match of search. For example: i type in textbox "hello world", Script get all words "hello" and "world" on page and replace it on "<b class="search_word">hello</b>" and "<b class="search_word">...

any ideas?
 
is this what you are looking for kilianvalkhof.com/uploads/listfilter ?
 
not really
for example
i have:
<div class="here_we_search">
  <div class="search_div">
    some text and wow text
  </div>
  <div class="search_div">
    other text wow super cool text
  </div>
  <div class="search_div">
    tralala text
  </div>
</div>
and i want to search in .here_we_search text: tralala and replace it with <b>tralala </b>
 
7:17 PM
$elements = $('//*[contains(., "tralala")]');
 
I tried this:

	if ($("#search_input").val() != "") {
		var words = $("#search_input").val().split(/\s/g)
		for (var i = 0; i < words.length; i++) {
			var new_reg = new RegExp(words[i], 'gi');
			var replaced = $(".content_area").html().replace(new_reg, "<b class='searched_word'>"+words[i]+"</b>")
			$(".content_area").html(replaced);
		}
	}
it works
but
tags
if i search somthing like: b class is the best class in School
it destroy page structure
 
7:48 PM
Would it be safe to assume use of the getElementByClassName will be adopted by all major browsers in the near future?
Waking @Raynos :)
 
hmmmm
is it right
$("#search_input").not($("#search_input").contains("b"))
?
 
00:00 - 20:0020:00 - 00:00

« first day (112 days earlier)      last day (4837 days later) »