Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

潘伟洲 wzpan

🎯
Focusing
View GitHub Profile
@wzpan
wzpan / ruhoh_compile.sh
Last active Dec 18, 2015
Shell - help me compile ruhoh and ask me to push to my repositories
View ruhoh_compile.sh
#!/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 Dec 18, 2015
emacsclient setting on Linux
View ec.sh
# 用ec来快速启动emacs client
alias sudo='sudo '
alias ec='emacsclient -c -a ""'
# 现在可以将emacs设为默认编辑器啦
export EDITOR='emacsclient -c -a ""'
@wzpan
wzpan / ruhoh.sh
Last active Dec 18, 2015
Some settings that can help me manage ruhoh
View ruhoh.sh
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 Jun 14, 2013
Using Pandoc instead of RedCarpet to render the page in Ruhoh. Supports markdown, rst and textile.
View pandoc.rb
require "pandoc-ruby"
class Ruhoh
module Converter
module Markdown
def self.extensions
['.md', '.markdown']
@wzpan
wzpan / notifynet.sh
Last active Dec 19, 2015
Shell - an applet to notify the network status.
View notifynet.sh
#!/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 Dec 19, 2020
Python - Fibonacci Iterator
View fibonacci.py
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 Jul 30, 2013
Python - LazyRules
View plural.py
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 Jul 31, 2013
Python - A unit test example for convertion between roman number and digit number
View romantest1.py
#!/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 Jul 31, 2013
Python - file I/O
View file_io.py
#!/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 Dec 20, 2015
Javascript - Alternative video source according to ip address
View videoGFW.js
/* 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");