Skip to content

Instantly share code, notes, and snippets.

@douo
douo / test
Created October 15, 2011 19:52
test
public void drawPicture(Picture picture) {
picture.endRecording();
native_drawPicture(mNativeCanvas, picture.ni());
}
@douo
douo / wp_to_ruhoh.rb
Created August 21, 2012 13:07
wordpress export xml to ruhoh post
# coding: utf-8
# chcp 65001
require 'rubygems'
require 'hpricot'
require 'nokogiri'
require 'fileutils'
require 'yaml'
require 'time'
require 'pandoc-ruby'
@douo
douo / no_raw_string.rb
Created September 15, 2012 06:12
将android layout 的xml 文件中的 raw string 转换到 strings.xml 的ruby 脚本
#usage: ruby test.rb layout/
$counter =1
$strs=[]
def gen(ctn)
reg = /android:text="([^@?]*?)"/
while res = ctn.match(reg)
id = "autogen_text_#{$counter}"
$counter=$counter+1
ctn.sub!(reg,"android:text=\"@string/#{id}\"")
@douo
douo / rss.rb
Created September 17, 2012 07:19
ruhoh's compiler plugin use to compile site's rss
require 'nokogiri'
class Ruhoh
module Compiler
# the origin rss compiler is provided by David Long
# http://www.davejlong.com/
# https://github.com/davejlong
# Thanks David!
# this rss compiler is modified by Douo
# use page.render_content instead of page.render
@douo
douo / site.yml
Created September 17, 2012 07:54 — forked from crhan/site.yml
Ruhoh Sitemap Generator
plugins:
sitemap_generator: # all optional
file_name: sitemap.xml
exclude_id:
- search.html
- pages.html
change_frequency_custom_name: changefreq
priority_custom_variable_name: priority
@douo
douo / TTPlayer(LRC).py
Created December 23, 2012 04:38
Lyrics Grabber2 的千千静听歌词抓取脚本
# -*- coding: utf-8 -*-
import encodings.utf_8
import math
import urllib, urllib2
import random
import re
from xml.dom import minidom
from LevenshteinDistance import LevenshteinDistance
from grabber import LyricProviderBase
@douo
douo / Lyricist(LRC).py
Created December 23, 2012 04:40
Lyrics Grabber2 乐辞的脚本
# -*- coding: utf-8 -*-
# Code from LyricZilla - Linux 下的滚动歌词
from encodings import gb18030, utf_8
import urllib
from xml.dom import minidom
from LevenshteinDistance import LevenshteinDistance
from grabber import LyricProviderBase
__all__ = 'Lyricist'
@douo
douo / ruhoh.sh
Last active May 11, 2016 23:54
为ruhoh 提供一些便利的方法,更新到ruhoh 2。
# ruhoh v2.5
# -s 是自己扩展的命令,用来指定ruhoh的工作目录,如果没有默认是当前目录
alias post='ruhoh -s "$RUHOH" posts new'
alias page='ruhoh -s "$RUHOH" pages new'
alias diary='ruhoh -s "$RUHOH" diary today'
alias note='ruhoh -s "$RUHOH" notes new'
@douo
douo / Tona.rb
Created January 24, 2013 07:25
打印出大调式
class Tona
def initialize
@_u = ["B", "C", "C'", "D", "Ds", "E", "F", "Fs", "G", "Gs", "A", "As"]
@_d = ["B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb"]
@_a = [0, 2, 2, 1, 2, 2, 2, 1]
end
["B", "C", "Cs", "D", "Ds", "E", "F", "Fs", "G", "Gs", "A", "As"].each do |t|
class_eval <<-RUBY
def #{t}
@douo
douo / gist:4984367
Last active December 13, 2015 22:28
how to detect layout inflate completely in activity
getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){
public void onGlobalLayout() {
// the code from here where excute after layout is complete
getWindow().getDecorView().getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});