Skip to content

Instantly share code, notes, and snippets.

View imzjy's full-sized avatar

Jerry Chou imzjy

View GitHub Profile
@imzjy
imzjy / TransformEmptyElements.cs
Created December 7, 2016 03:19
将XML空元素转换成完整格式, transform the empty XML element to it full end format.
/// <summary>
/// 将XML空元素转换成完整格式,比如 <Element /> => <Element></Element>
/// </summary>
/// <param name="srcFile">待转换XML文件地址</param>
/// <param name="destFile">转换后XML保存文件地址</param>
public static void TransformEmptyElements(string srcFile, string destFile)
{
var srcXML = File.ReadAllText(srcFile);
Regex reg = new Regex(@"<\w+\s/>");
@imzjy
imzjy / Logger.cs
Created September 12, 2016 01:47
.net logger without any dependencies
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace Portal.Common
{
public class Logger
{
@imzjy
imzjy / jquery.snippets.js
Last active August 29, 2015 14:21
javascript and jquery snippets, utils, etc.
//only numberic input
jQuery.fn.ForceNumericOnly = function()
{
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
// home, end, period, and numpad decimal
@imzjy
imzjy / getUrlVars.js
Last active August 29, 2015 14:21
javascript snippets, helper functions.
function getUrlVars(key) {
if(window.location.href.indexOf('?') < 0){
//no query string
return ""
}
var vars = [],
hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
@imzjy
imzjy / tuid.go
Last active August 29, 2015 14:20
golang get uid based on time.sleep
package main
import (
"fmt"
"time"
"strconv"
)
func main(){
for i := 0; i < 2000; i++ {
@echo off
SET st2Path=C:\software\SublimeText\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@imzjy
imzjy / RSAEnryption.cs
Created August 26, 2014 04:07
Encrypt and Decrypt with public key and private key(RSA based)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace ConsoleTester
@imzjy
imzjy / jquery-poll-message.js
Last active August 29, 2015 14:02
JQuery Plugin for poll message notification
/*
JQuery Plugin for poll message from RESTful API
Usage:
[HTML]
<a href="javascript:void;" id="msgText"></a>
[JavaScript]
$('#msgText').pollMessage({
'url': '/newmessage/get',
@imzjy
imzjy / proxy.pac
Last active August 29, 2015 14:02
function FindProxyForURL(url, host) {
var PROXY = "SOCKS5 localhost:1080";
var blocked = ["google.com",
"archive.org",
"youtube.com",
"facebook.com",
"blogspot.com",
"wordpress.com",
"amazonaws.com",
@imzjy
imzjy / molokai.vim
Created March 11, 2014 07:59
VIM colorscheme
" Vim color file
"
" Author: Tomas Restrepo <[email protected]>
"
" Note: Based on the monokai theme for textmate
" by Wimer Hazenberg and its darker variant
" by Hamish Stuart Macpherson
"
hi clear