Skip to content

Instantly share code, notes, and snippets.

View jonathanhculver's full-sized avatar

Jon Culver jonathanhculver

View GitHub Profile
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}"
# Customized git status
git_custom_status() {
local cb=$(git_current_branch)
if [ -n "$cb" ]; then
echo "$(parse_git_dirty)[$cb]"
fi
}
@jonathanhculver
jonathanhculver / index.html
Last active August 29, 2015 14:22
Front End Onboarding// source http://jsbin.com/piyuze
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1/prototype.js"></script>
<meta charset="utf-8">
<title>Front End Onboarding</title>
<script type="text/javascript">
document.observe("dom:loaded", function() {
nxj.frontend.init();
});
playlistModule.addTrack('a');
playlistModule.addTrack('b');
playlistModule.addTrack('c');
playlistModule.addTrack('d');
playlistModule.getTracks()
["a", "b", "c", "d"]
playlistModule.shuffleTracks()
["d", "c", "a", "b"]
@jonathanhculver
jonathanhculver / playlist.js
Last active August 29, 2015 13:57
Javascript module pattern for Spotify Playlist
var playlistModule = (function() {
/* private var */
var tracksArray = [],
shuffleArray = [];
/* public methods */
var addTrack = function(uri) {
tracksArray.push(uri);
return tracksArray;
@jonathanhculver
jonathanhculver / tape_measure_js.js
Created January 23, 2014 02:38
tape measure JS
/* click and drag */
new Draggable('tape_measure_drag', { constraint: 'horizontal', handle: 'tape_measure_drag',
onDrag: function(e) {
var offset = $('tape_measure_drag').positionedOffset().left;
var value = ((offset-140)/80)*-1;
value = (Math.round(value * 4) / 4).toFixed(2);
if(value > 0) {
$('measurementInput').value = value;
}
@jonathanhculver
jonathanhculver / tape_measure_style.css
Created January 23, 2014 02:34
tape measure style
/* container div for tape measure background */
.tape_measure_back {
background: url("//imga.nxjimg.com/emp_image/apparel/measurements/tapemeasure/background.jpeg") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 60px;
margin: 10px auto 0;
overflow: hidden;
position: absolute;
width: 320px;
}
@jonathanhculver
jonathanhculver / tape_measure.haml
Created January 23, 2014 02:27
tape measure haml
#measurementsContainer
.measurements_sub_title Virtual Tailor
#tape_measure.tape_measure_back
#tape_measure_drag.tape_measure_inches
%ul.numbers
- (0...81).each do |i|
%li
%label= i
%img.tapemeasure_needle{:src => "//imga.nxjimg.com/emp_image/apparel/measurements/tapemeasure/pointer.gif"}
%input.nxj_input{:placeholder => "15", :id => "measurementInput"}
@jonathanhculver
jonathanhculver / contacts.rb
Created January 15, 2014 02:54
iterating through a vcf file to add a field
load 'vpim-13.11.11/lib/vpim/vcard.rb'
#read file as string
address_book = File.open('contacts.vcf')
contents = address_book.read
#load contacts
original = Vpim::Vcard.decode(contents)
#create new file
@jonathanhculver
jonathanhculver / snapshot.js
Created September 1, 2013 18:23
webrtc snapshot from webcam
function snapshot() {
if (localMediaStream) {
var img = document.querySelector('img');
/* draws the image to the canvas */
ctx.drawImage(video, 0, 0);
/* loads the img to the hidden img tag */
img.src = canvas.toDataURL('image/webp');
img.style.display= "block";
}
}
@jonathanhculver
jonathanhculver / stream.js
Created September 1, 2013 18:20
javascript for webrtc webcam stream
window.onload = function() {
var video = document.querySelector('video');
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
var localMediaStream = null;
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;