Skip to content

Instantly share code, notes, and snippets.

@mikepack
mikepack / capybara-notification.txt
Created March 20, 2013 20:04
This is a comparision of handling JavaScript alert/confirm/prompt notifications with Capybara.
This is a comparision of handling JavaScript alert/confirm/prompt notifications with Capybara.
Proposed consolidated API in Capybara:
There are two styles of notification handling: proactive or reactive.
- Proactive is used in headless environments to queue up responses.
- Reactive is used in environments with actual notifications that mandate a response (eg selenium).
alert - # Reactive
page.driver.accept_alert
@joekiller
joekiller / gtk-firefox.sh
Last active October 1, 2024 21:25 — forked from phstc/gtk-firefox.sh
INSTALL FIREFOX ON AMAZON LINUX X86_64 COMPILING GTK+
#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Joseph Lawson 2012-06-03
# http://joekiller.com
# http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/
# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh
@eyeced
eyeced / nginx.conf
Created October 26, 2012 11:23
Nginx server configuration with Unicorn for a spree site, running ssl and non-ssl side by side
upstream unicorn {
server unix:/tmp/unicorn.store.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# To enable ssl on your server for checkout and admin functionality
# add this line
listen 443 ssl;
@alexbevi
alexbevi / pre-commit.sh
Created August 23, 2012 12:05
Git pre-commit hook that checks ruby source files for Pry breakpoints
# Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files
# for Pry binding references
#
# Installation
#
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
#
# Based on
#
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
@danvine
danvine / call_me_baby.rb
Created August 9, 2012 12:25
Cron job to call and connect you to your daily scrum via Twilio
require 'twilio-ruby'
require 'yaml'
account_sid = 'AC--------------------------------'
auth_token = '--------------------------------'
config = {
:from => '+15555555555', # your twilio verified phone number
:to => '+15558675309', # your phone number
:url => 'http://yourdomain.com/scrum/?call=18886191583&pass=555555555' # where the Twiml XML file below is hosted
@trcarden
trcarden / gist:3295935
Created August 8, 2012 15:28
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@clarle
clarle / app.js
Created July 26, 2012 07:35
Short tutorial on how to use Express and node-mysql
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
class User < ActiveRecord::Base
has_many :cars
end
class Color < ActiveRecord::Base
belongs_to :car
delegate :name, :to => :car, :prefix => true
end
class Car < ActiveRecord::Base
@jlecour
jlecour / README.md
Created October 10, 2011 20:33
Identify paperclip attachment files that are not attached to any record

Let's say you have a model, with an files attached, using Paperclip. You have a couple millions of those files and you're not sure that every one of them (and all its thumbnails) are still used by a database record.

You could use this rake task to recursively scan all the directories and check if the files need to be kept or destroyed.

In this example, the model is called Picture, the attachment is image and the path is partitioned like images/001/412/497/actual_file.jpg

The task is going down the path. Each time the path ends with 3 triplets of digits ("001/412/497" for example) it looks for a record with the ID 1412497. If such a record doesn't exist, the whole directory is moved to a parallel images_deleted directory. At the end you can delete the files if you like, or move them to an archive location.

You can use the "dry run" mode : to print which files would be removed

@michaelward82
michaelward82 / show.html.erb
Created September 8, 2011 12:30
Dynamic page parts in RefineryCMS
<% left_col_content = @page.content_for(:left_column) %>
<% content_content = @page.content_for(:content) %>
<% right_col_content = @page.content_for(:right_column) %>
<% if (!left_col_content && !!content_content && !right_col_content) -%>
<%= render :partial => 'content', :object => @page,
:locals => { :css => "grid_12 alpha omega" } %>
<% end -%>
<% if (!!left_col_content && !!content_content && !right_col_content) -%>
<%= render :partial => 'leftcol', :object => @page,