Skip to content

Instantly share code, notes, and snippets.

View mriddle's full-sized avatar

Matthew Riddle mriddle

View GitHub Profile
@mriddle
mriddle / git_reverting_multiple_commits.sh
Created January 25, 2012 02:49
[git foo] reverting multiple commits in one hit
# Below is the strat on reverting multiple commits while rolling forward rather than winding back
$ git reset --hard f7a4ffb0291f5fab47dd539a47e04bbd659e138
# Where the SHA is the known good version you want to be back at
$ git reset --soft @{1}
# Which brings you back to origin head with the changes off the past commits reversed
# eg
# [-console.log("Loosing")-]{+console.log("Winning")+}
# becomes
# [+console.log("Winning")+]{-console.log("Loosing")-}
@mriddle
mriddle / gist:1675779
Created January 25, 2012 10:41
Moving your work to other machines without pushing to master
# Commit your work locally and from the remote machine run
$ git pull dev@devmac-2:~/projects/atlas/atlas master
@mriddle
mriddle / coloured_git_output
Created May 11, 2012 23:18
Colour your git terminal output
git config --global color.ui true
@mriddle
mriddle / postgres_table_sizes
Created June 7, 2012 07:17
Finding the total size of your biggest tables
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
LIMIT 20;
@mriddle
mriddle / chef_solo_bootstrap.sh
Created September 9, 2012 06:32 — forked from cmaitchison/chef_solo_bootstrap.sh
Ubuntu 12.04 Chef-Solo bootstrap (VPSBlocks)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
ADMIN_USER=admin
ADMIN_GROUP=admin
#add admin group
(cat /etc/group | grep -E '\b$ADMIN_GROUP\b') || sudo groupadd $ADMIN_GROUP
#add admin user
@mriddle
mriddle / gist:3824002
Created October 2, 2012 23:35
Formtastic custom html_safe input
## html_safe_intput.rb
# encoding: UTF-8
class HtmlSafeInput < Formtastic::Inputs::TextInput
# Called dynamically, via form.input :foo, :as => :html_safe
def to_html
return super if object[method].blank?
input_wrapping do
label_html <<
@mriddle
mriddle / show-remote-branch-info.sh
Created October 4, 2012 22:19 — forked from michaelkirk/show-remote-branch-info.sh
sort remote branches by age
#!/bin/sh
#
# Too many crusty old git branches? Run this to find likely candidates for deletion
# It lists all the remote branches and sorts them by age.
#
# Folks at pivotal shared this with me
#
#$ . show-remote-branch-info.sh
# 2012-05-04 09:42:29 -0700 4 minutes ago Ted & Bill \torigin/hey_Bill
#!/usr/bin/env bash
set -e
set -x
### How To Use
#
# sudo bash -c 'bash \
# <(curl -sLB https://raw.github.com/gist/1209226/bootstrap_chef_server.sh) \
# --hostname foo.example.com'
#
@mriddle
mriddle / knife.rb
Created November 8, 2012 20:56
Basic knife configuration for chef server
### Chef Knife config example
# https://github.com/fnichol/chef-bootstrap-repo/blob/master/.chef/knife.rb
###
# Environment variables required:
# CHEF_SERVER_URL - IP or url of your chef server
# CHEF_USER - Initial user
# AWS_ACCESS_KEY - AWS Access ID found here https://portal.aws.amazon.com/gp/aws/securityCredentials
# AWS_SECRET_KEY - AWS Secrete key found in link above
@mriddle
mriddle / knife_basics.md
Last active July 20, 2019 19:09
Using knife

Using Knife

Basic configuration

How to knife the chef

  • Uploading cookbooks
    knife cookbook upload -a
    Will upload all cookbooks
  • Updating cookbooks from source
    knife cookbook site vendor cookbook_name # e.g. jenkins
  • Adding roles knife role from file path/filename.ext #e.g. roles/jenkins_node.json