Skip to content

Instantly share code, notes, and snippets.

View damien's full-sized avatar
🤝
Open for business! Hire me for your project at https://mindglob.com

Damien Wilson damien

🤝
Open for business! Hire me for your project at https://mindglob.com
View GitHub Profile
@damien
damien / backup.rake
Created January 11, 2009 02:18
Collection of useful rake tasks for rails applications.
require 'find'
namespace :db do
desc "Backup the database to a file. Options: DIR=base_dir RAILS_ENV=production MAX=20"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = ENV["DIR"] || "db"
backup_base = File.join(base_path, 'backup')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql.gz")
#! /bin/bash
##
# .bash_extras
#
# bash profile customizations. Just source this file to get things rolling!
##
# [damien@Protos:/etc] 21:00:20 $
export PS1='[\[\033[36m\]\u@\h\[\033[31m\]:\[\033[33m\]\w\[\033[0m\]] \[\033[35m\]\D{%H:%M:%S}\[\033[0m\] \$ '
@damien
damien / weather.rb
Created April 2, 2009 21:06
A simple ruby script that will display the weather for a given zip code using Yahoo's weather API.
require 'net/http'
require 'rexml/document'
puts "Enter your zip code to get today's forecast"
print "Zip: "
zip = gets.chomp
if (zip.nil? or zip == 0)
puts "Invalid zip, program exiting."
@damien
damien / wp-config-extras.php
Created August 24, 2009 01:26
Some helpful settings for WordPress development, to be appended to wp-config.php
<?php
/** Development settings.
*
* These are some customs settings that allow us to import arbitrary WordPress
* databases and run them within our development environment without any additional
* configuration. Append this to your regular wp-config.php file and customize as needed.
*
* @link http://gist.github.com/gists/173574
*/
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2009 The Authors
@damien
damien / _flash_alert.html.haml
Created April 15, 2010 19:30
A simple helper method/view to display flash notices and alerts. The application this code is extracted from utilized José Valim's excellant Responders gem to display localized messages.
%div.alert= flash[:alert]
@damien
damien / jquery.jump-menu.js
Created April 27, 2010 14:55
A simple utility JQuery plugin that converts a select element generated from `wp_dropdown_categories` into a classic jump menu/drop down navigation.
;(function($) {
$.fn.jumpMenu = function(options) {
// Creatues a jumpmenu using a form containing wp_dropdown_categories() and a submit input
return this.each(function() {
var form = $(this);
$('input[type=submit]', form).hide();
var categories = $('select#cat', form);
@damien
damien / Rakefile
Created May 18, 2010 22:22
Ruby backtrace of an error with rake and resque.
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'resque/tasks'
Rails::Application.load_tasks
def next_event
event = NeoEvent.first(
:starts_at.gt => Time.now,
:cancelled => false,
:order => [ :starts_at.asc ]).starts_at
"<time datetime='#{event.strftime}'>#{event.strftime('%I:%M %p PST')}</time>"
end
/Users/damien/.rvm/gems/ruby-1.8.7-p174@vokle/gems/dm-core-0.10.2/lib/dm-core/model/relationship.rb:381:in `method_missing': undefined local variable or method `is_paginated' for Occurrence:Class (NameError)
from /Users/damien/.rvm/gems/ruby-1.8.7-p174@vokle/gems/dm-core-0.10.2/lib/dm-core/model/property.rb:239:in `method_missing'
from /Users/damien/p/vokle-legacy/lib/vokle/models/occurrence.rb:190
from /Users/damien/p/vokle-legacy/lib/vokle/base.rb:72:in `require'
from /Users/damien/p/vokle-legacy/lib/vokle/base.rb:72:in `load'
from /Users/damien/p/vokle-legacy/lib/vokle/base.rb:72:in `each'
from /Users/damien/p/vokle-legacy/lib/vokle/base.rb:72:in `load'
from /Users/damien/p/vokle-legacy/lib/vokle.rb:47
from /Users/damien/p/vokle-legacy/config/init.rb:35:in `require'
from /Users/damien/p/vokle-legacy/config/init.rb:35