Skip to content

Instantly share code, notes, and snippets.

View oggy's full-sized avatar

George Ogata oggy

  • Rhino
  • New York, NY
View GitHub Profile
@oggy
oggy / deathsie-previews.user.js
Last active September 16, 2021 07:31
Hover previews for Deathsie's tier lists
// ==UserScript==
// @name Deathsie Card Previews
// @namespace Violentmonkey Scripts
// @include https://docs.google.com/spreadsheets/d/e/2PACX-1vR1eo40sfGoZ-MLxXZsGRHEeAWlKBHYxLFGbTY64l0ZFmsXN25iXOHRYvN7Dt4AsCalgj_RK7KAMr9G/pubhtml
// @grant none
// @version 1.0
// @author George Ogata
// @description 9/13/2021, 1:34:27 AM
// ==/UserScript==
@oggy
oggy / make-mtg-deck
Created January 29, 2017 04:48
Generate a Magic: The Gathering deck from a Cockatrice card database.
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'set'
require 'nokogiri'
CARDS_PATH = '~/Library/Application Support/Cockatrice/Cockatrice/cards.xml'
@oggy
oggy / git-prune-remote-branches
Created October 8, 2015 18:32
Command to delete old remote branches
#!/usr/bin/env ruby
require 'time'
class App
CUTOFF_DAYS = 30
def initialize(args)
args.size <= 1 or
abort "USAGE: #$0 [remote]"
@oggy
oggy / git-delete-merged-branches
Created October 8, 2015 18:26
Command to delete git branches that have been merged into the current branch
#!/usr/bin/env ruby
keep = `git config git-delete-merged-branches.persist`.strip.split(',')
puts "preserving: #{keep.join(', ')}"
current_branch = `git rev-parse --abbrev-ref HEAD`.strip
`git branch --merged`.lines.each do |line|
next if line =~ /\A\* /
branch, target = line.strip.split(' -> ', 2)
next if keep.include?(branch) || keep.include?(target)
@oggy
oggy / r.rb
Created May 16, 2015 11:29
Homebrew formula for R 3.1.2
class RDownloadStrategy < SubversionDownloadStrategy
def stage
quiet_safe_system "cp", "-r", @clone, Dir.pwd
Dir.chdir cache_filename
end
end
class R < Formula
homepage "http://www.r-project.org/"
url "http://cran.rstudio.com/src/base/R-3/R-3.1.2.tar.gz"
@oggy
oggy / git-delete-merged-branches
Created June 5, 2014 18:30
Script to delete merged git branches, and preserve ones you care about
#!/usr/bin/env ruby
keep = `git config git-delete-merged-branches.persist`.strip.split(',')
puts "preserving: #{keep.join(', ')}"
current_branch = `git rev-parse --abbrev-ref HEAD`.strip
`git branch --merged`.lines.each do |line|
next if line =~ /\A\* /
branch, target = line.strip.split(' -> ', 2)
next if keep.include?(branch) || keep.include?(target)
@oggy
oggy / aquamacs
Created March 6, 2014 18:08
Command line program for Aquamacs
#!/usr/bin/env ruby
######################################################################
#
# Open the given file names in Aquamacs.
#
# If the user already has an Aquamacs process open, use it.
# Otherwise, fire up a new one. Only Aquamacs instances without a
# controlling terminal (i.e., those running in a window) will be
# selected.
@oggy
oggy / goliath-vs-unicorn
Created February 21, 2013 22:31
Demonstrates the superiority of Goliath over Unicorn for a single-process app handling file uploads. Also a fine excuse to use gems named Unicorn, Thor, and Goliath in a single ruby script.
#!/usr/bin/env ruby
# Demonstrates the superiority of Goliath over Unicorn for a single-process app
# handling file uploads.
#
# This program runs in 3 modes:
#
# ./goliath-vs-unicorn goliath - Runs the goliath server on the default port (9000)
# ./goliath-vs-unicorn unicorn - Runs the unicorn server on the default port (8080)
# ./goliath-vs-unicorn upload - Upload 5 files in parallel to the port given by -p
class Person
attr_reader :full_name, :age, :profession, :favorite_food
def initialize(full_name, age, profession, favorite_food)
@full_name = full_name
@age = age
@profession = profession
@favorite_food = favorite_food
end
end
@oggy
oggy / gist:4237218
Created December 7, 2012 22:56
Make ActiveRecord ignore columns, so you can drop them without downtime.
ActiveRecord::Base.class_eval do
def self.ignore_columns(*names)
extend ColumnIgnorance
ignored_columns.merge names.map(&:to_s)
end
module ColumnIgnorance
def columns
return @columns if @columns
@columns = super.reject do |column|