Skip to content

Instantly share code, notes, and snippets.

View timrwood's full-sized avatar

Tim Wood timrwood

View GitHub Profile
@timrwood
timrwood / popup.txt
Last active December 21, 2015 19:39
Youtube + Vimeo Popup Bookmarklett
javascript:!function(){var h=location.href,y=h.match(/(youtu.be\/|v\/|u\/\w\/|embed\/|v=)([^#\&\? ]*).*/),v=h.match(/(vimeo.com\/)([^#\&\? ]*)/);y=y&&'http://www.youtube.com/watch_popup/?v='+y[2];v=v&&'http://player.vimeo.com/video/'+v[2];window.open(y||v,"_blank","height=345,width=560");}()
@timrwood
timrwood / livereload.html
Created July 19, 2013 17:47
Live Reload Snippet
<script>
(function(d) {
var g = d.createElement('script'),
s = d.scripts[0];
g.src = '//' + location.hostname + ':35729/livereload.js';
s.parentNode.insertBefore(g, s);
}(document));
</script>
@timrwood
timrwood / index.html
Created July 18, 2013 02:37
Approximating an answer to the Quarter Tank Problem http://mathworld.wolfram.com/Quarter-TankProblem.html
<canvas></canvas>
<style>canvas{background:#ddd;}</style>
<script>
var canvas = document.getElementsByTagName('canvas')[0];
var ctx = canvas.getContext('2d');
var step = 0.01;
var pctx = 0.50;
var pcty = 0.06;
canvas.width = canvas.height = 400;
(function () {
function Server(){
this.clients = [];
}
Server.prototype.spawn = function () {
var i;
for (i = 0; i < 100000; i++) {
this.clients.push(new Client(this));
}
var higgiesAge = new Number(6);
var phoneLives = new Number(3);
var higgiesAgeInt = higgiesAge.valueOf();
var phoneLivesInt = phoneLives.valueOf();
var higgiesRealAge = higgiesAgeInt * phoneLivesInt;

Via user guide

Ignoring Files

If you have files in your sync folder that you don’t want BitTorrent Sync to track, you can use .SyncIgnore.

.SyncIgnore is a UTF-8 encoded .txt file that helps you specify single files, paths and rules for ignoring during the synchronization job. It supports ‘?’ and ‘*‘ wildcard symbols.

Note that .SyncIgnore is applied only to the folder where it is contained and will not work with the files that have already been synced.

@timrwood
timrwood / js.js
Created March 30, 2013 21:13
Active class on click.
var nav = $('nav');
$(window).on('click', function (e) {
// we clicked inside the nav
if ($(e.target).closest(nav).length) {
nav.addClass('active');
} else {
nav.removeClass('active');
}
});
@timrwood
timrwood / moment.twitter.js
Last active December 14, 2015 15:09
Moment.js Twitter compliant feed display.
moment.fn.twitter = function () {
var diff = moment().diff(this, 'seconds');
return diff < 60 ? diff + 's' :
diff < 3600 ? ~~(diff / 60) + 'm' :
diff < 86400 ? ~~(diff / 3600) + 'h' : this.format('D MMM');
}
@timrwood
timrwood / steps.md
Last active December 14, 2015 07:49
Grunt upgrade steps

Switch to the new grunt CLI

npm uninstall -g grunt
npm install -g grunt-cli

Add the correct grunt version to your package.json

@timrwood
timrwood / Material
Last active December 10, 2015 20:08
Shader enums
// used for diffuse, normal, and specular map
string textureName
string reflectionTextureName
vec4 ambientColor
vec4 diffuseColor
float diffuseIntensity
vec4 specularColor