Skip to content

Instantly share code, notes, and snippets.

View levinalex's full-sized avatar

Levin Alexander levinalex

View GitHub Profile
@levinalex
levinalex / README.md
Last active December 25, 2015 12:09 — forked from mbostock/.block

Testing ...

# encoding: utf-8
require 'addressable/uri'
str = "http://उदाहरण.परीक्षा/मुख्य_पृष्ठ"
puts "original:"
puts "#=> #{str}"
#=> http://उदाहरण.परीक्षा/मुख्य_पृष्ठ
normalized = Addressable::URI.parse(str).normalize
@levinalex
levinalex / index.html
Last active December 16, 2015 11:19 — forked from njvack/LICENSE
<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,
@levinalex
levinalex / Gemfile
Created February 20, 2011 00:43
error.log
source :rubygems
gemspec
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
# 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
We couldn’t find that file to show.
@levinalex
levinalex / gist:228213
Created November 6, 2009 19:37
wikipedia2git.rb
require 'httparty'
require 'grit'
require 'pathname'
module Wikipedia
class Revision
def initialize(article, revision)
@article = article
@revision = revision
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] }},
# 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