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
class ActionView::TestCase | |
class TestController < ActionController::Base | |
attr_accessor :params | |
# Save the current initialize method to call in the new initialize method below. | |
alias_method :base_initialize, :initialize | |
def initialize | |
base_initialize | |
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
'/^(?:(?:(?<!^):)?[0-9A-Fa-f]{2}){6}$/' |
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
named_scope :by_keyword do |keyword| | |
keywords = keyword.downcase.split | |
query = "lower(profiles.job_title) like ? OR lower(resumes.body) like ? OR lower(career_level) like ? OR profiles.work_experience like ? OR profiles.degree_level like ? OR profiles.military_service like ? OR profiles.military_security like ? OR firstname like ? OR lastname like ? OR locations.city like ? OR locations.state like ? OR locations.zipcode like ? OR summary like ?" | |
parameters = 13 | |
conditions = [ ([ query ] * keywords.size).join(" OR ") ] | |
keywords.inject(conditions) do |conditions, keyword| | |
conditions += [ keyword ] * parameters | |
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
$ env | grep PATH | |
PATH=/usr/local/ruby-enterprise/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games | |
$ sudo env | grep PATH | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin |
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
#signup | |
+column(12) | |
form | |
label | |
+column(4) | |
input | |
+column(4, true) | |
&[type=submit] | |
+column(4, true) |
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
#friends = Array.new | |
#current_user.connections.each do |c| | |
#friends.push([c.friend.full_name, c.user_id]) | |
friends = current_user.connections.map do |c| | |
[ c.friend.full_name, c.user_id ] | |
end | |
friends = friends.sort do |a, b| | |
a[0] <=> b[0] |
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
# Single-level flatten | |
arr = [ [1], [2,3], [4, [5]] ] | |
# Too flat! | |
arr.flatten # => [1, 2, 3, 4, 5] | |
# Just right! | |
arr.inject([]){|a,e| a.concat(e)} # => [1, 2, 3, 4, [5]] |
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
// Before vim-javascript | |
method(arg1, arg2, | |
arg3); | |
// After vim-javascript | |
method(arg1, arg2, | |
arg3); | |
// After (Not sure I like this) |
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
foldingStartMarker = '/\*(\*|\s+\w)(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S))'; | |
foldingStopMarker = '(?<!\*)\*\*/|/\*\s+-+\s+\*/|^\s*\}'; | |
Update these expressions so they also recongize: | |
foldingStartMarker: | |
/* section: something variable | |
---------------------------------------------- */ |
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
exec_last_feature_or_test(){ | |
history|sort -r|sed -s 's/^ [0-9]* //'|while read i;do if [[ "$i" =~ ^ruby || "$i" =~ ^cucumber ]];then echo $i|sh;exit;fi;done | |
} |
OlderNewer