This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
class GoogleAnalytics | |
def initialize(app,id) | |
@app = app | |
@id = id | |
end | |
def call(env) | |
status,headers,response = @app.call(env) | |
response.each do |part| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parser | |
attr_accessor :results | |
@@default_services = {} | |
def parse(document) | |
document = Nokogiri::XML(document).remove_namespaces! | |
found = false | |
@@default_services.each do |service, content| | |
if document.xpath(content[:identifier]).length > 0 | |
self.send("parse_#{service.to_s}", document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getParam(name){ | |
var pathRegex = new RegExp(name + '\/([^\/]+)'), | |
searchRegex = new RegExp(name + '=([^&]+)'), | |
match; | |
match = (window.location.pathname.match(pathRegex) || window.location.search.match(searchRegex)); | |
if (!match) return false; | |
return match[1]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var old_timeout = setTimeout; | |
setTimeout = function(fn, timeout) { | |
if (Math.round(Math.random() * 6) === 1) { | |
throw 'The cogs of the software industry are greased by the blood of unwary developers. Today that blood is yours.' | |
} else { | |
old_timeout(fn, timeout); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UACompatible | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
status, headers, response = @app.call(env) | |
headers['X-UA-Compatible'] = 'IE=edge,chrome=1' | |
[status, headers, response] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
event = ARGV[0] | |
if event == 'songstart' | |
d = Hash.new | |
STDIN.each_line { |line| d.store(*line.chomp.split('=', 2)) } | |
File.open('/path/to/home/.config/pianobar/current-song.txt', 'w') do |f| | |
f.write("#[bg=colour39,fg=colour8]♫ #{d['title']} - #{d['artist']} @ #{d['stationName']} #[fg=default,bg=default]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
if [ -z `ps aux | grep 'pianobar$'` ]; then | |
echo '' | |
else | |
cat /Users/zpendleton/.config/pianobar/current-song.txt | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns last-fm.track-stream | |
(require [clj-http.client :as client]) | |
(use cheshire.core)) | |
(def api-key "...") | |
(def current-song (atom {})) | |
(def uri "http://ws.audioscrobbler.com/2.0/") | |
(defn next-song [user] | |
(decode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# coding: utf-8 | |
require 'digest/md5' | |
require 'net/http' | |
class LastFM | |
attr_reader :api_key, :secret, :session_key, :base_uri, :namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
sub event_message_public() { | |
my ($server, $text, $nick, $address, $target) = @_; | |
if ($text =~ /g\/\d+/) { | |
$text=~s/g\/(\d+)/https:\/\/gerrit.instructure.com\/#\/c\/$1/g; | |
Irssi::signal_emit('message public', $server, $text, $nick, $address, $target); | |
Irssi::signal_stop(); |
OlderNewer