Skip to content

Instantly share code, notes, and snippets.

View xwmx's full-sized avatar

William Melody xwmx

View GitHub Profile
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
" Vim color file
" eclips3remix v0.1
" eclips3remix -
" vim version of the eclips3media textmate theme
" cool help screens
" :he group-name
" :he highlight-groups
<!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&#8217;t done yet. And it does very little. It&#8217;s completely esoteric. So long as we&#8217;ve got that straight.</p>
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
@xwmx
xwmx / #
Created August 8, 2009 15:44 — forked from rmanalan/gist:161461
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
# 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) }
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]
# 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')
# get a random record from a table
Item.first(:offset => ( Item.count * rand ).to_i)
# 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