Skip to content

Instantly share code, notes, and snippets.

Avatar
🎮

Stephen Coley srcoley

🎮
View GitHub Profile
@srcoley
srcoley / resqueNotifications.js
Last active Aug 29, 2015
Resque Notifications
View resqueNotifications.js
(function(){
var failedCount = null;
var checkFailedInterval;
function getNotificationPrivileges(){
if (Notification.permission !== "granted")
Notification.requestPermission();
}
function checkFailedCount(){
@srcoley
srcoley / gist:5142268
Created Mar 12, 2013
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.
View gist:5142268
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
View jquery.centerToParent.js
/*
* 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 Aug 8, 2012
BatSignal - Automate Github Deploy
View batsignal.sh
#!/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 Mar 20, 2012
refer_id_filter - changes the referid of any given url
View gist:2138263
<?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;
View social_stuff.php
<?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 Feb 3, 2012
Metis 0.2 - A Divine Solution for Aliases
View metis.sh
#!/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 Oct 4, 2011
Determine browser version if Internet Explorer, and give the body element a respective class.
View jIE
var b = $.browser;
if(b.msie) {
var v = b.version.split('.')[0];
$('body').addClass("ie ie" + v);
}