Skip to content

Instantly share code, notes, and snippets.

@xufan6
xufan6 / graph.sh
Created January 20, 2012 15:20
通用性较差呢,用于rrd绘图
#!/bin/bash
name="gateway"
declare -a temp_arr
def="DEF:rrd_rtt=$name.rrd:rtt:AVERAGE \
DEF:rrd_pl=$name.rrd:pl:AVERAGE \
VDEF:rtt_max=rrd_rtt,MAXIMUM \
VDEF:pl_max=rrd_pl,MAXIMUM \
-e now -s end-2h \
"
NUM="`rrdtool graph xxx \
@xufan6
xufan6 / update.sh
Created January 20, 2012 15:23
rrd更新用的脚本。-p rrd位置 -n rrd名字 -h要ping的ip -d debug用
#!/bin/bash
RRD_DIR="/tmp"
RRD_NAME="gateway"
while getopts f:p:n:h:d OPTS
do
case $OPTS in
p) RRD_DIR="$OPTARG" ;;
n) RRD_NAME="$OPTARG" ;;
h) HOST_NAME="$OPTARG" ;;
@xufan6
xufan6 / unicode_clock.php
Created February 12, 2012 16:50
unicode clock
<?php
$str0 = "2012-01-24 12:00:00";
function clockit ( $date ){
$t = new DateTime ($date);
$h = $t->format('g');
$a = array (
"🕛","🕐","🕑","🕒","🕓","🕔","🕕","🕖","🕗","🕘","🕙","🕚","🕛"
);
return $a[$h];
}
@xufan6
xufan6 / gist:1867900
Created February 20, 2012 04:46
全角转半角的js
<html>
<textarea name="n" type="text" id="n" onkeyup="CtoH(this);" style="width:100%;height:100%;"></textarea>
<SCRIPT>
function CtoH(obj){
var str=obj.value;
var result="";
for (var i = 0; i < str.length; i++){
if (str.charCodeAt(i)==12288){
result+= String.fromCharCode(str.charCodeAt(i)-12256);
continue;
@xufan6
xufan6 / 4sq_categories.py
Created April 29, 2012 16:50
4sq categories
#/usr/bin/env python
# -*- coding: utf-8 -*-
import sys,urllib2,codecs
try: import simplejson as json
except ImportError: import json
CLIENT_ID="IYLVVWKAC110IENAZ53BJJUJEIDOSK5SVKKLDPAVLCHRLO45"
CLIENT_SECRET="KPW0QHUC2125TSWNZFLMHYXHHAN3BGXZRVZQYO5JS1RUZ3WS"
url="https://api.foursquare.com/v2/venues/categories?client_id="+CLIENT_ID+"&client_secret="+CLIENT_SECRET+"&v=20120615"
#url="file:///tmp/categories"
<!DOCTYPE HTML>
<html><head><meta charset=utf-8 /><title>4sq categories</title></head><body>
<ul>
<li><img src="https://foursquare.com/img/categories/arts_entertainment/default_32.png" />Arts & Entertainment</li>
<ul>
<li> <img src="https://foursquare.com/img/categories/arts_entertainment/arcade_32.png" />Arcade</li>
<li> <img src="https://foursquare.com/img/categories/arts_entertainment/artgallery_32.png" />Art Gallery</li>
<li> <img src="https://foursquare.com/img/categories/arts_entertainment/bowling_32.png" />Bowling Alley</li>
  • Arts & Entertainment Arts & Entertainment * Arcade Arcade * Art Gallery Art Gallery * Bowling Alley Bowling Alley * Casino Casino * Comedy Club Comedy Club * General Entertainment General Entertainment * Historic Site Historic Site * Movie Theater Movie Theater
#!/bin/bash -x
SRC=/home/xf/git/Hotot/data/
DEST=/opt/www/hotot/
echo "\033[1;31;40m[i]Sync ...\033[0m"
# ignore .*.swp, .hgignore, etc
rsync -av --exclude '.*.*' --exclude '*.coffee' --exclude 'test*' $SRC $DEST
# replace conf.vars.platform, key and secret
echo "\033[1;31;40m[i] Replace platform, key and secret ...\033[0m"
plugin.enltarget.draw_guardian([
{
"lat": 29.65357,
"lng": 115.943885,
"time": 1368429231432,
"days": 380,
"player": "honesty",
"title": "九江市生命活水医院",
"guid": "ade47c22469242b2b97957cbcda2682c.11"
},