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 / 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]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MinLength
{
class Program
{
@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))
@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 / soparser.js
Last active August 29, 2015 14:23
Extract information from Stack Overflow question with Noodlejs
var query = {
url: 'http://stackoverflow.com/questions/31095166/angular-mocha-tests-fail-when-i-add-multiple-controllers-to-the-same-module',
type: 'html',
map: {
title: {
selector: "#question-header h1 a",
extract: "text"
},
description: {
selector: ".question .postcell .post-text",
@rebornix
rebornix / q.ts
Created August 4, 2015 07:02
Angular $q written in typescript (draft)
interface PromiseState {
status: number;
}
class Promise {
$$state: PromiseState;
constructor() {
this.$$state = { status : 0 };
}
then(onFulfilled, onRejected, progressBack) {
var result = new Deferred();
@rebornix
rebornix / gist:3120180
Created July 16, 2012 03:06
Convert InFix String to PostFix String
private static string ConvertInFixToPostFix(string inFixExpression)
{
if (inFixExpression == null || inFixExpression.Trim().Length == 0)
return inFixExpression;
inFixExpression = inFixExpression.Replace("(", " ( ");
inFixExpression = inFixExpression.Replace(")", " ) ");
inFixExpression = inFixExpression.ToLower();
string[] tokens = inFixExpression.Split(new string[] { }, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0 || tokens.Length == 1)
@rebornix
rebornix / gist:3120198
Created July 16, 2012 03:08
ConvertToXml
public static XmlDocument ToXml(object thisObj)
{
XmlDocument propertyDoc = new XmlDocument();
XmlNode rootNode = propertyDoc.CreateElement(thisObj.GetType().Name.Replace("[]", "Array"));
propertyDoc.AppendChild(rootNode);
if (thisObj.GetType().IsArray)
{
Array objects = (Array)thisObj;
foreach (object obj in objects)
{
@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
@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):