Skip to content

Instantly share code, notes, and snippets.

View rubysolo's full-sized avatar

Solomon White rubysolo

View GitHub Profile
mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
@rubysolo
rubysolo / repl.rb
Last active December 12, 2015 06:09
def accept_and_run_command
loop do
print "enter command> "
input = gets.chomp.split(/\s+/)
case input.first
when "foo" then puts "got command 'foo'"
when "bar" then puts "got command 'bar'"
else
puts "Sorry, but I don't know how to '#{ input.first }'!"
@rubysolo
rubysolo / verification.txt
Created January 31, 2013 02:56
verification of all missing gem files I had cached locally on my system
006e83de634b6c49493bbd01b5599fe4070ba8175f5fefb3ae430d3594a2744608aacbb0832385de202520f50c99938e3b4372de75603f158139e2141ad80a9c sidekiq-2.5.4.gem
01dac9f0ed3570e2c13acc912d40c310cab137e1a340bd4e935a4bf026ae1c9707b3abac628c7b46bd38fac1bd9b0dc10d521f8d7425e511d6615c800846ff27 columnize-0.3.4.gem
03304f3603829d974b3c64bcc8e8f73e0506b54e259da5198357eef67551322e5905902ad924e719083096df27af6200dd8634c2d8ef23dc1c3db7e48d0d2400 unicorn-4.5.0.gem
0505f51a9478ba7d67c029dfbc4075aca028605d4ca035d0385371c55340cfd3b923d2e5dc026d2a7d1bdf72ecdcc203d362296af041fd13d50cfc99782e6cc8 kgio-2.8.0.gem
080a7755644f341d90b1c619a603060b889b89ae69457db119bd456798a0a23918da25c010e4b5d67ca8511bb7d0282c679d16d8dfabcfaac360c486af8ec0e3 rack-1.4.4.gem
08a8288b96a89e1587fddd5cecb665b084a5798391fc314aa9475499807d710e3912176b4087385065ae0d3a60075576d4d02019cecec3b8b8f05b735c16743c actionpack-2.3.15.gem
0a845fc04eee488ea1c9e12581b5dc3a59e823a6811cc4cb4bb2f90241d1d32feb9815faa91c878a3477d05cc4cd323ac4a83a48937214eb36af30c9c6d0e694 debugg
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
1 class Report < ActiveRecord::Base¬
2 attr_accessible :user_id, :evidence, :location, :time, :perpetrator_id, :new_perpetrator, :bounty, :active¬
3 attr_accessor :new_perpetrator¬
4 ¬
5 before_validation :create_new_perpetrator¬
6 ¬
7 belongs_to :perpetrator¬
8 belongs_to :user¬
9 ¬
10 scope :active, where(active: true)¬
@rubysolo
rubysolo / unicorn__connections_.rb
Created December 11, 2012 14:23
munin plugin to monitor unicorn connection queue
#!/usr/bin/env ruby
# Copyright: 2011 Opscode, Inc.
# Author: Bryan McLellan <[email protected]>
# Solomon White <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@rubysolo
rubysolo / tasks_controller_refactoring.rb
Created November 12, 2012 21:28 — forked from blowmage/tasks_controller_refactoring.rb
Variation of RubyTapas episode "021 Domain Model Events" without using callbacks
class TasksController < ApplicationController
def update
if @task.update_attributes(params[:task])
tracker = TaskTracker.new(@task.previous_changes)
TaskPusher.new(tracker, socket_id).push_changes
TaskMailSender.new(tracker, current_user).deliver_email
# success response
else
# failure respond
end
@rubysolo
rubysolo / README.txt
Created October 24, 2012 16:08 — forked from i-scorpion/README.txt
Twitter bootstrap fixed table header using jQuery
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
# encoding: binary
# Removes any bytes from a string that are not valid UTF-8
class Cleaner
attr_reader :bytes, :buffer, :outstanding
def self.clean(str)
new.tap { |c| c << str }.to_s
end
@rubysolo
rubysolo / preso.md
Created August 10, 2012 02:19 — forked from jamesward/preso.md
Den of Clojure

Heroku @ Den of Clojure


About James Ward

Java Developer since: 1997 >