Skip to content

Instantly share code, notes, and snippets.

View fredkelly's full-sized avatar

Freddy Kelly fredkelly

View GitHub Profile
@mojavelinux
mojavelinux / middleman-asciidoctor.adoc
Last active August 29, 2015 13:56
Instructions for configuring AsciiDoc in Middleman 3.

How to enable AsciiDoc in a Middleman 3 site

Follow these steps to setup AsciiDoc in a Middleman 3 site.

Note
Middleman 4 will require the use of the middleman-asciidoc gem.
@gregolsen
gregolsen / gist:5378320
Created April 13, 2013 13:01
simple way to get routes info
require 'rails/application/route_inspector'
all_routes = Rails.application.routes.routes.select { |r| r.defaults[:controller] =~ /api\/v1/ }
inspector = Rails::Application::RouteInspector.new
pp inspector.format(all_routes, 'api/v1/inboxes').map { |x| x.split(' ') }
# [["api_v1_inbox",
# "POST",
# "/api/v1/inboxes/:id(.:format)",
# "api/v1/inboxes#update"],
# ["api_v1_inboxes",
@mcls
mcls / rtmp_meta.rb
Created May 14, 2013 14:10
Quick hack to fetch duration of RTMP stream using rtmpdump v2.4.
require 'forwardable'
module RtmpMeta
class Parser
PATTERN = /duration\s+(?<duration>\d+\.?\d+)$/
attr_reader :raw_data
def initialize raw_data
@raw_data = raw_data
end
@MrAlexLau
MrAlexLau / airbrake.rb
Created June 27, 2013 13:25
How to ignore Sidekiq exceptions in Airbrake for a rails project.
#config/initializers/airbrake.rb
Airbrake.configure do |config|
config.api_key = 'mySecretKeyGoesHere'
config.ignore << "CustomSidekiqException" #do not report our custom exceptions to Airbrake
end
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= FoundationLinkRenderer
super.try :html_safe
end
class FoundationLinkRenderer < LinkRenderer
protected
bindkey '^R' history-incremental-pattern-search-backward
HISTSIZE=100000
SAVEHIST=100000
setopt hist_ignore_all_dups
setopt inc_append_history extendedglob share_history
. /etc/profile.d/autojump.zsh
@venj
venj / com.yourcompany.autossh.plist
Created May 30, 2012 14:39
Put following gist to ~/Library/LaunchAgents, and then run: launchctl load /Users/your_name/Library/LaunchAgents/com.yourcompany.autossh.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OnDemand</key>
<false/>
<key>KeepAlive</key>
<true/>
@jefflarkin
jefflarkin / gpio.sh
Last active April 13, 2018 22:15
BASH functions for using the C.H.I.P. GPIO pins.
#!/bin/bash
#FIXME Add usage() function to improve documentation
# Enable exposure of the specified GPIO pin (0-8)
gpio_enable()
{
if [[("$1" -lt 0) || ("$1" -gt 8)]] ; then
echo "Valid pins are 0-8"
return -1;
fi
@peterhellberg
peterhellberg / api.go
Last active January 18, 2019 01:58
A tiny example API written in Go using Martini and Redigo
package main
import (
"flag"
"fmt"
"net/http"
"github.com/codegangsta/martini"
"github.com/garyburd/redigo/redis"
"github.com/martini-contrib/render"
@elliottkember
elliottkember / spotify.applescript
Created February 22, 2012 12:45
Spotify Applescript
property baseURL : "http://statusboard.dev/song?"
if application "Spotify" is running then
tell application "Spotify"
set theTrack to name of the current track
set theArtist to artist of the current track
set theAlbum to album of the current track
set theurl to spotify url of the current track
try
do shell script "/usr/local/bin/wget --delete-after \"" & baseURL & "&t=" & theTrack & "&a=" & theArtist & "&al=" & theAlbum & "\""