Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
#
# A one file test to show ...
require 'rubygems'
require 'dm-core'
# setup the logger
DataMapper::Logger.new(STDOUT, :debug)
class GameMode
include DataMapper::Resource
property :id, Serial
property :title, String
property :description, Text
property :max_players, Integer
has n :games, :through => Resource
has n, :types, :through => Resource
cookies = document.cookie.split(';');
utmz = "";
for(i in cookies) {
if(cookies[i].test(/^__utmz/)) utmz = cookies[i];
}
medium = utmz.match(/".*?utmcmd=([a-z]+)\|/)[1];
adwords = utmz.match(/.*?utmgclid=([_0-9A-Za-z]+)\|/)[1];
# tpitale_rails_template.rb
file 'config/routes.rb', <<-CODE
ActionController::Routing::Routes.draw do |map|
end
CODE
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/favicon.ico"
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
@tpitale
tpitale / gist:660264
Created November 2, 2010 20:40 — forked from fj/gist:660258
ruby-1.8.7-p299 > class Vehicle
ruby-1.8.7-p299 ?> include Mongoid::Document
ruby-1.8.7-p299 ?> field :horsepower
ruby-1.8.7-p299 ?> field :top_speed_mph
ruby-1.8.7-p299 ?> end
=> nil
ruby-1.8.7-p299 > Vehicle.new(:horsepower => 300, :top_speed_mph => 180).save
=> true
@tpitale
tpitale / lib-sunspot-data_mapper.rb
Created October 16, 2011 16:18 — forked from dkubb/dm_sunspot.rb
DataMapper and Sunspot Integration Extension
module Sunspot
module DataMapper
def self.included(base)
base.class_eval do
alias new_record? new?
end
base.extend Sunspot::Rails::Searchable::ActsAsMethods
Sunspot::Adapters::DataAccessor.register(DataAccessor, base)
@tpitale
tpitale / db-backup.sh
Last active March 7, 2022 02:19 — forked from bkenny/db-backup.sh
Simple shell script to backup each postgresql database to s3.
#!/bin/bash
BACKUP="/tmp/s3/db"
DATE=`date +"%Y-%m-%d"`
DIR="${BACKUP}/${DATE}/"
if [ ! -d $DIR ];
then
mkdir -p $DIR
fi
#!/usr/bin/env ruby
require 'trello' # ruby-trello gem
require 'csv'
#
# export TRELLO_DEVELOPER_PUBLIC_KEY=yourkeyfrom # https://trello.com/app-key
# export BOARD_NAME=nameofboardtoimportto
# export MEMBER_NAME=yourusername