Skip to content

Instantly share code, notes, and snippets.

View sukima's full-sized avatar

Devin Weaver sukima

View GitHub Profile
@sukima
sukima / fnotify.sh
Created July 16, 2010 12:20
Grab irssi notifications from a SSH server
#!/bin/sh
# Retrieve irssi notifications from fnotify script via SSH.
# See full blog post at
# http://dev.tritarget.org/2010/07/16/irssi-notifications-over-ssh.html
SSH_CMD="ssh -p 22 username@yourshell.org"
# Set this to what ever unique key generation you wish
RESET_KEY=`date | sha1sum | cut -d\ -f1`
# Sample localization file for English. Add more files in this directory for other locales.
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
hello: "Hello world"
activerecord:
models:
Event: "Session"
ManikinReqType: "Manikin needs"
attributes:
@sukima
sukima / User.rb
Created July 26, 2010 20:36
Parse a persons name into parts. Ruby on Rails
class Instructor < ActiveRecord::Base
# code graciously copied and pasted from
# http://mysmallidea.com/articles/2009/5/31/parse-full-names-with-ruby/index.html
def self.parse_name(name)
return false unless name.is_a?(String)
# First, split the name into an array
parts = name.split
@sukima
sukima / README.md
Created August 5, 2010 21:48
How to customize a global config YAML load in rails

I found this great [RailsCast][1] about making a global configuration. And further offered through the [Nifty Generators][2] (script/generate nifty_config) However I wanted to further customize it by allowing global configurations regardless of the environment.

For example this is the original idea: # config/config.yml development: perform_authentication: false

@sukima
sukima / application_mailer.rb
Created August 6, 2010 19:21
ActiveMailer syntax error
class ApplicationMailer < ActionMailer::Base
def welcome_email(instructor)
recipients instructor.email
from APP_CONFIG['system_email_address']
subject "Welcome to #{APP_CONFIG['application_name']}. Thank you for registering."
sent_on Time.now
body {:instructor => instructor}
end
end
@sukima
sukima / application.js
Created August 6, 2010 23:36
jQuery datepicker with formtastic and rails
/**
* Shamlessly copied from http://snipt.net/boriscy/datetime-jquery-formtastic/
*
* This did not function with formtastic version 0.9.10
* I had to move the live("change") event below the initializing part
* I also had to adjust the jQuery selections as formtastic uses <ol>'s to
* seperate every select box.
*/
$(document).ready(function() {
@sukima
sukima / easteregg.js
Created August 19, 2010 01:18
skiQuery easter egg
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).ready(function() {
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ){
openDialog("#game");
SKI.run($("#game"));
kkeys = [];
return false;
@sukima
sukima / gist:548192
Created August 24, 2010 19:57
Rake task for making a new Jekyll blog post
desc "Create a new blog post"
task :blog do
print "Please enter in the title of the blog post: "
title = $stdin.gets.chomp.strip
name = title.gsub(/\s+/, '-')
name = name.gsub(/[^a-zA-Z0-9_-]/, "").downcase
time = Time.now.strftime("%Y-%m-%d")
File.open("_posts/#{time}-#{name}.markdown", "w+") do |file|
file.puts <<-EOF
---
@sukima
sukima / Rakefile
Created August 27, 2010 19:46
Jekyll Rakefile
require "rake/clean"
CLEAN.include "_site"
def jekyll(opts = "", path = "/usr/bin/")
sh "rm -rf _site"
sh path + "jekyll " + opts
end
desc "Build site using Jekyll"
@sukima
sukima / gist:569211
Created September 7, 2010 21:57
Confussing has_many conditional error
# Instructor model
class Instructor < ActiveRecord::Base
has_many :events
end
# Event model
class Event < ActiveRecord::Base
belongs_to :instructor
end