Skip to content

Instantly share code, notes, and snippets.

View charlie's full-sized avatar

Charles Hornberger charlie

View GitHub Profile
diff --git a/build.gradle b/build.gradle
index 8035f51..e8f2e0d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,11 +1,8 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '1.2.3'
- id 'application'
}
1.9.3p374 :001 > "\x90".force_encoding(Encoding::WINDOWS_1250).valid_encoding?
=> true
1.9.3p374 :002 > "\x90".force_encoding(Encoding::WINDOWS_1250).encode("UTF-8")
Encoding::UndefinedConversionError: "\x90" to UTF-8 in conversion from Windows-1250 to UTF-8
from (irb):2:in `encode'
from (irb):2
from /Users/charleshornberger/.rvm/rubies/ruby-1.9.3-p374/bin/irb:16:in `<main>'
public static <T> List partition(List<T> list, int numPartitions, int minPerPartition) {
ArrayList<List> partitions = new ArrayList<List>();
int i = 0;
int n = list.size();
int numPerPartition = new BigDecimal(n).divide(new BigDecimal(numPartitions), 0, RoundingMode.CEILING).intValue();
if (numPerPartition < minPerPartition) {
numPerPartition = minPerPartition;
}
while(i < n) {
int j = 0;
{{velocity wiki="true"}}
##
## XWiki Dashboard
##
## This dashboard can be used for both wikis (Main.WebHome)
## and spaces (*.WebHome).
##
$xwiki.ssx.use('Main.Dashboard')##
#set ($isSpaceDashboard = false)
#if ($doc.space != "Main")
require 'rubygems'
require "test/unit"
require "active_record"
require "sqlite3"
module Test::Unit
class TestCase
def setup
$VERBOSE = nil
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "./.test.sqlite3")
config.generators do |g|
g.stylesheets false
g.test_framework :test_unit, :fixture => false
g.helper false
end
def hash_to_params(hash)
hash.keys.inject("") do |qs, key|
qs << "&" unless qs.blank?
qs << if Array === hash[key]
k = CGI.escape(key.to_s)
hash[key].map { |value| "#{k}=" << CGI.escape(value.to_s) }.join("&")
else
CGI.escape(key.to_s) << "=" << CGI.escape(hash[key].to_s)
end
end
commit aebb80511636cc78f8df6db2c3508ad64ed79cba
Author: Charlie <**@**.**>
Date: Thu Jan 6 11:16:43 2011 -0800
Guess when the expressions in your named_scopes get evaluated. That's right, bozo, they get evaluated when your classes get loaded :)
diff --git a/app/models/offer.rb b/app/models/offer.rb
index 410b05a..5e0ce8d 100644
--- a/app/models/offer.rb
+++ b/app/models/offer.rb
# app/models/*.rb
class Business < ActiveRecord::Base
has_many :verifications, :as => :object
has_many :owners, :through => :verifications, :source => :verifiable, :source_type => "User", :conditions => "verified_at IS NOT NULL"
has_many :email_subscribers, :through => :verifications, :source => :verifiable, :source_type => "Email", :conditions => "verified_at IS NOT NULL"
has_many :sms_subscribers, :through => :verifications, :source => :verifiable, :source_type => "Phone", :conditions => "verified_at IS NOT NULL"
end
class Email < ActiveRecord::Base