Joined February 2012
·

Rob W

Developer at Return Path
·
Arvada, CO, United States
·
·
·

Posted to jQuery UI button set selected icon over 1 year ago

@comfuner not sure what you mean...

variable hoisting is what causes the second example to work differently. Here's a pretty good read about it Javascript Variable Scoping and Hoisting

TL:DR
Function declarations and variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter.

@hauleth you can always bypass the commit hooks with the '--no-verify' flag. That way if you are writing a cross browser console.log class and it needs to be there you can still check it in.

I know you borrowed the example but I just cringed at the loop. Easiest prime factorization speed up is to only check up to the square root of the number.

var check = Math.sqrt(num);
for ( var i = 2; i < check; i++ ) {
Posted to Easy Accordion in JQUERY over 1 year ago

There's also built in jQuery UI accordiains:

http://jqueryui.com/accordion/

Which offer a bit more felxability, and nifty features. For a nice lightweight solution yours is great.

Posted to Better jQuery Performance over 1 year ago

Using multiple appends is a bad idea as it will cause a repaint (and potentially a reflow) of the DOM. A Nifty trick of the append method is that you can pass in multiple elements into one append call. I think your example would be better as:

span.append(a, '<strong>Test2</strong>', a.clone(true), a.clone(true));

though I get you were trying to show chaining as well.

If' you are using linux you can simply simply add the __git_ps1 variable.

GIT_PS1_SHOWDIRTYSTATE=true

GIT_PS1_SHOWUNTRACKEDFILES=true

GIT_PS1_SHOWUPSTREAM="verbose"

export PS1="\t]\[\e[${ps_color}m\]\h:\w\[\e[0m\] \$(__git_ps1 '(%s)')>

Will produce something like this:

12:55:52]machineName:/home/user/dir (branchname *% u=)>

Where * means modified files exist -- from SHOWDIRTYSTATE

% means untracked files -- from SHOWUNTRACKEDFILES

u=/+/- means same/ahead/behind remote -- from SHOWUPSTREAM

Also works in firebug for Firefox :)

Posted to Indentation Primer over 1 year ago

For automatic indentation you can also use =

Posted to Autocomplete last command's param over 1 year ago

For when you forget to run sudo on a command there's

sudo !!

And for another alternative

ls !$

where !$ is also the last "word" from the last command.

Posted to Don't overuse $(this) over 1 year ago

@francisc I think you're example test it too simple. Of course it's not going to matter in an example where there is only one element the DOM. When you use $(this) it starts from the root node and then checks every node until it finds the given selector. In a real world scenario the lookups could become more expensive.

Posted to Get a file extension from file name over 1 year ago

Or php's built in function pathinfo

tried copy and paste and took me a few tries to realize the // comments were breaking the css. Might want to update to /* */ comments for valid css.

Also copied to a demo-able example on jsfiddle

Posted to Pretty git commit graph over 1 year ago

In my git config I have one for compact as well

[pretty]
    compact = "%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset"

Which looks something like this:

| * 6a6b662 - My Commit Message (4 hours ago) <Brombomb>

which can then be used with the

--pretty=compact

flag

Posted to Don't overuse $(this) over 1 year ago

Also worth noting the idea of adding the $ to this to denote it is already a jquery object.

Achievements
188 Karma
11,796 Total ProTip Views