Skip to content

Instantly share code, notes, and snippets.

View plainprogrammer's full-sized avatar

James Thompson plainprogrammer

View GitHub Profile
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 / 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()

@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 / 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)

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 / nginx.conf
Created June 17, 2011 20:36
Orabrush Unicorn Application Server Configs
worker_processes 5;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
@plainprogrammer
plainprogrammer / Capfile
Created October 11, 2011 21:41
A Capfile for Node.js deployment
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
##################################
# Edit these
set :application, "app_name"
set :node_file, "server.js"
set :host, "app.example.com"
set :repository, "git://github.com/example/example.git"
set :branch, "master"
set :deploy_to, "/var/apps/#{application}"
---
:verbose: true
gem: --no-ri --no-rdoc
:update_sources: true
:sources:
- http://gems.rubyforge.org
:backtrace: false
:bulk_threshold: 1000
:benchmark: false
@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%}
audio = Audio.first
configuration = RefNetAdmin::Application.config.zencoder
id = audio.id
bucket = configuration['bucket']
base_path = configuration['base_path']
options = {
input: audio.file.url(:original),
outputs: [