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
#!/bin/zsh | |
cd $RUHOH | |
rm -r compiled | |
bundle exec ruhoh compile | |
cd - | |
echo -n "Copy the compiled result to your site repo?[y/n]" | |
read copy_yn | |
if [ "$copy_yn" = "y" ]; then | |
cd $PUBLISH | |
rm -r * |
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
# 用ec来快速启动emacs client | |
alias sudo='sudo ' | |
alias ec='emacsclient -c -a ""' | |
# 现在可以将emacs设为默认编辑器啦 | |
export EDITOR='emacsclient -c -a ""' |
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
export RUHOH=/home/ehome/Documents/blog | |
export PUBLISH=/home/ehome/Documents/wzpan.github.io | |
alias _rp='cd $RUHOH && bundle exec rackup -p 9294' | |
alias _gd='cd $RUHOH && guard' | |
alias _dft='cd $RUHOH && bundle exec ruhoh posts draft' # 快速添加草稿 | |
alias _note='cd $RUHOH && bundle exec ruhoh wiki draft' # 快速添加笔记 | |
alias _tp='cd $RUHOH && bundle exec ruhoh posts titleize' # 快速为草稿文件命名 | |
alias _tn='cd $RUHOH && bundle exec ruhoh wiki titleize' # 快速为草稿文件命名 | |
alias _cp='ruhoh_compile' # 编译和交互式更新 |
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 "pandoc-ruby" | |
class Ruhoh | |
module Converter | |
module Markdown | |
def self.extensions | |
['.md', '.markdown'] |
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
#!/bin/bash | |
net_stat=1 | |
while true | |
do | |
PINGRET=$( ping 8.8.8.8 -c 4 | grep "ttl=" ) | |
[ -z "$PINGRET" ] && | |
{ |
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
class Fib: | |
def __init__(self, max): | |
self.max = max | |
def __iter__(self): | |
self.a = 0 | |
self.b = 1 | |
return self | |
def __next__(self): |
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 | |
class LazyRules: | |
rules_filename = 'rules.txt' | |
def __init__(self): | |
self.pattern_file = open(self.rules_filename, encoding='utf-8') | |
self.cache = [] | |
def __iter__(self): |
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
#!/bin/python3 | |
# A unit test example for convertion between roman number and digit number | |
import roman1 # the module you want to test | |
import unittest | |
class KnownValues(unittest.TestCase): | |
known_values = ((1, 'I'), | |
(2, 'II'), |
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
#!/usr/bin/python | |
# Filename: file_io.py | |
poem = '''\ | |
Programming is fun | |
When the work is done | |
if you wanna make your work also fun: | |
use Python! | |
''' |
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
/* Copyright (c) 2013 by Joseph Pan (http://hahack.com) */ | |
function videoGFW(src) { | |
if (window.XMLHttpRequest) | |
{// code for IE7+, Firefox, Chrome, Opera, Safari | |
var request = new XMLHttpRequest(); | |
} | |
else | |
{// code for IE6, IE5 | |
var request = new ActiveXObject("Microsoft.XMLHTTP"); |
OlderNewer