Skip to content

Instantly share code, notes, and snippets.

View unixmonkey's full-sized avatar

David Jones unixmonkey

View GitHub Profile
desc 'Set RAILS_ENV to cucumber, run cucumber and re-set RAILS ENV'
task :cuke do
# save old env
old_env = RAILS_ENV || ENV['RAILS_ENV'] || 'test'
# set to cucumber env
RAILS_ENV = ENV['RAILS_ENV'] = 'cucumber'
# run cucumber
Rake::Task['cucumber'].invoke
#!/bin/bash
# ssh-eternal is a poor-man's clone of ssh-forever
# (http://github.com/mattwynne/ssh-forever)
#
# It's purpose is to run this the first time you connect to a
# remote computer with ssh. This script will then copy your public
# key to the remote computers ~/.ssh/authorized_keys file to
# allow subsequent logins to be done without having to remember
# the remote machine's password every time.
# execute by calling
# rake db:import:from_csv
# RAILS_ENV=production db:import:from_csv to use the production environment
require 'ruport'
namespace :db do
namespace :import do
desc 'import stuff into the database'
" Vim color file
" Converted from Textmate theme Cobalt using Coloration v0.2.3 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
// This javascript file is intened to make redmine_backlogs
// look and behave just a bit more like Pivotal Tracker to
// help ease the transition
$(function(){
// make backlogs less hideous
apply_styles();
// refresh browser every half hour to prevent js memory bloat
@unixmonkey
unixmonkey / Haml.tmLanguage
Created February 8, 2011 17:55
Haml Language definition file for TextMate; modified to work with Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>haml</string>
<string>sass</string>
</array>
<key>foldingStartMarker</key>
@unixmonkey
unixmonkey / Cucumber Plain Text Feature.tmLanguage
Created March 10, 2011 20:15
Cucumber Language definition file for TextMate; modified to work with Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>feature</string>
</array>
<key>firstLineMatch</key>
<string>기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd(.*)</string>
module ExpectedBehavior
module ActsAsArchival
module ActMethods
def acts_as_archival
unless included_modules.include? InstanceMethods
include InstanceMethods
before_save :raise_if_not_archival
@unixmonkey
unixmonkey / email.rb
Created July 13, 2011 00:53
email configuration for rails
# Loads ActionMailer settings from config/email.yml
# and turns deliveries on only if configuration block is found
config_file = Rails.root.join('config','email.yml')
if File.file?(config_file)
mailconfig = YAML::load_file(config_file)
if mailconfig.is_a?(Hash) && mailconfig.has_key?(Rails.env)
# enable deliveries
ActionMailer::Base.perform_deliveries = true
@unixmonkey
unixmonkey / gist:1316430
Created October 26, 2011 13:57
Redirect and still show error messages
# app/controllers/ballots_controller.rb
def create
@ballot = Ballot.new(params[:ballot])
if @ballot.save
redirect_to @ballot, :notice => 'Successful'
else
session[:error_messages] = @ballot.errors.full_messages
redirect_to edit_ballot_path(@ballot, :params => params), :notice => 'Ruh Roh!'
end
end