mkdir proj
cd proj
git init
git config user.name 'username'
r1 = {'a': {'q': 1, 'w': 2}, 'b': {'q': 3, 'w': 4}} | |
r2 = {'a': {'q': 5, 'w': 7}, 'b': {'q': 8, 'w': 2}} | |
# ret = {'a': {'q': 6, 'w': 9}, 'b': {'q': 11, 'w': 6}} | |
a = lambda x, y: list(zip(x.keys(), list(zip(x.values(), y.values())))) | |
rs = reduce(a, (r1, r2)) | |
print rs | |
#print reduce(a, map(lambda r: r[1], rs)) |
from collections import Counter | |
r1 = {'a': {'q': 1, 'w': 2}, 'b': {'q': 3, 'w': 4}} | |
r2 = {'a': {'q': 5, 'w': 7}, 'b': {'q': 8, 'w': 2}} | |
r = dict(zip(r1.keys(), map(lambda r: dict(r[0] + r[1]), zip(map(lambda k: Counter(r1[k]), r1), map(lambda k: Counter(r2[k]), r2))))) | |
print r |
1.9.2p320 :001 > require 'rubypython' | |
=> true | |
1.9.2p320 :002 > RubyPython.start | |
=> true | |
1.9.2p320 :003 > sys = RubyPython.import('sys') | |
=> <module 'sys' (built-in)> | |
1.9.2p320 :004 > sys.path.append('/var/shire') | |
=> None | |
1.9.2p320 :005 > user = RubyPython.import('luzong.user') | |
=> <module 'luzong.user' from '/var/shire/luzong/user/__init__.pyc'> |
while [ $? -eq 0 ];do nc -vlp 8888 -c'(r=read;e=echo;$r a b c;z=$r;while [ ${#z} -gt 2 ];do $r z;done;f=`$e $b|sed "s/[^a-z0-9_.-]//gi"`;h="HTTP/1.1";o="$h 200 OK";c="Content";hd="$c-Type: text/html; charset=utf-8";if [ -z $f ];then($e "$o";$e $hd;$e;ls|(while $r n;do if [ -f "$n" ]; then $e "<a href=\"/$n\">`ls -gh $n`</a><br>";fi;done););elif [[ $f =~ eggs ]];then($e "$o";$e $hd;$e;curl http://labs.douban.com/doublo/eggs?k=`$e $f|sed "s/eggs//gi"` 2>/dev/null;);elif [ -f $f ];then $e "$o";$e "$c-Type: `file -ib $f`";$e "$c-Length: `stat -c%s $f`";$e;cat $f;else $e -e "$h 404 Not Found\n\n404\n";fi)';done |
http://tioga.rubyforge.org/index.html |
1, 获取 access token | |
get '/auth/douban/callback' do | |
auth = env['omniauth.auth'] | |
credentials = auth['credentials'] | |
end | |
在这里可以拿到 credentials, 大致格式: | |
{"token"=>"xxxxxxxxxxxxxxxxx", "expires_at"=>1345640145, "expires"=>true} |
var navBgc = $($('.nav-wrap')[0].parentNode).css('background-color'); | |
$('#db-global-nav').css('background', navBgc); | |
$('#db-global-nav ul li a').css('color', '#566D5E'); | |
$('#db-global-nav ul li.on a').css({'color': '#219A44', 'font-weight': 800}); | |
$('#db-global-nav .bd').css({'width': 960, 'margin': 'auto'}); |
class Faraday::Parts::FilePart | |
def initialize(boundary, name, io) | |
file_length = io.respond_to?(:length) ? io.length : File.size(io.local_path) | |
@head = build_head(boundary, name, io.original_filename, io.content_type, file_length, | |
io.respond_to?(:opts) ? io.opts : {}) | |
@length = @head.length + file_length | |
@io = CompositeReadIO.new(StringIO.new(@head), io, StringIO.new("\r\n")) | |
end | |
end |
#!/usr/bin/env ruby | |
# ^ 1.8.x or 1.9, folks! | |
require 'rubygems' | |
require File.expand_path('./md_izer', File.dirname(__FILE__)) | |
render_options = { | |
:fenced_code_blocks => true, | |
:autolink => true, | |
:space_after_headers => true |