Public Gists by awesome

Gravatar
Tue Nov 03 10:05:08 -0800 2009
1
2
3
# copied from (thanks!): http://codesnippets.joyent.com/posts/show/615
 
str = <<HTML_TEXT
gist: 225181 ruby strip HTML tags
Gravatar
Tue Nov 03 08:29:40 -0800 2009
1
2
3
# copied from (thanks!): http://codesnippets.joyent.com/posts/show/615
 
str = <<HTML_TEXT
Gravatar
Tue Sep 29 10:04:49 -0700 2009
1
request.env['RAW_POST_DATA']
Gravatar
Sun Sep 27 13:09:09 -0700 2009

      
Gravatar
Sun Sep 27 12:19:40 -0700 2009

      
gist: 192979 list attr_accessors
Gravatar
Thu Sep 24 12:42:28 -0700 2009
1
2
3
# there may be a better way that is not ghetto,
# however I will show you how to list attr_accessors,
# actually have them returned as strings in an array:
gist: 191317 auto unhyperlink links
Gravatar
Tue Sep 22 11:50:16 -0700 2009
1
2
3
def unhyperlink(string)
  string.gsub(/<a[^>]*>([^<]+)<\/a>/i, '\1')
end
Gravatar
Sun Sep 13 16:50:16 -0700 2009
1
2
3
require 'rubygems'
require 'active_support'
 
Gravatar
Sun Sep 13 16:43:52 -0700 2009
1
2
3
require 'nokogiri'
 
# = XmlMini Nokogiri implementation
Gravatar
Mon Aug 31 01:52:07 -0700 2009
1
2
3
      === Epic Snow Leopard Upgrayyyyd Guide ===
 
Son, you’re now living in the land of 64-bit systems.
Gravatar
Tue Aug 18 22:33:38 -0700 2009
1
2
3
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
Gravatar
Sun Aug 16 21:51:14 -0700 2009
1
2
3
# http://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby
# Kent Fredric:
 
Gravatar
Sat Jul 25 04:06:11 -0700 2009
1
2
3
In response to all the responses to:
 
http://twitter.com/rtomayko/status/1155906157
Gravatar
Thu Jul 23 01:02:20 -0700 2009
1
2
3
# @member is set by a factory before reaching this step
Then /^I should be at edit_member page$/ do
  response.request.env["REQUEST_URI"].should contain("/members/#{@member.id}/edit")
Gravatar
Wed Jul 22 14:39:49 -0700 2009
1
2
3
Then(/^I should be at (.+?) page$/) do |page_name|
  request.path.should =~ /^#{path_to(page_name + " page")}/
end
Gravatar
Fri Jun 19 01:00:34 -0700 2009
1
2
3
HOWTO: iPhone AT&T Tethering
============================
 
Gravatar
Tue Jun 16 03:07:09 -0700 2009
1
2
3
Given /^I visit subdomain (.+)$/ do |sub|
  host! "#{sub}.#{TEST_DOMAIN}" #TEST_DOMAIN is defined in test.rb. In my case TEST_DOMAIN = 'example.com'
end
Gravatar
Tue Mar 31 23:14:57 -0700 2009
1
2
3
# hash to query string
$ irb
>> hash = {1=>1,2=>2,3=>3}
Gravatar
Mon Mar 30 16:59:25 -0700 2009
1
2
3
use Rack::Auth::Basic do |login, password|
  # Account.find_by_login(login) returns a Hash:
  # account = {:login => "dude", :password => "awesome"}
Gravatar
Thu Mar 26 23:02:01 -0700 2009
1
2
3
<!-- the following is the output that thing produces, as requested by Eric Meyer here: http://www.tbray.org/ongoing/When/200x/2009/03/25/On-Rack#c1238071590.220874 -->
 
<html><head><title>Awesome</title></head><body><h2>Awesome</h2><ul><li><p>SERVER_NAME => localhost</p></li><li><p>rack.input => #<StringIO:0x11f32f8></p></li><li><p>rack.run_once => false</p></li><li><p>rack.url_scheme => http</p></li><li><p>HTTP_USER_AGENT => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1</p></li><li><p>HTTP_ACCEPT_ENCODING => gzip, deflate</p></li><li><p>PATH_INFO => /foo</p></li><li><p>rack.errors => #<IO:0x2f7c4></p></li><li><p>HTTP_CACHE_CONTROL => max-age=0</p></li><li><p>HTTP_ACCEPT_LANGUAGE => en-us</p></li><li><p>HTTP_HOST => localhost:4321</p></li><li><p>SERVER_PROTOCOL => HTTP/1.1</p></li><li><p>SCRIPT_NAME => </p></li><li><p>REQUEST_PATH => /foo</p></li><li><p>SERVER_SOFTWARE => Mongrel 1.1.5</p></li><li><p>REMOTE_ADDR => 127.0.0.1</p></li><li><p>rack.version => 01</p></li><li><p>rack.multithread => true</p></li><li><p>HTTP_VERSION => HTTP/1.1</p></li><li><p>HTTP_COOKIE => __utma=111872281.1141454409546431100.1233860251.1233860251.1235520138.2; __utmz=111872281.1233860251.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); re_ret=2</p></li><li><p>rack.multiprocess => false</p></li><li><p>REQUEST_URI => /foo?bar=baz</p></li><li><p>SERVER_PORT => 4321</p></li><li><p>QUERY_STRING => bar=baz</p></li><li><p>GATEWAY_INTERFACE => CGI/1.2</p></li><li><p>HTTP_ACCEPT => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</p></li><li><p>REQUEST_METHOD => GET</p></li><li><p>HTTP_CONNECTION => keep-alive</p></li></ul></body></html>