Skip to content

Instantly share code, notes, and snippets.

View rebornix's full-sized avatar
📓
Working from home

Peng Lyu rebornix

📓
Working from home
View GitHub Profile
@rebornix
rebornix / index
Created June 2, 2015 13:22
Download Trend
<!DOCTYPE html>
<html>
<head>
<title>d3.tip.js - Tooltips for D3</title>
<meta charset="utf-8" />
<title>Bar Chart</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../index.js"></script>
<script type="text/javascript">
data = [{"total":1225, "date": "5.1"},{"total":279, "date": "5.2"},{"total":212, "date": "5.3"},{"total":335, "date": "5.4"},{"total":329, "date": "5.5"},{"total":234, "date": "5.6"},{"total":175, "date": "5.7"}, {"total":1225, "date": "5.1"},{"total":279, "date": "5.2"},{"total":212, "date": "5.3"},{"total":335, "date": "5.4"},{"total":329, "date": "5.5"},{"total":234, "date": "5.6"},{"total":175, "date": "5.7"}, {"total":1225, "date": "5.1"},{"total":279, "date": "5.2"},{"total":212, "date": "5.3"},{"total":335, "date": "5.4"},{"total":329, "date": "5.5"},{"total":234, "date": "5.6"},{"total":175, "date": "5.7"}, {"total":1225, "date": "5.1"},{"total":279, "date": "5.2"},{"total":212,
@rebornix
rebornix / badgeFactory
Created April 24, 2015 02:21
Draw badge(png)
public Bitmap Draw(Color subjectCol, string subjectStr, Color statusCol, string statusStr) {
var fullHeight = 0;
var fullWidth = 0;
var padding = 8;
var shadowOffset = 5;
var font = new Font("Segoe UI", 100, GraphicsUnit.Pixel);
var maxWidth = (subjectStr.Length + statusStr.Length) * 100 + 4 * padding;
Bitmap bitmap = new Bitmap(maxWidth, 200);
using (Graphics g = Graphics.FromImage(bitmap))
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MinLength
{
class Program
{
@rebornix
rebornix / gist:10347284
Created April 10, 2014 06:18
Create a new protocol
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\xm]
@="URL:xm Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\xm\shell]
[HKEY_CLASSES_ROOT\xm\shell\open]
@rebornix
rebornix / CrawlerPathAPI.sh
Created January 11, 2014 13:02
Crawler4PathAPI
from bs4 import BeautifulSoup
import urllib2
url = 'https://path.com/developers/docs'
data = urllib2.urlopen(url).read()
soup = BeautifulSoup(data)
for node in soup.findAll(attrs={'class': 'curl'}):
print node.contents[0]
@rebornix
rebornix / rss2md.py
Created April 11, 2013 12:51
parse rss to markdown
import feedparser
rss_url = ""
feed = feedparser.parse( rss_url )
items = feed["items"]
for item in items:
time = item[ "published_parsed" ]
title = item[ "title" ].encode('gb18030')
fileName = str(time.tm_year) + '-' + str(time.tm_mon) + '-' + str(time.tm_mday) + '-' + title + '.md'
@rebornix
rebornix / gist:4085783
Created November 16, 2012 09:17
Weibo Relation
import urllib2
import urllib
import json
import ConfigParser
COMMENTS_SHOW = 'https://api.weibo.com/2/comments/show.json'
USER_TIMELINE = 'https://api.weibo.com/2/statuses/user_timeline.json'
HDR = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
@rebornix
rebornix / gist:3999713
Created November 2, 2012 09:24
Deploy my Dev Env
#!/bin/bash
sudo apt-get install git
git clone https://github.com/njukidreborn/vimbackup.git ~/.vim
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
ln -s ~/.vim/vimrc ~/.vimrc
ln -s ~/.vim/gvimrc ~/.gvimrc
@rebornix
rebornix / gist:3227889
Created August 1, 2012 15:32
Convert between Column No & Column Name in Excel.
import sys
import string
def NameToNo(name):
result = 0
for ch in name.upper().strip("\n"):
result = result * 26 + ord(ch) - ord('A') + 1
return result
def NoToName(no):
@rebornix
rebornix / gist:3174719
Created July 25, 2012 06:23
A Performance Trace Tool
using System;
using System.Diagnostics;
using System.Text;
namespace Common
{
/// <summary>
/// This class will take down the steps in the api flow, and trace it if the latency is larger than config.
/// </summary>
public static class PerfTracer