Skip to content

Instantly share code, notes, and snippets.

@jch
jch / tips.md
Last active December 13, 2015 18:48

Collection of Everyday Tips

Also see The Lazy Programmer

Mac

  • cmd-shift-t open last tab (sometimes preserves input) via @atmos
  • option-shift-volume|brightness increase/decrease brightness or volume by quarter increments
  • cmd-shift-3 whole screenshot
  • cmd-shift-4 select screenshot. Click space and it'll let you choose a window.
  • cmd-shift-g in finder, go to folder. tab completion available
@jch
jch / test.md
Created February 12, 2013 02:36
@jch
jch / en.yml
Created December 28, 2012 00:15 — forked from anonymous/en.yml
# find this file in config/locales/en.yml
# http://guides.rubyonrails.org/i18n.html
# https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml
number:
currency:
format:
delimiter: ","
format: "%u%n"
negative_format: "(%u%n)" # <-- wrap negative numbers in parenthesis
precision: 2
@jch
jch / namespace.sh
Created December 4, 2012 03:17
Namespace ruby files with a module
#!/bin/sh
# Usage:
#
# find app -name *.rb | xargs -L1 ./namespace.sh
#
sed -i.bak -e '
/^class/ {
# prepend namespace
i\
@jch
jch / elasticsearch-emails.sh
Created November 1, 2012 03:27
experimenting with elasticsearch and email searches
#!/bin/sh
# Start fresh
curl -q -XDELETE 'localhost:19200/emails?pretty' 2>1 1>/dev/null
# Create index 'emails' with a mapping for type 'user', and settings for
# custom email analyzers
echo "Create Index"
curl -XPUT 'localhost:19200/emails?pretty' -d '{
"settings": {
@jch
jch / gist:3919611
Created October 20, 2012 00:51
Annoying Web Things
* asking for a country when it's easily derived
* listing different states in a country dropdown
* all browser autocomplete forms
@jch
jch / retirement-notes.md
Created October 19, 2012 00:20
Retirement Notes
@jch
jch / test-unitfy.rb
Created September 19, 2012 19:02
Turn shoulda formatted tests into traditional test-unit format
#!/usr/bin/env ruby
banner = <<-USAGE
Turn shoulda formatted tests into traditional test-unit format
Edit in place:
find test -name '*_test.rb' | xargs ruby -p -i.bak test-unitfy.rb
Preview:
curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar xzvf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
./configure --enable-shared --disable-pthread --program-suffix n
make && make install
@jch
jch / yard-mount.rb
Created July 2, 2012 18:17
mount yard documentation at /docs
# 1) Running a raw RackAdapter in config.ru mounted at '/' works fine
require 'bundler/setup'
require 'yard'
run YARD::Server::RackAdapter.new(
{'surfiki' => [YARD::Server::LibraryVersion.new('surfiki', nil, File.expand_path('../.yardoc', __FILE__))]},
{
:single_library => true,
:caching => false
})