Skip to content

Instantly share code, notes, and snippets.

corporealfunk / spina_embedded_image_tag_helper.rb
Last active March 11, 2021 21:39
Force SpinaCMS admin panel to not inject the host:port into the urls
# SpinaCMS will inject image URLs into the Trix content with the host:port as part of the URL
# This makes it hard to port that DB content to another host (say move from localhost to a production or staging site)
# load this patch from the config/application.rb like so:
Spina::ImagesHelper.class_eval do
def embedded_image_url(image)
return "" if image.nil?
main_app.polymorphic_path(image.variant(resize: Spina.config.embedded_image_size), only_path: true)
corporealfunk /
Created May 7, 2012 17:58
Fix Spork 0.9.0+ permissions problems in system-wide RVM installs
sudo find /usr/local/rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0 -name "*.rb" -exec chmod go+r {} \;
sudo find /usr/local/rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0 -name "spork" -exec chmod g+r {} \;
sudo find /usr/local/rvm/gems/ruby-1.9.2-p290/gems/spork-0.9.0 -type d -exec chmod go+rx {} \;
sudo chmod -R g+rw /usr/local/rvm/gems/ruby-1.9.2-p290/gems
corporealfunk / js.rake
Created May 2, 2012 00:22
Rake Task generate JS Routes functions
desc "Generate a JavaScript file that contains your Rails routes"
namespace :js do
task :routes, [:filename] => :environment do |t, args|
filename = args[:filename].blank? ? "rails_routes.js" : args[:filename]
save_path = "#{Rails.root}/app/assets/javascripts/#{filename}"
routes = generate_routes_for_rails_3
javascript = ""
routes.each do |route|
javascript << generate_method(route[:name], route[:path]) + "\n"
corporealfunk / .tmux.conf
Created April 19, 2012 23:07
tmux configuration
unbind C-b
set -g prefix C-a
# resize panes with VIM nav keys
bind -r C-h resize-pane -L
bind -r C-j resize-pane -D
bind -r C-k resize-pane -U
bind -r C-l resize-pane -R
# faster tmux escape wait times?
RSpec.configure do |config|
config.filter_run_excluding :remote => true
config.before :each, :remote => true do
# Configure code to hit the Braintree service
# Include your remote specs within your "normal" specs
describe Sweeper do
corporealfunk /
Created March 6, 2012 07:55
Serving static files with Rack
puts ">>> Serving: #{root}"
# using thin:
# thin -R start
corporealfunk /
Created December 20, 2011 02:27
install chef server on ubuntu
echo "deb `lsb_release -cs`-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list
sudo mkdir -p /etc/apt/trusted.gpg.d
gpg --keyserver --recv-keys 83EF826A
gpg --export | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
sudo apt-get update
sudo apt-get install opscode-keyring # permanent upgradeable keyring
sudo apt-get upgrade
sudo apt-get install chef chef-server
corporealfunk /
Created July 5, 2011 15:23
download all files in typical Apache web directory "index" page
curl --silent | grep "a href" | grep png | cut -d ' ' -f 8 | cut -d '=' -f 2 | cut -d '"' -f 2 | sed "s/^/http:\/\/\/images\/loggedout\//" | xargs wget
corporealfunk / .screenrc
Created April 1, 2011 15:04
My .screenrc file
# change the hardstatus settings to give an window list at the bottom of the
# screen, with the time and date and with the current window highlighted
startup_message off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
corporealfunk / .vimrc
Created April 1, 2011 14:57
My .vimrc file
let &t_Co=256
set number
set tabstop=2
set shiftwidth=2
set expandtab
set background=dark
syntax on
set ff=unix
set autoindent
set smartindent