Skip to content

Instantly share code, notes, and snippets.

View tenderlove's full-sized avatar
©️
 ​[object Object] :trollface:

Aaron Patterson tenderlove

©️
 ​[object Object] :trollface:
View GitHub Profile
#!/usr/bin/env ruby -KU
TIMES = 100000
require 'rubygems'
gem 'addressable', '~>2.0'
gem 'faker', '~>0.3.1'
gem 'rbench', '~>0.2.3'
require 'addressable/uri'
require 'socket'
require 'rubygems'
require 'nokogiri'
PORT = rand(65535 - 1024) + 1024
sthread = Thread.new {
s = TCPServer.new(PORT).accept
s.write('<foo>')
@tenderlove
tenderlove / t.rb
Created September 25, 2010 00:02 — forked from joevandyk/t.rb
def foo1
yield
end
m = lambda { |&block| foo1(&block) }
m.call do
puts "i rock"
end
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
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
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
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
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)
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
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(" &raquo;", :class => "show-more")