Skip to content

Instantly share code, notes, and snippets.

@srcoley
srcoley / resqueNotifications.js
Last active August 29, 2015 14:20
Resque Notifications
(function(){
var failedCount = null;
var checkFailedInterval;
function getNotificationPrivileges(){
if (Notification.permission !== "granted")
Notification.requestPermission();
}
function checkFailedCount(){
@srcoley
srcoley / gist:5142268
Created March 12, 2013 11:42
A data uri that uses inline css and javascript to turn your browser into a notepad. The javascript converts tab keystrokes into four spaces as presented here: http://stackoverflow.com/questions/1105452/catching-tabs-in-textarea. Tapping tab otherwise, would cause the textarea to lose focus.
data:text/html, <html><head><style>html, body {height:100%;}#text-area {width: 100%;height: 100%;color: #868686;font-size: 18px;font-family: Helvetica;border: 0px;letter-spacing: 1px;outline: none;}</style></head><body><textarea id="text-area"></textarea><script type="text/javascript">function insertAtCursor(a,b){if(document.selection){var c;a.focus(),sel=document.selection.createRange(),c=sel.text.length,sel.text=b,0==b.length?(sel.moveStart("character",b.length),sel.moveEnd("character",b.length)):sel.moveStart("character",-b.length+c),sel.select()}else if(a.selectionStart||"0"==a.selectionStart){var d=a.selectionStart,e=a.selectionEnd;a.value=a.value.substring(0,d)+b+a.value.substring(e,a.value.length),a.selectionStart=d+b.length,a.selectionEnd=d+b.length}else a.value+=b}document.getElementById("text-area").onkeydown=function(a){a||9!=event.keyCode?9==a.keyCode&&(a.preventDefault(),insertAtCursor(document.getElementById("text-area")," ")):(event.returnValue=!1,insertAtCursor(document.getElementById("text-ar
@srcoley
srcoley / jquery.centerToParent.js
Created November 9, 2012 17:15
jQuery.centerToParent
/*
* jQuery.centerToParent
* Centers an element within it's parent.
*
* Usage:
*
* To center along both x and y axes: $(el).centerToParent();
* To center along the x axis only: $(el).centerToParent("x");
* To center along the y axis only: $(el).centerToParent("y");
*
@srcoley
srcoley / batsignal.sh
Created August 8, 2012 22:48
BatSignal - Automate Github Deploy
#!/usr/bin/bash
# Author: Stephen Coley @coleydotco
#
# This script automates a Github deploy.
# I use it with Alfred to deploy http://coley.co.
#
# Change the stuff surrounded in [..]
#
# You must run git pull in the terminal and
# copy the line that asks you for your password.
@srcoley
srcoley / gist:2138263
Created March 20, 2012 17:08
refer_id_filter - changes the referid of any given url
<?php
function referid_filter($url, $refer_id) {
$regex = "%http[s]*\:\/\/www\.hccmis\.com\/[\w-\/]+\?referid=(\d*)%";
if(preg_match($regex, $url, $matches)) {
if($matches[1] == "") {
return $url . $refer_id;
} else {
$url_arr = explode("?referid=", $url);
return $url_arr[0] . "?referid=" . $refer_id;
@srcoley
srcoley / social_stuff.php
Created February 15, 2012 17:21
Social Stuff
<?php
/*
* Plugin Name: Social Stuff
* Description: Allows users to befriend or follow one-another. Also tracks events such as commemts and follows so they they can be displayed in an activity feed.
* Version: 0.1
* Author: Stephen Coley
* Author URI: http://coley.co
* License: GPL2
*
*
@srcoley
srcoley / metis.sh
Created February 3, 2012 13:03
Metis 0.2 - A Divine Solution for Aliases
#!/bin/bash
# Metis - A Divine Solution for Aliases
# by Stephen Coley @coleydotco 2012
## Install ##
# %> git clone git://gist.github.com/1730076.git
#
# Initialized empty Git repository in ~/1730076/.git/
# remote: Counting objects: 25, done.
@srcoley
srcoley / jIE
Created October 4, 2011 19:03
Determine browser version if Internet Explorer, and give the body element a respective class.
var b = $.browser;
if(b.msie) {
var v = b.version.split('.')[0];
$('body').addClass("ie ie" + v);
}