Skip to content

Instantly share code, notes, and snippets.

View onpaws's full-sized avatar
🚴‍♂️
building things

Pat onpaws

🚴‍♂️
building things
View GitHub Profile
@onpaws
onpaws / bootstrap3-CurrentPageNavHighlight
Last active August 29, 2015 14:08
animate navbar clicks
$('#nav .navbar-nav li>a').click(function(){
var link = $(this).attr('href');
var posi = $(link).offset().top;
$('body,html').animate({scrollTop:posi},700);
});
@onpaws
onpaws / bootstrap3-CurrentPageNavHighlight
Created October 28, 2014 21:50
highlight current page on navbar
def is_active(action)
params[:action] == action ? "active" : nil
end
def nav_entry(body, path)
content_tag(:li, link_to(body, path), class: ('active' if current_page?(path)))
end
def nav_entry_indent(body, path)
entry_class = 'nav-indent'
entry_class += ' active' if current_page?(path)
@onpaws
onpaws / gist:d92c6abb69a4870f3094
Created January 27, 2015 04:58
screaming fast imaging on mac (dcfldd or dd)
date; sudo dcfldd if=/dev/disk3 of=/Volumes/TRANSFER/"WDC WD75 00AAKS-00RBA0.dd" ibs=32k obs=4k conv=sync,noerror hashwindow=0 hash=sha1 hashlog=hash_sha1.txt; date
#via http://www.anguas.com/?p=1160
#install paragon NTFS or similar.
@onpaws
onpaws / run-tests-over-git
Created March 11, 2015 17:37
run a test suite over git revisions
(set -e && git rev-list --reverse master~3..master | while read rev; do git checkout $rev; python runtests.py; done)
# set -e causes shell to stop while loop on test error
# via Gary Bernhardt
@onpaws
onpaws / batch-like-all
Created March 16, 2015 20:53
batch like all facebook
/*via http://n8henrie.com/2015/03/how-to-batch-like-all-facebook-posts-on-a-page-with-jquery-2/
open javascript console & copy paste jquery latest from
http://code.jquery.com/jquery-latest.min.js
*/
$('a.UFILikeLink[title="Like this"]').each(
function(i, e){
this.click()
}
@onpaws
onpaws / removeQuarantine.sh
Created October 14, 2015 08:52
fix for so-called 'corrupt' apps
xattr -d com.apple.quarantine /path/to/file
@onpaws
onpaws / ArrayUtils.js
Last active May 26, 2016 07:48
.join(), .map(), toUpperCase(), .indexOf()
//Reactive Programming
//http://reactivex.io/learnrx/
//Patrick's favorite exercises to practice:
//20,
names = ['Jerry','Wang','Shane','Omni']
names.map(x => x[0].toUpperCase() + x.slice(1))
//Search array
names.indexOf('Jerry') //returns 0 ---- JS arrays are zero-based
@onpaws
onpaws / json2file
Created December 1, 2015 23:08
Download JSON data as a file
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
@onpaws
onpaws / compress.sh
Last active December 4, 2015 07:05
optimize web frontend
gif2png -n -O image.gif
pngcrush -brute image.png image-crushed.png
jpegtran -copy none -optimize -perfect -outfile new.jpg orig.jpg
#-copy none removes metadata
gifsicle -O2 orig.gif -o new.gif
#good for *animated* gifs
@onpaws
onpaws / align.css
Created December 17, 2015 08:32
vertical and horizontal align
#pond {
display: flex;
justify-content: center;
align-items: center;
}