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 fib(n): | |
if n == 0 or n == 1: | |
return n | |
else: | |
return fib(n-1) + fib(n-2) | |
for i in range(36): | |
print "n=%d => %d" % (i, fib(i)) | |
# Python 2.5.4 |
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
" Vim color file | |
" eclips3remix v0.1 | |
" eclips3remix - | |
" vim version of the eclips3media textmate theme | |
" cool help screens | |
" :he group-name | |
" :he highlight-groups |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | |
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<style type="text/css">@import 'doc.css';</style> | |
<div id='potion'><img src='potion-1.png' /></div> | |
</head><body><div id='central'> | |
<h1 class="kana">ポーション</h1> | |
<h1>A Short Pamphlet</h1> | |
<h4>by why the lucky stiff</h4> | |
<p>Well, here we go. You want to learn Potion<sup class="footnote"><a href="#fn1">1</a></sup>? Sure, okay. But first, bear in mind that Potion isn’t done yet. And it does very little. It’s completely esoteric. So long as we’ve got that straight.</p> |
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 'net/dns/resolver' | |
# Custom Domain | |
# | |
# Require net-dns gem | |
# | |
# A Rack middleware to to resolve the custom domain to original subdomain | |
# for your multi telent application. | |
# | |
# It's all transperant to your application, it performs cname lookup and |
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
script/generate plugin HelloWorld | |
# vendor/plugins/hello_world/init.rb | |
Rails.configuration.gem "sinatra" | |
Rails.configuration.middleware.insert_before("ActionController::Failsafe", "HelloWorld") | |
# vendor/plugins/hello_world/lib/hello_world.rb | |
# your sinatra app goes here... | |
require 'sinatra/base' | |
class HelloWorld < Sinatra::Base |
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
# Referring to http://blog.rubybestpractices.com/posts/gregory/011-tap-that-hash.html | |
# Ruby 1.9, no tap, single line | |
Hash[[:x, :y, :z].map { |l| [l, rand(100)]}] | |
# Ruby 1.9/1.8, no tap, inject, single line | |
[:x, :y, :z].inject({}) { |result, l| result[l] = rand(100); result} | |
# Ruby 1.9/1.8, no tap, each_with_object from ActiveSupport, single line | |
[:x, :y, :z].each_with_object({}) { |l, result| result[l] = rand(100) } |
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
from xml.sax.saxutils import escape | |
import urllib, re, os, urlparse | |
import HTMLParser, feedparser | |
from BeautifulSoup import BeautifulSoup | |
from pprint import pprint | |
import codecs | |
import sys | |
streamWriter = codecs.lookup('utf-8')[-1] |
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
# from http://blog.davidziegler.net/post/122176962/a-python-script-to-automatically-extract-excerpts-from | |
from BeautifulSoup import * | |
import urllib2 | |
import cookielib | |
import re | |
def cleanSoup(soup): | |
# get rid of javascript | |
subtree = soup('script') |
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
# get a random record from a table | |
Item.first(:offset => ( Item.count * rand ).to_i) |
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
# first you'll want to create a gist then `git clone` the private url | |
# second you'll want to run this script in the gist's directory | |
loop do | |
`git commit -a -m save && git push origin master` | |
sleep 60 * 4 | |
end |