This file contains 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
# in foo.rb | |
class Foo | |
attr_accessor :field1, :field2 | |
def initialize(options => {}) | |
@field1 = options[:field1] ||= nil | |
@field2 = options[:field2] ||= nil | |
end | |
end |
This file contains 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
# File actionpack/lib/action_view/helpers/text_helper.rb, line 141 | |
def excerpt(text, phrase, *args) | |
options = args.extract_options! | |
unless args.empty? | |
options[:radius] = args[0] || 100 | |
options[:omission] = args[1] || "..." | |
end | |
options.reverse_merge!(:radius => 100, :omission => "...") | |
if text && phrase |
This file contains 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
# download, from_repo, and commit_state methods swiped from | |
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb | |
require 'open-uri' | |
def download(from, to = from.split("/").last) | |
#run "curl -s -L #{from} > #{to}" | |
file to, open(from).read | |
rescue | |
puts "Can't get #{from} - Internet down?" |
This file contains 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
require 'rubygems' | |
require 'eventmachine' | |
require 'digest/md5' | |
require 'base64' | |
require 'socket' | |
# Dunno, may need this later on. | |
class Session < Struct.new(:username, :id) | |
end |
This file contains 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 tmpdir | |
+ @@tmpdir ||= self.root ? File.expand_path(File.join(self.root, "tmp")) : "tmp" | |
+ end | |
+ | |
+ def tmpdir=(path) | |
# type | |
+ @@tmpdr = path | |
+ end |
This file contains 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
activerecord/ activeresource/ | |
elad-meidars-computer-3:rails eladmeidar$ git add activeresource/lib/active_resource/connection.rb | |
elad-meidars-computer-3:rails eladmeidar$ git commit -c 84f2984 | |
activeresource/test/connection_test.rb: needs merge | |
activeresource/test/connection_test.rb: unmerged (ead7204eb244829d88dfb5892e846e03c7312d5d) | |
activeresource/test/connection_test.rb: unmerged (12e8058b0c849730fcfb5aa9a233e7422106c606) | |
activeresource/test/connection_test.rb: unmerged (2425edba4df72e8d8abadb7ddd4d621edf76e7f2) | |
error: Error building trees |
This file contains 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 test_truncate_multibyte_with_seperator | |
with_kcode 'none' do | |
assert_equal "אלעד ...", truncate("אלעד אוכל גזר כתום", :seperator => ' ', :length => 12) | |
end | |
with_kcode 'u' do | |
assert_equal "אלעד ...", | |
truncate("אלעד אוכלת גזר כתום", :length => 10, :seperator => ' ') | |
end | |
end |
This file contains 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
## layout | |
<head> | |
<title>bla</title> | |
<%= javascript_include_tag 'some_js_i_want_everywhere' %> | |
<%= yield(:head) %> | |
</head> | |
## view 1 |
This file contains 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_all").removeClass("active_select"); |
This file contains 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
## html | |
<span>Select:</span> <a href="#" id="select_all_pending" class="select_all">Pending</a>, | |
<a href="#" id="select_all_expired" class="select_all">Expired</a>, | |
<a href="#" id="select_all_valid" class="select_all">Valid</a> | |
## js | |
function setupPostsFilter(){ | |
if ($(".select_all")) { |
OlderNewer