Skip to content

Instantly share code, notes, and snippets.

View ericboehs's full-sized avatar

Eric Boehs ericboehs

  • Oddball
  • Enid, OK
  • 02:00 (UTC -05:00)
View GitHub Profile
@ericboehs
ericboehs / Verify PostGIS installed correctly
Created March 17, 2010 03:39
Verify PostGIS installed correctly
sudo su postgres
psql -d template_postgis15
SELECT postgis_full_version();
\q
exit
@ericboehs
ericboehs / PostGIS Version
Created March 17, 2010 03:40
PostGIS Version
POSTGIS="1.5.1" GEOS="3.2.0-CAPI-1.6.0" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.7" USE_STATS
<?php
/**
* This class calls the bitly.pro RESTful API for our short domain wim.gs. It
* provides shorten, info and stas calls.
*
* @link http://bit.ly/apidocs
* @package urlShortener
* @author Eric Boehs
**/
class Feed < ActiveRecord::Base
def self.check_livescores(interval="30", duration="60")
how_many = duration.to_i / interval.to_i
@feeds = Feed.find(:all, :conditions => ['path LIKE ? OR path LIKE ?', '%livescores%', '%in-progress-boxscores%' ])
@feeds.each do |feed|
how_many.times do |i|
Delayed::Job.enqueue(AtomChecker.new(feed.id, :priority => 3), 4, (i*interval).seconds.from_now)
end
end
end
class Sale < ActiveRecord::Base
belongs_to :user
belongs_to :deal
has_many :coupons
end
class Deal < ActiveRecord::Base
has_many :sales
@ericboehs
ericboehs / lighter
Created November 13, 2010 00:12 — forked from jnunemaker/lighter.rb
Lighter -- Campfire from the command line #
#!/usr/bin/env ruby
#############################################################
# Lighter -- Campfire from the command line #
# #
# Installation: #
# gem install tinder #
# chmod +x lighter #
# #
# Usage: #
@ericboehs
ericboehs / Xbox Live Push Notifications for Ruby
Created December 9, 2010 23:09
Sends push notifications to boxcar when an Xbox Live friend signs online.
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'cgi'
require 'httparty'
user_statuses = Hash.new
file = "/tmp/xbox_live_user_statuses.yml"
db = YAML::load(File.open(file)) if File::exists?(file)
@ericboehs
ericboehs / to_slug.rb
Created February 1, 2011 21:09
This extends ruby's string class and adds a to_slug method
# coding: utf-8
class String # This reopns the string class
# Define a new method to convert the string to be url friendly
def to_slug
# This is the input as there are no arguments passed.
string = self
# Define which accents map to which ascii characters
accents = {
['á','à','â','ä','ã','å'] => 'a',
@ericboehs
ericboehs / test_generator.rb
Created February 2, 2011 05:10
Created my tests for my accents to_slug gem
# Define which accents map to which ascii characters
accents = {
'A' => %w(À Á Â Ã Ā Ă Ȧ Ả Ä Å Ǎ Ȁ Ȃ Ą Ạ Ḁ Ầ Ấ Ẫ Ẩ Ằ Ắ Ẵ Ẳ Ǡ Ǟ Ǻ Ậ Ặ),
'AE' => %w(Æ Ǽ Ǣ),
'B' => %w(ḂƁ Ḅ Ḇ Ƃ Ƅ),
'C' => %w(C Ć Ĉ Ċ Č Ƈ Ç Ḉ),
'D' => %w(D Ḋ Ɗ Ḍ Ḏ Ḑ Ḓ Ď Đ Ɖ Ƌ),
'E' => %w(È É Ê Ẽ Ē Ĕ Ė Ë Ẻ Ě Ȅ Ȇ Ẹ Ȩ Ę Ḙ Ḛ Ề Ế Ễ Ể Ḕ Ḗ Ệ Ḝ Ǝ Ɛ),
'F' => %w(Ḟ Ƒ),
'G' => %w(Ǵ Ĝ Ḡ Ğ Ġ Ǧ Ɠ Ģ Ǥ),
@ericboehs
ericboehs / instant_search.js
Created February 21, 2011 15:15
Author: Eric Boehs
// Author: Eric Boehs
// Description: Submits a GET request using jQuery's AJAX lib to conferences/search.js.
// It expects an html response of the <li> elements of each conference object
// It will populate the ul.search-results element with the response
// Created: February 20th, 2011
// Version: 0.01
// BUG: There's a horrible bug in this version: Searches are commonly left blank even though
// there may be results due to the throttling I built in. Pressing an enter at the end of the
// search fixes it. I thought about doing a loop check to search again if they I haven't seen a
// a keypress in >500ms or something. But then I thought I should go to bed.