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
git clone git://github.com/imathis/octopress.git octopress | |
cd octopress # If you use RVM, You'll be asked if you trust the .rvmrc file (say yes). | |
ruby --version # Should report Ruby 1.9.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
~~~php | |
protected static function resolve_name_conflicts($new_parent, $items, $params) | |
{ | |
$resolve_conflicts_strategy = isset($params['resolve_conflicts_strategy']) ? $params['resolve_conflicts_strategy'] : null; | |
// there are speical logic for folder creation | |
$new_items_to_check = isset($params['new_items_to_check']) ? $params['new_items_to_check']: false; | |
// what does it mean? | |
$ignore_self_conflicts = isset($params['ignore_self_conflicts']) ? $params['ignore_self_conflicts']: true; | |
if (!in_array($resolve_conflicts_strategy, array('rename_if_conflicts', 'overwrite_if_conflicts', 'throw_exception'))) | |
{ |
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
import re, Image | |
im = Image.open("oxygen.png") | |
row = [im.getpixel((x, 47)) for x in range(0, im.size[0], 7)] | |
chrs = [chr(r) for r, g, b, a in row if r == g == b] | |
s = ''.join(chrs) | |
print ''.join(map(chr, map(int, re.findall(r'\d+',s)))) |
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
def f n | |
n == 0 ? "1": | |
f(n-1).scan(/(\d)(\1*)/).collect{|i| "#{i[1].size+1}#{i[0]}"}.join | |
end | |
puts f(30).size |
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 "RMagick" | |
img = Magick::ImageList.new 'good.jpg' | |
gc = Magick::Draw.new | |
gc.fill('#CC6600') | |
gc.polygon(*first_list) | |
gc.fill('white') | |
gc.polygon(*second_list) | |
gc.draw(img) | |
img.display |
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 'bzip2' | |
un = "同上,需要用双引号括起来" | |
pw = "同上,需要用双引号括起来" | |
puts Bzip2.uncompress(un), Bzip2.uncompress(pw) |
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
from PIL import Image | |
img = Image.open("cave.jpg") | |
c,r = img.size | |
pix = img.load() | |
for j in range(r-1): | |
for i in range(c): | |
if (i+j)%2: | |
pix[i,j] = pix[i,j+1] | |
img.show() | |
# 注意也可以用 img.getpixel 和 img.putpixel 来操作像素。 |
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
import bz2 | |
un = "un 的字符串内容,表示 user name" | |
pw = "pw 的字符串内容,表示 password" | |
print bz2.decompress(un), bz2.decompress(pw) |
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
from re import findall | |
def f(n): | |
return "1" if n == 0 else ''.join( | |
["%d%s"%(len(j)+1, i) for i,j in findall(r'(\d)(\1*)', f(n-1))]) | |
print len(f(30)) |
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
from PIL import Image, ImageDraw | |
img = Image.new("RGB",(640,480), 'white') | |
draw = ImageDraw.Draw(img) | |
draw.polygon(first_list, 'black') | |
draw.polygon(second_list, 'grey') | |
img.show() |
NewerOlder