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
require 'ostruct'
class GeoIpCity
DATA = "#{Rails.root}/db/GeoLiteCity.dat"
def locate(ip_to_locate)
data = api.city(ip_to_locate)
return if data.nil?
/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
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
@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
@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 / _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]
#
# = 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 <[email protected]>
# Copyright:: 2007-2009 The Authors
@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
*/
@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."
#! /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\] \$ '