Testing ...
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
# encoding: utf-8 | |
require 'addressable/uri' | |
str = "http://उदाहरण.परीक्षा/मुख्य_पृष्ठ" | |
puts "original:" | |
puts "#=> #{str}" | |
#=> http://उदाहरण.परीक्षा/मुख्य_पृष्ठ | |
normalized = Addressable::URI.parse(str).normalize |
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> | |
<head> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js"></script> | |
</head> | |
<body> | |
<div id="chart"> | |
</div> | |
<script type="text/javascript"> | |
var w = 960, |
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
source :rubygems | |
gemspec |
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 RespondWithController < ActionController::Base | |
respond_to :html, :json | |
def using_resource_with_block | |
respond_with(resource) do |format| | |
format.csv { render :text => "CSV" } | |
end | |
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
# http://all-thing.net/fibers-via-continuations | |
# | |
# this is an implementation of Ruby 1.9 Fibers with continuations | |
# it transparently falls back to real Fibers when they exist | |
if Object.const_defined?("Fiber") | |
# that's the native implementation of fibers from Ruby 1.9 | |
# | |
class CFiber |
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 'httparty' | |
require 'grit' | |
require 'pathname' | |
module Wikipedia | |
class Revision | |
def initialize(article, revision) | |
@article = article | |
@revision = revision |
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 'json' | |
# takes a JSON object, removes specified subtrees and trims arrays | |
# returns a pretty printed string | |
# | |
# before = <<-EOF | |
# { "foo": { | |
# "one": { "a": 1, "b": {"c": 2} }, | |
# "two": "value", | |
# "three": { "b": [1,2,3] }}, |
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
# demonstrates that fixtures are not cleaned after unit tests are run (or between different unit tests) | |
# setup a fresh rails project | |
rails foo | |
cd foo | |
# create a model | |
./script/generate model bar |
NewerOlder