Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Coding!

Andrew Crookston acrookston

👨‍💻
Coding!
Block or report user

Report or block acrookston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:1194290
# Directory listing
alias ls="ls -G"
alias l="ls"
alias ll='ls -Ghlk'
alias la='ls -GAhlka'
alias ..="cd .."
alias G=" | grep "
# Convenience commands
alias flushdns="dscacheutil -flushcache"
View gist:1446888
// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
View gist:1981887
def redirect_mobile(url = "http://detectmobilebrowser.com/mobile")
redirect_to url if /android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.match(request.user_agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|j
@acrookston
acrookston / scroll.js
Created May 16, 2012
Small scrolling script for fun. Not sure how well it works. Please contribute if you have ideas.
View scroll.js
Scrolling = {};
$.extend(Scrolling, {
smoothScrollTo: function(top) {
var sm_speed = 300;
var sm_runs = 0;
var sm_last = -1; // don't use 0, b/c sm_window_top can be 0
var sm_window_top = $(window).scrollTop();
var sm_down = (top > sm_window_top);
var sm_each_step = (sm_down ? top - sm_window_top : sm_window_top - top) / (sm_speed / 13);
var sm_scroll = function() {
@acrookston
acrookston / scroll.js
Created May 17, 2012 — forked from arnorhs/scroll.js
Small scrolling script for fun. Not sure how well it works. Please contribute if you have ideas.
View scroll.js
// muhaha.. changed all the code
// maybe this version handles scrolling to the bottom edge of a document a little better
// still not satisfied with the speed variable.. should that be higher == more speed, perhaps? or pixels per second?
// sorry about the opinionated style changes
Scrolling = {
smoothScrollTo: function(target_top) {
// ensure that we never scroll further than viewport size from bottom of the doc
target_top = Math.min(target_top, Math.max($(document).height(), $(window).height()) - $(window).height());
var speed = 30,
View pngbai-git.sh
#!/bin/bash
git diff --name-only origin/master | grep '\.png$' | xargs -I xxx -P 10 -t pngbai xxx xxx2
echo "Replacing files"
find . -iname *.png2 -exec bash -c 'echo {} `dirname {}`/`basename {} .png2`.png' \;
find . -iname *.png2 -exec bash -c 'mv {} `dirname {}`/`basename {} .png2`.png' \;
echo "Removing leftovers"
find . -iname *.png2.png -exec bash -c 'echo {}' \;
View ruby-warrior.rb
class Player
def od(dir)
return dir == :backward ? :forward : :backward
end
def play_turn(warrior)
w = warrior
@direction = :forward if @direction == nil
@back = 0 if @back == nil
@rest = false if @rest == nil
@acrookston
acrookston / growth-hacking.md
Created Aug 27, 2013
Summary of The Definitive Guide to Growth Hacking
View growth-hacking.md
View pngbai
#!/bin/sh
## Packages:
# brew install pngcrush optipng advancecomp
# brew install https://gist.github.com/acrookston/7726731/raw/3e3ce6c177a450c375e3622636f4d55bbe5289f6/pngout.rb
function usage {
echo "Usage: $0 infile outfile"
exit 1
}
View pngbai_git
#!/bin/bash
# Depends on pngbai script: https://gist.github.com/acrookston/6877287
# And don't forget to install pngbai's dependencies (documeted there)
FILES=`git diff --name-only origin/master | grep '\.png$'`
for file in $FILES; do
echo "$file"
git add $file
pngbai $file "${file}2"
You can’t perform that action at this time.