Skip to content

Instantly share code, notes, and snippets.

View plainprogrammer's full-sized avatar

James Thompson plainprogrammer

View GitHub Profile
@plainprogrammer
plainprogrammer / .bash_profile
Created September 30, 2015 20:24
Kevin's PS1
%{$PROMPT_SUCCESS_COLOR%}%~%{$reset_color%} %{$GIT_PROMPT_INFO%}$(git_prompt_info)%{$GIT_DIRTY_COLOR%}$(git_prompt_status) %{$reset_color%}%{$PROMPT_PROMPT%}ᐅ%{$reset_color%}

Keybase proof

I hereby claim:

  • I am plainprogrammer on github.
  • I am plainprogrammer (https://keybase.io/plainprogrammer) on keybase.
  • I have a public key whose fingerprint is BF75 7722 AE10 7AE8 4C85 9DE5 5A1F 973B AEB0 18AF

To claim this, I am signing this object:

@plainprogrammer
plainprogrammer / example.rb
Created November 22, 2014 22:59
Renewable Objects (Immutability by Default) — A more Functional way to do OOP
class Person
include Renewable
attr_accessor :name, :age
def celebrate_birthday
self.renew(age: age + 1)
end
end
john = Person.new(name: 'John', age: 24)
@plainprogrammer
plainprogrammer / PlainBot.rb
Last active August 29, 2015 14:09
plainprogrammer's RRobot tank-bot
class PlainBot
include Robot
def tick(events)
get_up_to_speed
turn(2) if (time % turn_adjust == 0)
if events['robot_scanned'].empty?
turn_gun(1)
else
closest = events['robot_scanned'].sort.pop.pop
@plainprogrammer
plainprogrammer / Directions.md
Last active August 29, 2015 14:07
MongoDB Forced Reconfiguration

Directions

  1. On the primary, edit /etc/mongod.conf so that it will start and join the evgrs replica set.

  2. On the primary, restart mongod

  3. Get into a mongo console, and run the following series of commands:

    // First we need to connect to the mongo console and copy the current configuration. cfg = rs.conf()

namespace :failover do
desc 'Roll failover back to primary database configuration'
task :primary do
File.delete('config/database.yml')
symlink('database.primary.yml', 'config/database.yml')
end
end
desc 'Failover to secondary database configuration'
task :failover do
@plainprogrammer
plainprogrammer / README.md
Created January 27, 2014 17:17
FoundationDB Sandbox with RVM in Vagrant (Virtualbox and VMware)

FoundationDB Sandbox

The provided Vagrant file and BASH provisioning script will setup a Precise 64 environment with version 1.0.1 of FoundationDB installed and ready to go, along with a working RVM environment.

Requirements

The Vagrantfile expects the vagrant-exec plugin to be present.

@plainprogrammer
plainprogrammer / README.md
Created January 27, 2014 17:09
FoundationDB Sandbox in Vagrant (Virtualbox and VMware)

FoundationDB Sandbox

The provided Vagrant file and BASH provisioning script will setup a Precise 64 environment with version 1.0.1 of FoundationDB installed and ready to go.

@plainprogrammer
plainprogrammer / .bash_profile
Last active December 10, 2015 05:08
Custom BASH prompt including username, working directory, git branch and status on one line; followed by a simple prompt that reflects the exit status of the last command.
source /usr/local/etc/bash_completion.d/git-prompt.sh
function parse_git_dirty {
local retval=$?
[[ $(git status 2> /dev/null | tail -n1) != "" && $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
return $retval
}
function parse_git_branch {
local retval=$?
@plainprogrammer
plainprogrammer / readyproject-soa-template.rb
Created November 19, 2012 21:48
The Ready Project Ruby Application Templates
require 'rvm'
rvm_env = RVM::Environment.new("jruby")
rvm_env.gemset_create(app_name)
rvm_env.gemset_use!(app_name)
create_file ".rvmrc", "rvm use jruby@trpsoa-#{app_name} --create"
run "rm README.rdoc"
run "rm doc/README_FOR_APP"