Skip to content

Instantly share code, notes, and snippets.

View wzpan's full-sized avatar
:octocat:
Focusing

潘伟洲 wzpan

:octocat:
Focusing
View GitHub Profile
@wzpan
wzpan / ruhoh_compile.sh
Last active December 18, 2015 11:59
Shell - help me compile ruhoh and ask me to push to my repositories
#!/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 *
@wzpan
wzpan / ec.sh
Last active December 18, 2015 11:59
emacsclient setting on Linux
# 用ec来快速启动emacs client
alias sudo='sudo '
alias ec='emacsclient -c -a ""'
# 现在可以将emacs设为默认编辑器啦
export EDITOR='emacsclient -c -a ""'
@wzpan
wzpan / ruhoh.sh
Last active December 18, 2015 11:59
Some settings that can help me manage ruhoh
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' # 编译和交互式更新
@wzpan
wzpan / pandoc.rb
Created June 14, 2013 05:25
Using Pandoc instead of RedCarpet to render the page in Ruhoh. Supports markdown, rst and textile.
require "pandoc-ruby"
class Ruhoh
module Converter
module Markdown
def self.extensions
['.md', '.markdown']
@wzpan
wzpan / notifynet.sh
Last active December 19, 2015 07:09
Shell - an applet to notify the network status.
#!/bin/bash
net_stat=1
while true
do
PINGRET=$( ping 8.8.8.8 -c 4 | grep "ttl=" )
[ -z "$PINGRET" ] &&
{
@wzpan
wzpan / fibonacci.py
Last active December 5, 2022 23:17
Python - Fibonacci Iterator
class Fib:
def __init__(self, max):
self.max = max
def __iter__(self):
self.a = 0
self.b = 1
return self
def __next__(self):
@wzpan
wzpan / plural.py
Created July 30, 2013 13:22
Python - LazyRules
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):
@wzpan
wzpan / romantest1.py
Created July 31, 2013 09:30
Python - A unit test example for convertion between roman number and digit number
#!/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'),
@wzpan
wzpan / file_io.py
Created July 31, 2013 14:27
Python - file I/O
#!/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!
'''
@wzpan
wzpan / videoGFW.js
Last active December 20, 2015 12:19
Javascript - Alternative video source according to ip address
/* 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");