Skip to content

Instantly share code, notes, and snippets.

View heycarsten's full-sized avatar

Carsten Nielsen heycarsten

View GitHub Profile
require 'open-uri'
# First lets assign the results to a couple variables.
labe_output = open("http://en.wikipedia.org/wiki/Labe").read
usa_output = open("http://en.wikipedia.org/wiki/USA").read
# Okay, so if we want to just send these to stdout:
puts labe_output
puts usa_output
# Self-If-Self: A Study
#
# I have decided that this is silly, but I want to share it to see what other
# people think.
#
require 'benchmark'
require 'pp'
parse_git_branch() {
RSLT=''
GIT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' | awk '{print $2}'`
if [ "$GIT_BRANCH" ]
then
GIT_STATUS=`git status 2> /dev/null | grep 'working directory clean'`
CLR='2'
if [ "$GIT_STATUS" ]
then
CLR='2'
# You can override these if you want in environment initializers:
COUCHDB_HOST = 'http://127.0.0.1:5984' unless defined?(COUCHDB_HOST)
COUCHDB_DB_NAME = "learnhub_#{Rails.env}" unless defined?(COUCHDB_DB_NAME)
# This stuff should stay here:
COUCHDB_SERVER = CouchRest.new(COUCHDB_HOST)
COUCHDB_DATABASE = COUCHDB_SERVER.database!(COUCHDB_DB_NAME)
CouchRest::Model.default_database = COUCHDB_DATABASE
iPhone
------
8 GB - $655 / $199 with 3 year contract.
16 GB - $755 / $299 with 3 year contract.
Apparently you can buy them on Craigslist and stuff but then you have
to crack it open to switch out the SIM card, of course that voids the
warranty so if you mess it up: you're fucked.
## application_controller.rb
def refresh_to(url, timeout = 10)
headers['Refresh'] = "#{timeout}; URL=#{url}"
end
## photo_albums_controller.rb
def create
# /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/relationship_chain.rb:49:in `initialize': undefined method `name' for nil:NilClass (NoMethodError)
# from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/one_to_many.rb:56:in `new'
# from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/one_to_many.rb:56:in `setup'
# from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations.rb:122:in `has'
class StoreProductInventory
include DataMapper::Resource
module FlashHelper
# Will output all flashes in the FlashHash into DIV elements containing the
# FlashHash value as content and the FlashHash key as the class name. Some
# class names which have styles associated with them are:
# * information / info
# * success
# * warning
# * error
def flash_messages
document.observe('dom:loaded', function() {
$$('input[tabindex="1"]').invoke('focus');
});
=begin
License: latest LGPL :D
As per my discussion with Gianni (@gf3),
http://twitter.com/phillmv/status/2659984348
http://twitter.com/phillmv/status/2660026344
http://twitter.com/phillmv/status/2660059102
http://twitter.com/phillmv/status/2660184885
http://twitter.com/phillmv/status/2660283856 and
http://twitter.com/phillmv/status/2660306850