Skip to content

Instantly share code, notes, and snippets.

@malpinder
malpinder / git_repo_redaction
Last active February 8, 2017 16:06
This removes obvious references to the author from a given git repo.
# This removes obvious references to the author from a given git repo.
# This isn't foolproof - you'll have to trust that interviewers won't go digging.
# re-write the branch so that the author email, name, and committer are replaced with the candidate’s reference.
# if there are any branches other than master, you'll need to run that command on those separately.
git filter-branch -f --prune-empty --env-filter 'GIT_AUTHOR_EMAIL=redacted@example.com; GIT_AUTHOR_NAME="XX"; GIT_COMMITTER_NAME="XX"; export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME GIT_COMMITTER_NAME'
# remove any remotes - check what they are called and replace `origin` if necessary
git remote rm origin
@malpinder
malpinder / current_salary.txt
Last active January 10, 2022 11:08
This is my current salary.
I currently earn £49,776 (GBP) each year as Head of Development for a charity, working a 4-day week, in central London.
@malpinder
malpinder / gist:76b70ea0fd2f0fcf375b
Last active February 19, 2016 13:59
Some SQL to make a little test setup for explaining joins.
CREATE TABLE people (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(20),
age INT(10)
);
CREATE TABLE dogs (
id INT AUTO_INCREMENT PRIMARY KEY,
person_id INT(10),
name VARCHAR(20)
);
@malpinder
malpinder / hopelessly_egocentric_spec.rb
Last active August 29, 2015 14:21
Hopelessly egocentric objects that make Rspec mock expectations explode.
require 'spec_helper'
# https://github.com/raganwald-deprecated/homoiconic/blob/master/2009-02-02/hopeless_egocentricity.md
class HopelesslyEgocentric < BasicObject
def method_missing(*args, &block)
self
end
# These methods are required to make the tests output their failures normally.
@malpinder
malpinder / Gemfile
Created April 15, 2014 09:51
Example modular Sinatra app
source 'https://rubygems.org'
gem 'totally_cool_art', git: "https://github.com/shjohnson/TotallyCoolArt"
gem 'sinatra'
group :test, :development do
gem 'rspec'
end
@malpinder
malpinder / cheats.txt
Created April 2, 2014 17:01
SQL cheatsheet
Basic select:
SELECT * FROM users;
Selecting only some columns:
SELECT id, name FROM users;
Aliasing columns:
@malpinder
malpinder / moon.rb
Created March 24, 2014 12:56
A more readable version of Aaron Patterson's moon tweet. https://twitter.com/tenderlove/status/435590528025899008
moon_id=0x1F311
loop do
8.times do |i|
delete = ("\b"*6)
moon = [moon_id+i].pack("U")
spaces = (" "*5)
line = delete + moon + spaces
print(line)
sleep(0.1)
end
@malpinder
malpinder / module_cheatsheet.rb
Created March 20, 2014 09:01
Modules cheatsheet
# Modules can be used for namespacing...
module Whizz
class SoundEffect
def noise
"Whizzo!"
end
end
class Popper
@malpinder
malpinder / adventure.rb
Created March 19, 2014 18:17
Refactoring excercise. A version of adventure.rb that has been refactored to a degree.
# I'm less sorry but still a bit sorry.
class Adventure
def rooms
{
room_one: "You are in a maze of twisty little passages, all alike",
room_two: "It is dark here. You are likely to be eaten by a grue.",
room_three: "It is dark here."
}
@malpinder
malpinder / adventure.rb
Created March 18, 2014 11:07
Refactoring excercise. Make this thrashing leviathan of code into something a bit more understandable, before it devours us all.
# I'm so, so sorry.
class Adventure
def run
@location = :north
puts "You are in a maze of twisty little passages, all alike"
puts "What do you do?"
result = gets.chomp