This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stop(); | |
loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress); | |
loaderInfo.addEventListener(Event.COMPLETE, loadComplete); | |
function loadProgress( evt:ProgressEvent ):void { | |
var ratio:Number = loaderInfo.bytesLoaded/loaderInfo.bytesTotal; | |
var percent:int = int( ratio*100 ); | |
trace( percent + "%" ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
It's a very, very, bad idea to attach handlers to the window scroll event. Depending upon the browser the scroll event can fire a lot and putting code in the scroll callback will slow down any attempts to scroll the page (not a good idea). Any performance degradation in the scroll handler(s) as a result will only compound the performance of scrolling overall. Instead it's much better to use some form of a timer to check every X milliseconds OR to attach a scroll event and only run your code after a delay (or even after a given number of executions - and then a delay). | |
Always cache the selector queries that you're re-using. It's not clear why Twitter decided to re-query the DOM every single time the scroll event fired, but this does not appear to be necessary (since scrolling itself didn't change the DOM). They could've saved the result of that single query to a variable and looked it up whenever they wanted to re-use. This would've resulted in absolutely no querying overhead (which is even better than hav |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number | |
and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". | |
*/ | |
var fizzbuzz = function(){ | |
var x = 0, print; | |
while (++x<=100) { | |
print = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[file] | |
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <filename>' --prune-empty -- --all | |
[dir] | |
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch <dir-path>/' --prune-empty -- --all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UIImage+Alpha.h | |
// Created by Trevor Harmon on 9/20/09. | |
// Free for personal or commercial use, with or without modification. | |
// No warranty is expressed or implied. | |
// Helper methods for adding an alpha layer to an image | |
@interface UIImage (Alpha) | |
- (BOOL)hasAlpha; | |
- (UIImage *)imageWithAlpha; | |
- (UIImage *)transparentBorderImage:(NSUInteger)borderSize; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function promisify(nodeAsyncFn, context) { | |
return function() { | |
var defer = q.defer() | |
, args = Array.prototype.slice.call(arguments); | |
args.push(function(err, val) { | |
if (err !== null) { | |
return defer.reject(err); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Options +FollowSymLinks | |
IndexIgnore */* | |
RewriteEngine on | |
# if a directory or a file exists, use it directly | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteCond %{REQUEST_URI} !/api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<!-- | |
Minimal JS, crossbrowser, styled input[type="file"] with simple markup. | |
Tested working in IE[>=7], FF[24], O[16], C[30], S[6.0.5]; Should work in | |
all browsers that support opening a file browser via a label associated | |
to an input[type="file"]. Some adjustments might be necessary for IE[6] | |
support. | |
Tested using html5 doctype. Further testing is necessary to ensure proper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat ~/.ssh/id_rsa.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys' |