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
scope :voted_since, lambda{|since| | |
joins(:votes) | |
.where("`votes`.created_at >= ? AND `votes`.project_id = `users`.project_id", since.to_s(:db)) | |
.group("`votes`.user_id") | |
.order("COUNT(`votes`.user_id) DESC") | |
} |
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 last_activity_description(date, user_id) | |
user_activity = UserActivity.find(:first, :conditions => ["Date(updated_at) <= ? and user_id = ?", dat | |
e, user_id], :order => 'updated_at DESC') | |
user_activity.activity.description | |
end | |
# better | |
def last_activity(date, user_id) | |
UserActivity.find(:first, :conditions => ["Date(updated_at) <= ? and user_id = ?", dat | |
e, user_id], :order => 'updated_at DESC').activity |
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 last_activity(date, user_id) | |
active_id = UserActivity.find(:first, :conditions => ["Date(updated_at) <= ? and user_id = ?", dat | |
e, user_id], :order => 'updated_at DESC').activity_id | |
end |
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
source 'http://rubygems.org' | |
group :db do | |
gem 'ruby-odbc', :require => 'odbc' | |
gem 'tiny_tds' | |
gem 'activerecord-sqlserver-adapter', '~> 3.1.0' | |
# gem 'composite_primary_keys', '~> 3.1.0' | |
end |
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 | |
FICS_LIMIT = 400 | |
if RUBY_VERSION < '1.9' | |
require 'iconv' | |
def conv str | |
Iconv.conv("US-ASCII//TRANSLIT//IGNORE","UTF-8", str) | |
end | |
else | |
def conv str |
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
%w/ foo11 foo2 3foo foo4 bar2 foo1 bar99-a /.sort do |a,b| | |
[a[/[[:alpha:]]+/],a[/[[:digit:]]+/]] <=> | |
[b[/[[:alpha:]]+/],b[/[[:digit:]]+/]] | |
end |
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 'decimal' | |
require 'bigdecimal' | |
require 'dec_number' | |
require 'benchmark' | |
include Benchmark | |
n = 123.58132134 | |
m = Math::PI | |
bm(6) do |x| | |
x.report("dec_number") do |
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 | |
data = if file = ARGV.shift | |
File.open(file).read | |
else | |
<<DATA | |
command "simple-prompt", "Toggle the simple prompt." do | |
case Pry.active_instance.prompt | |
when Pry::SIMPLE_PROMPT | |
Pry.active_instance.prompt = Pry::DEFAULT_PROMPT |
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
digraph G { | |
size = "5,5"; node[fontsize=16]; | |
struct3 [shape=record,label="hello\nworld |{ b |{c|<here> d|e}| f}| g | h"]; | |
// incoming | |
client -> server; | |
server -> client; | |
} |
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 ApplicationController < ActionController::Base | |
require 'postgresql_view_monkey' | |
end |