Skip to content

Instantly share code, notes, and snippets.

View jamesmoriarty's full-sized avatar
🔮
0xc0000005

James Moriarty jamesmoriarty

🔮
0xc0000005
View GitHub Profile
@jamesmoriarty
jamesmoriarty / Vagrantfile
Created September 27, 2014 05:18
Vagrant, Ansible, Rbenv and Ruby on Rails
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.box = "precise"
ls --almost-all | head --lines=-1 | xargs rm -r
CREATE OR REPLACE FUNCTION balanced() RETURNS trigger AS $balanced$
DECLARE
balance decimal;
BEGIN
SELECT SUM(postings.amount) INTO balance FROM postings;
IF balance != 0 THEN
RAISE EXCEPTION 'Invalid posting sum. (%)', balance;
END IF;
# Twilio HTTP HAProxy Configuration
# Version: 0.1
global
daemon
log 127.0.0.1 local0 info
maxconn 60000
spread-checks 3
@jamesmoriarty
jamesmoriarty / deploy.rb
Created December 14, 2012 03:38
Sidekiq, Upstart, and Capistrano
namespace :deploy do
namespace :sidekiq do
desc 'Replace upstart config for sidekiq-workers'
task :upstart_config do
data = %Q{
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec su - #{user} -c 'cd #{release_path}; export RAILS_ENV=#{stage}; bundle exec sidekiq -q default,1 -c 4 -pid #{release_path}/tmp/pids/sidekiq.pid >> #{release_path}/log/sidekiq.log 2>&1'
@jamesmoriarty
jamesmoriarty / redis.markdown
Created November 1, 2012 01:48 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@jamesmoriarty
jamesmoriarty / pi.sh
Last active October 4, 2022 12:25
Raspberry Pi - hfs+, external disk, samba, minidlna, transmission
sudo raspi-config
sudo reboot
# mount external disk
sudo apt-get install hfsplus hfsutils hfsprogs
sudo mkdir /media/usb0
sudo nano /etc/fstab
# /dev/sda2 /media/usb0 hfsplus defaults,force,gid=pi,uid=pi,noatime 0 0
sudo chown -R root:users /media/usb0/
sudo chmod -R ug=rwx,o=rx /media/usb0/
@jamesmoriarty
jamesmoriarty / kernel.rb
Created September 18, 2012 06:45
require_relative
# File lib/extensions/kernel.rb, line 38
def require_relative(path)
require File.join(File.dirname(caller[0]), path.to_str)
end
class Account
attr_reader :balance
def initialize(balance)
@balance = balance
end
def receive(amount)
@balance += amount
end
@jamesmoriarty
jamesmoriarty / one.js.coffee
Created July 4, 2012 02:15
Coffeescript Ternary Statements
# toggle order
order = ( order == "desc" ? "asc" : "desc" )
# var order, _ref;
#
# order = (_ref = order === "desc") != null ? _ref : {
# "asc": "desc"
# };