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: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
@jordan-brough
jordan-brough / google-url-shortener-bookmarklet.js
Created November 22, 2017 16:48
Goo.gl URL shortener bookmarklet
// Step 1: Get an API key here: https://developers.google.com/url-shortener/v1/getting_started#APIKey
// Step 2: Paste your api key below
// Step 3: Add the code below to your browser as a bookmark
// Step 4: Visit a non-goo.gl URL and click your bookmark
// NOTE: The security policy of some sites (such as this gist.github.com!) will prevent this from working.
// Check your javascript console if something doesn't work.
javascript:(function(){
var googleApiKey = 'INSERT YOUR API KEY HERE';
# 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 April 8, 2024 02:53
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 / DefaultKeyBinding.dict
Last active April 9, 2024 16:29
MacOS checkmark keybinding
// Installation:
// 1. Save this file as /Users/YOUR_USER_NAME_HERE/Library/KeyBindings/DefaultKeyBinding.dict
// 2. Log out and log back in (or just restart any app where you'd like to use the shortcut)
// What: Keyboard shortcut to easily insert checkmarks. (Or whatever text you'd like to insert).
// By default option+v in MacOS inserts a square-root symbol: √
// I've often used option+v as a quick-and-dirty checkmark. This shortcut lets me get a real checkmark.
{
// Insert a checkmark with option+v