Skip to content

Instantly share code, notes, and snippets.

@robflaherty
robflaherty / gaEventTracking.js
Created February 28, 2010 22:28
Simple Google Analytics event tracking. Tracks external links, downloads, and mailtos
document.onclick = function(event) {
event = event || window.event;
var target = event.target || event.srcElement,
targetElement = target.tagName.toLowerCase();
if (targetElement == "a") {
var href = target.getAttribute("href"),
urlHost = document.domain.replace(/^www\./i,"");
var urlPattern = "^(?:https?:)?\/\/(?:(?:www)\.)?" + urlHost + "\/?";
@robflaherty
robflaherty / fbLikeButton.html
Created June 8, 2010 17:39
Dynamic URL Facebook Like Button
<!-- Like button placeholder -->
<div id="fbLikeBtn"></div>
<!-- Like button script -->
<script>
$(function(){
var fbUrl = encodeURIComponent(location.href),
fbIframe = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + fbUrl + '&amp;layout=standard&amp;show_faces=false&amp;width=300&amp;action=recommend&amp;font=arial&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:35px;" allowTransparency="true"></iframe>';
$("#fbLikeBtn").html(fbIframe);
@robflaherty
robflaherty / gist:567525
Created September 6, 2010 21:17
Script for rotating nginx logs
#!/usr/bin/evn python2.6
# Shell script for rotating/archiving nginx logs
import os
from datetime import datetime
cwd = os.getcwd()
date = datetime.now().strftime("%Y-%m-%d")
#!/bin/bash
curl -k --user USERNAME:PASSWORD -o delicious.xml -O 'https://api.del.icio.us/v1/posts/all'
@robflaherty
robflaherty / cookie.js
Created January 29, 2011 23:13
standalone utility for getting/setting/deleting cookies
//Set initial slide
changeSlide(currentSlide);
//Add this line to make the slides auto-change
autoSlide = setInterval(function() { nextSlide() }, 30000);
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
<!--[if lt IE 9]><script src="/_assets/js/html5-shiv.js"></script><![endif]-->
<link rel="stylesheet" href="/_assets/css/styles.css" media="all" />
<!--[if IE]><link rel="stylesheet" href="/_assets/css/ie.css" media="all" /><![endif]-->
@robflaherty
robflaherty / LICENSE
Created June 18, 2011 15:31 — forked from hugs/LICENSE
The Node.js "Hello World" web server ported to CoffeeScript
I, Jason Huggins, the author of the work "CoffeeScript Web Server" (2010), irrevocably renounce
all current and future legal rights to the work in any medium whatsoever.
I stand behind the merit of the work, but disclaim all liability for it under law.
I encourage you, the audience, to share, copy, distribute, perform, remix, mash up, interpret,
excerpt, translate, and otherwise enjoy and use the work as you will.
I request that you acknowledge my authorship.
var app = (function(testMode) {
//Private methods
var method1 = function() {};
var method2 = function() {};
//Public methods
var method3 = function() {};
var method4 = function() {};
@robflaherty
robflaherty / gist:1129871
Created August 6, 2011 23:14
CoffeeScript and Stylus watch/build cakefile
# CoffeeScript and Stylus watch/build cakefile
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args...) ->
proc = spawn name, args
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
proc.stdout.on 'data', (buffer) -> console.log buffer.toString()
proc.on 'exit', (status) -> process.exit(1) if status isnt 0