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
| ARGV.each { |email| | |
| next if User.find_by_email email | |
| buzz_team_users = [ '[email protected]' ] | |
| user_sending_invite = buzz_team_users.rand | |
| user = User.find_by_email user_sending_invite | |
| invitation = Invitation.new | |
| invitation.sent_to_email = email | |
| invitation.sent_by_user_id = user.id | |
| invitation.note = "Hey, we want you to join buzz" |
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
| View: | |
| - if favorite_comment.text.length < 45 | |
| %p= favorite_comment.text | |
| - else | |
| = sample_with_more(favorite_comment.text, favorite_comment.id) | |
| Helper: | |
| def sample_with_more(body, comment_id, html_options = {}) | |
| more_link = link_to(" »", :class => "show-more") |
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
| if !defined?(JSON) | |
| require 'yajl' | |
| else | |
| require 'json' | |
| module Yajl | |
| LOOKUP = Hash[%w[null boolean string bytes int long float double].map { |x| [x.inspect, x] }] | |
| def self.dump obj | |
| JSON.dump obj | |
| end | |
| def self.load string |
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
| require 'nokogiri' | |
| doc = Nokogiri::XML(open("news.rss")) | |
| content_tag = Nokogiri::XML::Node.new "content", doc | |
| content_tag << doc.create_cdata("<<<<") | |
| doc.at("//item/description").add_next_sibling(content_tag) |
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
| require 'nokogiri' | |
| html = 'CA<br/>Sr Technical Architect' | |
| fragment = Nokogiri::HTML::DocumentFragment.parse(html) | |
| fragment.traverse do |child| | |
| next unless 'br' == child.name | |
| child.replace Nokogiri::XML::Text.new(' ', child.document) | |
| 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
| require "intercession" | |
| require "myapp" | |
| require "myapp/session_extras" | |
| use Rack::Session::Cookie, :secret => "I'll punchasize your face for FREE!" | |
| use Intercession, MyApp::SessionExtras | |
| run MyApp |
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
| require "intercession" | |
| require "myapp" | |
| require "myapp/session_extras" | |
| use Rack::Session::Cookie, :secret => "I'll punchasize your face for FREE!" | |
| use Intercession, MyApp::SessionExtras | |
| run MyApp |
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
| require "intercession" | |
| require "myapp" | |
| require "myapp/session_extras" | |
| use Rack::Session::Cookie, :secret => "I'll punchasize your face for FREE!" | |
| use Intercession, MyApp::SessionExtras | |
| run MyApp |
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 foo1 | |
| yield | |
| end | |
| m = lambda { |&block| foo1(&block) } | |
| m.call do | |
| puts "i rock" | |
| 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
| require 'socket' | |
| require 'rubygems' | |
| require 'nokogiri' | |
| PORT = rand(65535 - 1024) + 1024 | |
| sthread = Thread.new { | |
| s = TCPServer.new(PORT).accept | |
| s.write('<foo>') |