Skip to content

Instantly share code, notes, and snippets.

@nick-jonas
nick-jonas / bubbles-dom.js
Last active August 29, 2015 13:57
Animating bubbles using the transform property on multiple DOM elements
// 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(':');
@nick-jonas
nick-jonas / keyframe-animation.scss
Created February 5, 2014 21:53
Compass Keyframe Animation
@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 / analyzespectrum.py
Created August 23, 2013 17:16
Analyze sound spectrum at 30 fps, from Mr. Doob's post: http://ricardocabello.com/blog/post/677
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 / gist:5531169
Created May 7, 2013 08:42
.bash_profile: tab completion for SSH hostnames on ~/.ssh/config
# 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 / ssh_easy_access.sh
Created April 29, 2013 05:38
Add ssh key to remote server for easy access (no typing in password). Just swap 'user' and 'server'
cat ~/.ssh/id_rsa.pub | ssh user@server 'mkdir -p ~/.ssh; cat >> .ssh/authorized_keys'
@nick-jonas
nick-jonas / orphan.js
Created March 5, 2013 17:18
Add &nbsp; between last two words in a body of text to avoid orphans.
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 / isretina.js
Created February 26, 2013 18:46
Javascript conditional for retina screens
isRetina = ((window.devicePixelRatio===undefined?1:window.devicePixelRatio)>1);
@nick-jonas
nick-jonas / amdconditional.js
Created February 14, 2013 15:00
Conditional AMD Support via this blog post: http://dailyjs.com/2011/12/22/framework/
var myModule = {
awesome: 'not really'
};
if (typeof define === 'function' && define.amd) {
define('myModule', [], function() {
return myModule;
});
}
<div class="threesixty" data-path="assets/img/src/gem{index}.JPG" data-count="61"></div>
$(document).ready(function(){
$('.threesixty').threeSixty({
dragDirection: 'horizontal'
});
});