Skip to content

Instantly share code, notes, and snippets.

@mathiasbynens
mathiasbynens / change-favicon.js
Created June 7, 2010 12:41
Dynamically changing favicons with JavaScript
/*!
* Dynamically changing favicons with JavaScript
* Works in all A-grade browsers except Safari and Internet Explorer
* Demo: http://mathiasbynens.be/demo/dynamic-favicons
*/
// HTML5™, baby! http://mathiasbynens.be/notes/document-head
document.head || (document.head = document.getElementsByTagName('head')[0]);
function changeFavicon(src) {
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@ches
ches / spec_suites.rake
Created November 29, 2010 18:08
Set up Rake tasks to execute defined sets of specs
# Nice idea from:
# http://kpumuk.info/ruby-on-rails/my-top-7-rspec-best-practices/
#
# ~/test$ rake -T spec:suite
#
# (in /Users/kpumuk/test)
# rake spec:suite:acl # Run all specs in access control spec suite
# rake spec:suite:amazon # Run all specs in Amazon libraries spec suite
SPEC_SUITES = [
@pjkelly
pjkelly / DevelopmentEnvironmentInstructions.markdown
Created December 13, 2010 17:13
Instructions for setting up a Rails development environment using Cinderella

These instructions are for Snow Leopard only.

XCode

Ensure that you have XCode for the version of OS X you're running. These are not installed by default on new machines and can be installed off the OS installation DVD. If you're not sure, run the following command. It should return something like this: /usr/bin/gcc; if it does not, you need to install XCode.

which gcc

SSH Keys

@pjkelly
pjkelly / install-apt-file.sh
Created July 7, 2011 01:00
Not sure what apt-get package contains a file?
# credit: http://crshlv.ly/qkAzW0
#
# I found this especially useful when trying
# to figure out equivalent apt-get packages
# for certain Perl CPAN modules.
apt-get install apt-file
apt-file update
apt-file search URI::Escape
@pjkelly
pjkelly / setup-vmware-image-with-static-IP.markdown
Created July 7, 2011 01:06
VMWare Fusion Images with a static IP Address on Mac OS X Snow Leopard

How to setup your VMWare Fusion images to use static IP addresses on Mac OS X

At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.

When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name ubuntu-lucid-lynx-base a

@mislav
mislav / Gemfile
Created August 31, 2011 21:48
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass'
end
@leshill
leshill / Procfile
Created November 28, 2011 20:01
Unicorn config for cedar stack on Heroku.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@stevenhaddox
stevenhaddox / server_certificates_to_pem.md
Last active December 14, 2023 05:42
Convert .crt & .key files into .pem file for HTTParty

Two ways to do it, but only worked for me so I'll put it first and the second for reference:

$ openssl pkcs12 -export -in hostname.crt -inkey hostname.key -out hostname.p12
$ openssl pkcs12 -in hostname.p12 -nodes -out hostname.pem

Other options for this method in comments below:

# Note, the -certfile root.crt appends all CA certs to the export, I've never needed these so it's optional for my personal steps
$ openssl pkcs12 -export -in hostname.crt -inkey hostname.key -certfile root.crt -out hostname.p12

Note, I've always had my hostname.crt as part of my .pem, so I keep my certs but apparently you may not have to, hence the nocerts flag being an extra option in this sample

@rmetzler
rmetzler / app.rb
Created January 22, 2012 12:51 — forked from jamiehodge/app.rb
Sinatra API for resumable.js
require 'sinatra'
require 'slim'
require 'coffee-script'
require 'sass'
require 'sequel'
DB = Sequel.sqlite
DB.create_table :uploads do
String :id, text: true, primary_key: true