Skip to content

Instantly share code, notes, and snippets.

View jaredhabeck's full-sized avatar

Jared Habeck jaredhabeck

  • Ethisphere
  • Boulder, CO
View GitHub Profile
We couldn’t find that file to show.
@jaredhabeck
jaredhabeck / cook.py
Created January 9, 2018 20:32
cooking converter
# Cooking Converter Project Ver1.03
"""Changelog
ver1.03
- removed clearscreen function for now
- units now print full names
- script gives plural unit when necessary
- fractions implemented but not printing human-readable
"""
from __future__ import division
@jaredhabeck
jaredhabeck / git_branch_cleaner.sh
Last active May 11, 2016 15:34
This script is for cleaning up merged branches on remote, it will only check merged and also outputs relevant information, then prompts for action. It also prunes the origin if deletes were made.
#!/bin/bash
count=0
# grab remote merged branches, ignoring master and HEAD
for x in `git branch --merged master -r --column | grep -v HEAD | grep -v master`; do
branch="${x/origin\//}"
mod=$(git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $x | head -n 1)
# get the number of commits the remote branch is behind/ahead of master
set -- $(git rev-list --left-right --count origin/$branch...origin/master)
ahead=$1
@jaredhabeck
jaredhabeck / clean_remote_git_branches.sh
Created November 3, 2015 16:48
A bash script to clean up remote branches that pile up. Use '-r <remote>' to specify a remote such as 'origin'.
#!/bin/bash
_check_options() {
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "options:"
echo "-h, --help show brief help"
echo "-r, --remote=ORIGIN remote repository to target"
exit 0
;;
def merge_sort(array_a, array_b)
(array_a + array_b).sort
end
merge_sort([3,1,7,5,9], [4,2,6,8,0])
# => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
$('#coverflip').jcoverflip({
current: flipItemCount,
beforeCss: function( el, container, offset ){
console.log(container);
return [
$.jcoverflip.animationElement( el, { 'transform':'skew(0deg, 30deg)', left: ( container.width( )/2 - 280 - 190 *offset )+'px', bottom: '60px' }, {}),
$.jcoverflip.animationElement( el.find( 'img' ), { opacity: 0.7, width: '175px', height: '175px' }, {} )
];
},
afterCss: function( el, container, offset ){
// Make sure you have a parent element that wraps the checkboxes you want to check has an ID set
// in this case it's "interest" - so <fieldset id="interest">.
$('#checkall').click(function(e) {
e.preventDefault();
$('#interest').find('input[type="checkbox"]').each(function(item) {
if ($(this).attr('checked')) {
$(this).attr('checked', false);
} else {
$(this).attr('checked', true);
@jaredhabeck
jaredhabeck / rspec-syntax-cheat-sheet.rb
Created June 15, 2012 21:28 — forked from irohiroki/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@jaredhabeck
jaredhabeck / reloadbrowser.sh
Created April 17, 2012 16:26
osascript to reload chrome or firefox, make reloadbrowser.sh available to watchr via PATH or otherwise...
#!/usr/bin/osascript
-- setting to return focus to the initial calling app (in my case it's Textmate)
set callingApp to (path to frontmost application as Unicode text)
-- tell application "Google Chrome"
-- activate
-- end tell
--
-- tell application "System Events"
@jaredhabeck
jaredhabeck / gist:1628718
Created January 17, 2012 20:32
Facebook PHP SDK - check access token validity
<?php
// this follows the assumption that you've already instantiated the facebook SDK
// e.g. $facebook = new Facebook();
// The key is the first api() call - you need to try to access something which requires the access token
// you are attempting to validate.
// e.g. if your access token has *no* special permissions you could use $facebook->api('/me'),
// which is the most basic permission level.
try {