Skip to content

Instantly share code, notes, and snippets.

View switchspan's full-sized avatar

Ken Taylor switchspan

  • Viking Sasquatch
  • Chesapeake, VA
View GitHub Profile
@switchspan
switchspan / gist:5536508
Created May 7, 2013 21:58
Partition function - James Edward Gray II's ruby implementation
# The partition (combinatoric partition theory) function for a given number
def partition(largest, rest = Array.new, &block)
block.call([largest] + rest)
(rest.first || 1).upto(largest / 2) do |i|
partition(largest - i, [i] + rest, &block)
end
end
# call the partition function with "5" as a test
partition(5) { |nums| p nums if nums[0] != 5 }

Ruby on Rails development setup on Ubuntu 12.04

System update

# change mirror to ubuntu.osuosl.org first
sudo apt-get update

Install common libraries

sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev

@switchspan
switchspan / Gemfile
Created July 27, 2013 19:52
RAILS: Test Gist
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
# Add Foundation Here
gem 'compass-rails' # you need this or you get an err
@switchspan
switchspan / IE10_pie_notes.md
Created August 18, 2013 15:36
NOTES: IE10 css border-image hack

IE 10 CSS Border Hack

border-image

Option 1 (Fall back)

From Microsoft Blog and html5please:
Internet Explorer 10 doesn’t include support for CSS border-image. To preserve the layout of your page, a best practice is to specify a solid border-style fallback so border widths, padding, and margin are preserved. (If IE doesn’t find a supported border type, it will discard those values.) For example:

Before:

@switchspan
switchspan / README.md
Last active August 29, 2015 14:25 — forked from hofmannsven/README.md
@switchspan
switchspan / brew-install-missing-unix-tools
Created June 24, 2016 13:13 — forked from evnm/brew-install-missing-unix-tools
A brew command to install useful tools missing from Mac OS X
# Legitimately-useful utilities missing from OS X.
brew install wget watch gnu-sed coreutils
# Up-to-date versions of included tools.
brew install git emacs
# Just for fun.
brew install fortune cowsay
@switchspan
switchspan / README-Template.md
Created March 4, 2017 14:42 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@switchspan
switchspan / postgres
Created October 12, 2017 18:44 — forked from mmrwoods/postgres
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@switchspan
switchspan / postgres-cheatsheet.md
Created October 15, 2017 21:11 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes