Skip to content

Instantly share code, notes, and snippets.

View spikegrobstein's full-sized avatar

spike grobstein spikegrobstein

View GitHub Profile
@spikegrobstein
spikegrobstein / Gemfile
Created June 19, 2013 10:36
example of my concept implementation degrawlixer for teamonetickets. basic
source 'https://rubygems.org'
gem 'rspec'
gem 'pry'
@spikegrobstein
spikegrobstein / tmux.conf
Last active July 22, 2022 15:23
my tmux config (updated for 2.4)
# This requires tmux 2.1. a lot of these settings will error on anything earlier.
# Act like Vim; use h,j,k,l to select panes and move the cursor
set-window-option -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Look good
## Profiler
## A wrapper for the rblineprof library to pretty-print the profile data
## and enable customization of the output
## Based heavily on tmm1's examples
## This assumes that rblineprof lib is installed in Rails.root + 'vendor/rblineprof/ext'
## https://github.com/tmm1/rblineprof
class Profiler
# see docs for self.log_line method
@@logger = Proc.new { |line| Rails.logger.info line }
@spikegrobstein
spikegrobstein / class.pid_file.php
Created June 4, 2013 10:38
php code to ensure that only n instances of a process are running at a time.
<?
class PIDFileException extends Exception {}
class PIDFileSlotsExhaustedException extends PIDFileException {}
class PIDFileErrorException extends PIDFileException {}
class PIDFileNoBigDealException extends PIDFileException {}
class PIDFileBadPidException extends PIDFileErrorException {}
/**
*
@spikegrobstein
spikegrobstein / deploy.rb
Last active December 16, 2015 16:20
Deploying to multiple environments in a single capistrano command
# This is such a hack. holy shit.
# use it like this:
# cap production deploy sandbox deploy
require 'capistrano/ext/multistage'
set :base_servers, @roles.clone
stages.each do |stage|
before(stage) do
@roles.replace(base_servers)
@spikegrobstein
spikegrobstein / nginx.conf
Last active August 9, 2024 13:42
nginx config for proxying requests for plex over a hostname-based virtualhost.
upstream plex-upstream {
# change plex-server.example.com:32400 to the hostname:port of your plex server.
# this can be "localhost:32400", for instance, if Plex is running on the same server as nginx.
server plex-server.example.com:32400;
}
server {
listen 80;
# server names for this server.
def get_quotes(block_of_text)
lines = block_of_text.split(/\n+/)
lines.map do |line|
m = line.match(/^(.+?):\s+(.+)$/) # match the line
next unless m # skip any lines that don't look like "some name: some text"
[ m[1], m[2] ]
end.compact
end
@spikegrobstein
spikegrobstein / resque-failed-iterator.rb
Created December 11, 2012 23:35
iterate through resque failed jobs
1.upto(Resque::Failure.count) do |i|
job = Resque::Failure.all(i)
# inspect failed job
args = job['payload']['args']
klass = job['payload']['class']
end
@spikegrobstein
spikegrobstein / couchdb.log
Created November 26, 2012 17:08
couchdb compaction log
[Mon, 26 Nov 2012 17:06:54 GMT] [info] [<0.18152.6>] Starting compaction for db "chef"
[Mon, 26 Nov 2012 17:06:54 GMT] [info] [<0.20248.6>] 127.0.0.1 - - 'POST' /chef/_compact 202
[Mon, 26 Nov 2012 17:06:54 GMT] [error] [emulator] Error in process <0.20250.6> with exit value: {{badmatch,no_valid_header},[{couch_db_updater,start_copy_compact,1}]}
[Mon, 26 Nov 2012 17:06:54 GMT] [error] [<0.20251.6>] ** Generic server <0.20251.6> terminating
** Last message in was {'EXIT',<0.20250.6>,
@spikegrobstein
spikegrobstein / chef_compact.sh
Created November 16, 2012 23:39
Chef compaction script run via cron
#! /bin/bash -
curl -H "Content-Type: application/json" localhost:5984/chef
curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_compact
sleep 3
for VIEW in nodes roles registrations clients data_bags data_bags_items users checksums cookbooks sandboxes environments id_map; do
curl -H "Content-Type: application/json" -X POST http://localhost:5984/chef/_compact/$VIEW