Skip to content

Instantly share code, notes, and snippets.

@petermac-
petermac- / 1-nginx.conf
Last active September 12, 2015 19:38
nginx.conf
# nginx
 
description "nginx http daemon"
author "George Shammas <[email protected]>"
 
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
 
env DAEMON=/usr/sbin/nginx
env PID=/var/run/nginx.pid
@petermac-
petermac- / 1-flushdns-yosemite.sh
Last active September 12, 2015 19:38
flushdns-yosemite.sh
sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;say flushed
@petermac-
petermac- / 1-anidb_year_filter.js
Last active September 12, 2015 19:38
anidb_year_filter.js
// ==UserScript==
// @name AniDB Year Filter
// @namespace http://techexplored.io
// @version 0.1
// @description Removes rows from the anime show lists based on year.
// @match http://anidb.net/perl-bin/animedb.pl?type.web=1*
// @copyright 2014+, Peter MacDonald
// @run-at document-start
// ==/UserScript==
@petermac-
petermac- / SassMeister-input.scss
Created March 18, 2015 19:31
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// Breakpoint (v2.5.0)
// Modular Scale (v2.0.6)
// ----
@import "modular-scale";
@import "breakpoint";
@petermac-
petermac- / 1-debounce.js
Last active September 12, 2015 19:38
debounce.js
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
@petermac-
petermac- / 1-poll.js
Last active September 12, 2015 19:15
poll.js
function poll(fn, callback, errback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if(fn()) {
callback();
}
// If the condition isn't met but the timeout hasn't elapsed, go again
@petermac-
petermac- / 1-once.js
Last active September 12, 2015 19:14
once.js
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
return result;
@petermac-
petermac- / 1-getAbsoluteUrl.js
Last active September 12, 2015 19:14
getAbsoluteUrl.js
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
@petermac-
petermac- / 1-polling-deferred.js
Last active September 12, 2015 19:14
polling-deferred.js
// The polling function
function poll(fn, timeout, interval) {
var dfd = new Deferred();
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if(fn()) {
dfd.resolve();
@petermac-
petermac- / 1-polling.js
Last active September 12, 2015 19:14
polling.js
function poll(fn, callback, errback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if(fn()) {
callback();
}
// If the condition isn't met but the timeout hasn't elapsed, go again