Skip to content

Instantly share code, notes, and snippets.

View jordan-brough's full-sized avatar

Jordan Brough jordan-brough

View GitHub Profile
@jordan-brough
jordan-brough / gist:1684779
Created January 26, 2012 20:07
Decode Rails session cookie
cookie = 'XXX--YYY'
ActiveSupport::MessageVerifier.new(Rails.application.config.secret_token).verify(cookie)
@jordan-brough
jordan-brough / gist:1926410
Created February 27, 2012 19:14
ruby count_by using group_by
# See http://jordan.broughs.net/archives/2012/07/enumerablecount_by-for-ruby
# Ruby >= 1.8.7 (incl 1.9.x)
module Enumerable
def count_by(&block)
Hash[group_by(&block).map { |key,vals| [key, vals.size] }]
end
end
// ==UserScript==
// @name GitHub Dashboard Twitter
// @namespace http://tekkub.net/
// @include https://github.com/
// ==/UserScript==
$("div.news h1").before(
$("<div>").attr("id", "twitter_div2").append(
$("<h1>").text("GitHub status ").css({
@jordan-brough
jordan-brough / gist:3452180
Created August 24, 2012 15:48
Extend splunk saved search TTL to 1 year
# 31536000 == 1 year (365 days) in seconds
curl -u <USERNAME>:<PASSWORD> --insecure https://<SPLUNK_URL>:8089/services/search/jobs/<JOB_ID>/control -d action=setttl -d ttl=31536000; echo
@jordan-brough
jordan-brough / instructions.markdown
Created November 3, 2012 13:50
Splunk-friendly timestamp plugin snippet for Sublime Text 2
  1. Choose: Tools > New Plugin

  2. Paste in the contents of "timestamp.py" below

  3. Save as timestamp.py in ~/Library/Application Support/Sublime Text 2/Packages/User/ (should be the default directory that pops up when you save)

  4. Choose: Sublime Text 2 > Preferences > Key Bindings - User

  5. Add:

    { "keys": ["super+ctrl+t"], "command": "timestamp" }

To make command+ctrl+t perform the insertion.
Make sure to add a comma after the previous keymap entry, if present.

@jordan-brough
jordan-brough / compliments.sh
Last active August 29, 2015 13:56
Bash compliments when you clear your screen. You deserve it. ;)
# from https://gist.github.com/jordan-brough/fc085fa50f520ef022c9
# inspired by http://emergencycompliment.com/
function emergency_compliment {
ruby <<RUBY
require "rubygems"
require "json"
today = Time.now.strftime('%Y-%m-%d')
today_filename = "/tmp/compliments-#{today}.json"
latest_filename = "/tmp/compliments-latest.json"
json = if File.exist?(today_filename)
# to always include this in IRB save this to ~/.irbrc.examine and add this to your ~/.irbrc:
#
# load File.expand_path('../.irbrc.examine', __FILE__)
#
module JordanBrough
module Examine
module InstanceMethods
def examine(*attrs, printer: :default)
@jordan-brough
jordan-brough / git-recent
Last active December 4, 2024 06:39
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# See also: https://stackoverflow.com/a/25095062/58876
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Examples:
@jordan-brough
jordan-brough / sandbox.sh
Last active August 29, 2015 14:05
customized spree sandbox
#!/usr/bin/env bash
set -e
cd ~/repos/spree
bundle install --quiet 1> /dev/null || bundle update --quiet
bundle exec rake sandbox