This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PrinceXML Ruby interface. | |
# http://www.princexml.com | |
# | |
# Library by Subimage Interactive - http://www.subimage.com | |
# | |
# | |
# USAGE | |
# ----------------------------------------------------------------------------- | |
# princely = Princely.new() | |
# html_string = render_to_string(:template => 'some_document') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time_consuming(&block) | |
raise "Must wrapping a block" unless block_given? | |
t1 = Time.now | |
yield | |
t2 = Time.now | |
puts "Time consumed: #{t2 - t1 }" | |
end | |
def hello | |
count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select Lifestyle_cat, replace(replace(short_name, '_males', ''), '_female', '') as short_name, | |
Max(case when WorkOn = 'Good Work' then lifestyle_habits else '' end) as Good_Work_Feedback, | |
Max(case when WorkOn = 'Work on' then lifestyle_habits else '' end) as Work_On_Feedback, | |
Sum(case when WorkOn = 'Good Work' then ResponseCount else 0 end) as Good_Work_Count, | |
Sum(case when WorkOn = 'Work on' then ResponseCount else 0 end) as Work_On_Count | |
From ( | |
Select | |
case | |
when q.short_name in ('binge_drinking', 'daily_drinking_female', 'daily_drinking_males') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'ftools' | |
require 'fileutils' | |
require 'rubygems' | |
require 'RMagick' | |
include Magick | |
require 'open3' | |
def merge( files = [] ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSessionsController < InheritedResources::Base | |
actions :new, :create, :destroy | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => :destroy | |
# create! do |success, failure| | |
# @user_session = UserSession.new(params[:user_session]) | |
# @user_session.save do |result| | |
# if result | |
# flash[:notice] = "Login successful!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSessionsController < InheritedResources::Base | |
actions :new, :create, :destroy | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => :destroy | |
# create! do |success, failure| | |
# @user_session = UserSession.new(params[:user_session]) | |
# @user_session.save do |result| | |
# if result | |
# flash[:notice] = "Login successful!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
def index | |
key = '8J0aBBq6zOP2dqtARKzAw' | |
secret = 'RIKTpVosvsPXdyUlgZO0mnkvHnn42P5IugxRXHEsY' | |
@consumer = OAuth::Consumer.new(key,secret,{ :site=>"http://twitter.com", | |
:authorize_url => "http://twitter.com/oauth/authenticate" }) | |
@request_token = @consumer.get_request_token(:oauth_callback => 'http://rociiu.com/home/twitter_callback') | |
session[:request_token] = @request_token | |
redirect_to @request_token.authorize_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> o.total_price == 13.78 | |
=> false | |
>> o.total_price | |
=> 13.78 | |
>> o.total_price.class | |
=> Float |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Matz | |
def self.included(*) | |
puts <<-MATZ | |
Simplicity is NOT a Goal | |
------------------------ | |
Things too simple are difficult | |
Things too complex are difficult |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :application, "My supper app" | |
set :repository, "svn://yoursvnhost/svn/yourproject/" | |
set :scm, :subversion | |
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | |
role :web, "http://mywebserver.com" # Your HTTP server, Apache/etc | |
role :app, "http://myappserver.com" # This may be the same as your `Web` server | |
role :db, "http://mymaindbserver.com", :primary => true # This is where Rails migrations will run | |
role :db, "http://myslaveserver.com" |