Skip to content

Instantly share code, notes, and snippets.

@corporealfunk
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
@corporealfunk
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
corporealfunk / download_apache_index.sh
Created July 5, 2011 15:23
download all files in typical Apache web directory "index" page
curl --silent http://example.com/images/loggedout/ | grep "a href" | grep png | cut -d ' ' -f 8 | cut -d '=' -f 2 | cut -d '"' -f 2 | sed "s/^/http:\/\/example.com\/images\/loggedout\//" | xargs wget
@corporealfunk
corporealfunk / chef_server_install.sh
Created December 20, 2011 02:27
install chef server on ubuntu
!#/bin/sh
echo "deb http://apt.opscode.com/ `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 keys.gnupg.net --recv-keys 83EF826A
gpg --export packages@opscode.com | 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
corporealfunk / static.ru
Created March 6, 2012 07:55
Serving static files with Rack
root=Dir.pwd
puts ">>> Serving: #{root}"
run Rack::Directory.new("#{root}")
# using thin:
# thin -R static.ru start
RSpec.configure do |config|
config.filter_run_excluding :remote => true
config.before :each, :remote => true do
# Configure code to hit the Braintree service
end
end
# Include your remote specs within your "normal" specs
describe Sweeper do
@corporealfunk
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?
@corporealfunk
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
corporealfunk / fix_spork.sh
Created May 7, 2012 17:58
Fix Spork 0.9.0+ permissions problems in system-wide RVM installs
#!/bin/bash
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
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:https://guides.rubyonrails.org/engines.html#overriding-models-and-controllers
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)
end
end