Skip to content

Instantly share code, notes, and snippets.

View timrwood's full-sized avatar

Tim Wood timrwood

View GitHub Profile
@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');
}
});

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.

var higgiesAge = new Number(6);
var phoneLives = new Number(3);
var higgiesAgeInt = higgiesAge.valueOf();
var phoneLivesInt = phoneLives.valueOf();
var higgiesRealAge = higgiesAgeInt * phoneLivesInt;
(function () {
function Server(){
this.clients = [];
}
Server.prototype.spawn = function () {
var i;
for (i = 0; i < 100000; i++) {
this.clients.push(new Client(this));
}
@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;
@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 / 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");}()
import mimetypes
mimetypes.add_type("application/font-woff", ".woff", True)
@timrwood
timrwood / reload.md
Created September 20, 2013 01:19
Bookmarklett to reload all CSS files. X-Treme code-golfed version.
javascript:!function(a,b,c){for(b=a.length;b--;)c=a[b],c.rel.match(/^sty/i)&&c.href&&(c.href=c.href.replace(/(\?|&)_.*/,"$1_"+ +new Date))}(document.querySelectorAll("link"));
@timrwood
timrwood / add-grunt-build-pre-push-hook.sh
Created September 30, 2013 22:09
Add Grunt build pre push git hook
cd $(git rev-parse --show-toplevel)/.git/hooks/ && echo -e '#!/bin/sh\n\ngrunt build' > pre-push && chmod 755 pre-push && cd -