Skip to content

Instantly share code, notes, and snippets.

View jordan-brough's full-sized avatar

Jordan Brough jordan-brough

View GitHub Profile
@AndrewRadev
AndrewRadev / ack-gems
Created December 20, 2012 14:15
Use 'ack' to search through all the gems in the project. Call with "bundle exec ack-gems".
#! /usr/bin/env ruby
require 'bundler'
paths = Bundler.load.specs.map(&:full_gem_path)
system("ack '#{ARGV[0]}' #{paths.join(' ')}")
@damncabbage
damncabbage / random.rb
Created August 23, 2013 01:37
Generate a random string of 0-9, a-z characters in Ruby.
require 'securerandom'
length = 10
SecureRandom.random_number(36 ** length).to_s(36) # Base 36, ie. 0..9 + a..z
# => "9datwwkqlo"
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_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';
@diriver63
diriver63 / pyodbc-unixODBC-lambda-layer
Last active January 24, 2024 09:32
pyodbc and unixODBC for MSSQL as a lambda layer
# use https://github.com/lambci/docker-lambda to simulate a lambda environment
docker run -it --rm --entrypoint bash -e ODBCINI=/opt/odbc.ini -e ODBCSYSINI=/opt/ lambci/lambda:build-python3.7
# download and install unixODBC
# http://www.unixodbc.org/download.html
curl ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.7.tar.gz -O
tar xzvf unixODBC-2.3.7.tar.gz
cd unixODBC-2.3.7
./configure --sysconfdir=/opt --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --prefix=/opt
@psanford
psanford / meraki_strongswan_notes.md
Last active February 20, 2024 06:52
connect to meraki client vpn from strongswan (ubuntu 16.04 edition)

These are my notes for connecting to a meraki client vpn from ubuntu 16.04. This configuration assumes you are using a psk for the ipsec auth.

Install the following packages:

apt-get install -y strongswan xl2tpd

Configure strong swan

@cdesch
cdesch / rails_generator_cheat_sheet.md
Last active March 30, 2024 09:07
Rails Generator CheatSheet

Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.

Command Line Generator Info

Reference

You can get all of this information on the command line.

rails generate with no generator name will output a list of all available generators and some information about global options. rails generate GENERATOR --help will list the options that can be passed to the specified generator.

@JuggoPop
JuggoPop / Git branch bash autocomplete *with aliases*
Created April 15, 2014 06:23
Git branch bash autocomplete *with aliases* (add to .bash_profile)
# To Setup:
# 1) Save the .git-completion.bash file found here:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# 2) Add the following lines to your .bash_profile, be sure to reload (for example: source ~/.bash_profile) for the changes to take effect:
# Git branch bash completion
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
# Add git completion to aliases
@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