Skip to content

Instantly share code, notes, and snippets.

View kamarcum's full-sized avatar
:fishsticks:

Keith Marcum kamarcum

:fishsticks:
  • Portland, Oregon
View GitHub Profile
@kamarcum
kamarcum / gist:9486644
Created March 11, 2014 14:18
Find your tallest postgres tables
ActiveRecord::Base.connection.execute("SELECT relname, reltuples FROM pg_class where relname NOT LIKE 'pg_%' ORDER BY reltuples DESC LIMIT 10;").each { |row| puts row }
@kamarcum
kamarcum / doit.sh
Created June 25, 2014 18:43
Inspect requests on a server with rack
gem install rack ; echo "run Proc.new { |env| puts env.inspect; ['200', {'Content-Type' => 'text/html'}, [env.inspect]] }" >> hax.ru ; rackup hax.ru
@kamarcum
kamarcum / keybase.md
Created October 2, 2014 19:36
keybase.io

Keybase proof

I hereby claim:

  • I am kamarcum on github.
  • I am marcumka (https://keybase.io/marcumka) on keybase.
  • I have a public key whose fingerprint is CB99 CCE3 96C2 713F F5E4 539D 86A5 4353 248A F6FC

To claim this, I am signing this object:

@kamarcum
kamarcum / Paste
Created October 5, 2011 16:05
JRuby bundler puzzlement
$ sudo jruby -S bundle install
Could not find rake-0.9.2 in any of the sources
$ sudo jruby -S gem list
*** LOCAL GEMS ***
bundler (1.0.21)
rake (0.9.2)
rubygems-update (1.6.0)
sources (0.0.1)
@kamarcum
kamarcum / ErrorBehavior.java
Created July 10, 2012 18:41
Fiddling with error behavior in Java
public abstract class ErrorBehavior<T extends Exception> {
public abstract void handle(T e);
public class SilentErrorBehavior extends ErrorBehavior {
@Override
public void handle(T e) {
}
}
@kamarcum
kamarcum / doit.rb
Created September 13, 2012 17:36
STRINGS ARE FUN
puts "Hello" + " world"
puts "What is your name?"
name = gets.chomp
def do_a_funny_cheer(probably_keith)
puts "laugh at #{probably_keith}"
# Give me a K! ad nauseum
end
do_a_funny_cheer(name)
# fizz buzz would be really cool here since they know %
# these are comments you don't have to type them
@kamarcum
kamarcum / gist:3965475
Created October 27, 2012 17:44
Rudely reclaim port 3000.
kill -9 `lsof -i :3000 -F p | cut -c 2-10`
alias gorailsgo='kill -9 `lsof -i :3000 -F p | cut -c 2-10` ; rails s'
@kamarcum
kamarcum / student_controller.rb
Created November 19, 2012 16:17
A probably incorrect live-coded eTag example that doesn't use the eTag middleware
class StudentController < ApplicationController
def show
existing_etag = request.headers["if-none-match"]
student = Student.where(id: params[:id]).first
if(existing_etag)
type, id, modified = existing_etag.split("_")
if(type == student && id == params[:id])
if(student.updated_at == modified)
render :not_modified and return
end
@kamarcum
kamarcum / do_these_things
Last active December 14, 2015 21:49
This is how I set up development machines sometimes.
1. Xcode
2. xcode command line tools
3. git
4. brew install libksba autoconf automake apple-gcc42 qt imagemagick libxml2 postgres tmux macvim
5. fix imagemagick library names (see below)
6. x11
7. rvm
8. dotmatrix
@kamarcum
kamarcum / gist:5547845
Created May 9, 2013 14:37
Basic format for standups
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Status">
<xs:complexType>
<xs:sequence>
<xs:element name="Location">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="The Office" />
<xs:enumeration value="Remote" />