Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Jonas nick-jonas

View GitHub Profile
View threesixty-js-example.js
$(document).ready(function(){
$('.threesixty').threeSixty({
dragDirection: 'horizontal'
});
});
View threesixty-html-example.html
<div class="threesixty" data-path="assets/img/src/gem{index}.JPG" data-count="61"></div>
View amdconditional.js
var myModule = {
awesome: 'not really'
};
if (typeof define === 'function' && define.amd) {
define('myModule', [], function() {
return myModule;
});
}
@nick-jonas
nick-jonas / isretina.js
Created Feb 26, 2013
Javascript conditional for retina screens
View isretina.js
isRetina = ((window.devicePixelRatio===undefined?1:window.devicePixelRatio)>1);
@nick-jonas
nick-jonas / orphan.js
Created Mar 5, 2013
Add &nbsp; between last two words in a body of text to avoid orphans.
View orphan.js
var orig = 'My sample body text',
split = orig.split(' '),
lastTwo = split.splice(split.length - 2);
lastTwo = lastTwo.join('&nbsp;');
split = split.join(' ') + ' ' + lastTwo;
orig = split;
// orig = 'My sample body&nbsp;text'
@nick-jonas
nick-jonas / ssh_easy_access.sh
Created Apr 29, 2013
Add ssh key to remote server for easy access (no typing in password). Just swap 'user' and 'server'
View ssh_easy_access.sh
cat ~/.ssh/id_rsa.pub | ssh user@server 'mkdir -p ~/.ssh; cat >> .ssh/authorized_keys'
@nick-jonas
nick-jonas / gist:5531169
Created May 7, 2013
.bash_profile: tab completion for SSH hostnames on ~/.ssh/config
View gist:5531169
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
@nick-jonas
nick-jonas / analyzespectrum.py
Created Aug 23, 2013
Analyze sound spectrum at 30 fps, from Mr. Doob's post: http://ricardocabello.com/blog/post/677
View analyzespectrum.py
import math
import struct
import wave
import sys
w = wave.open(sys.argv[1], 'rb')
# We assume 44.1k @ 16-bit, can test with getframerate() and getsampwidth().
sum = 0
value = 0;
delta = 0;
@nick-jonas
nick-jonas / keyframe-animation.scss
Created Feb 5, 2014
Compass Keyframe Animation
View keyframe-animation.scss
@import "compass/css3/transform";
@import "compass/css3/transition";
@mixin animation($animate...) {
$max: length($animate);
$animations: '';
@for $i from 1 through $max {
$animations: #{$animations + nth($animate, $i)};
@nick-jonas
nick-jonas / bubbles-dom.js
Last active Aug 29, 2015
Animating bubbles using the transform property on multiple DOM elements
View bubbles-dom.js
// updates the position of a bubble element
updatePosition: function($elem, x, y){
var value = 'translate3d(' + x + 'px, ' + y + 'px, 0.1px)';
// use Modernizr to get all the vendor prefixes
value = Modernizr._prefixes.join('transform' + ':' + value + '; ');
value = value.split(';');
var props = {};
// create an object to apply the vendor prefixed CSS properties
for(var i = 0; i < value.length; i++){
var thisVal = value[i].split(':');