Skip to content

Instantly share code, notes, and snippets.

/**
* Simple XML parser
* @param {String} xml
* @return {Object}
*/
function parseXML(xml) {
var beg = -1;
var end = 0;
var tmp = 0;
@yulanggong
yulanggong / emoji.ini
Created June 24, 2021 09:08
根据 github emoji 标记转换的搜狗输入法自定义短语
; 根据 github emoji 标记转换的搜狗输入法自定义短语
smile,2=😄
laughing,2=😆
blush,2=😊
smiley,2=😃
relaxed,2=☺️
smirk,2=😏
heart_eyes,2=😍
kissing_heart,2=😘
kissing_closed_eyes,2=😚
@yulanggong
yulanggong / mac_notes.md
Last active July 22, 2019 06:22
Mac Notes

Shortcuts

  • Toggle full screen control + command + F
  • Quit app comman + Q
@yulanggong
yulanggong / autoproxy.sh
Last active February 28, 2019 08:53
Auto change proxy for work and shadowsocks on MacOS
#! /bin/bash
pushd ~/.config;
curl -s -o proxyss.pac http://127.0.0.1:1089/proxy.pac
if [ "$?" = "0" ]; then
cat proxyss.pac proxyw2.js > proxy.pac
cat proxyw2_pre.js proxyw2.js > proxyw2.pac
# find active network service and set autoproxy url
services=$(networksetup -listnetworkserviceorder | grep 'Hardware Port')
@yulanggong
yulanggong / combineVariances.js
Created October 19, 2017 03:24
Combine variances of subsets
/**
* statistics of a set
* @typedef {object} stat
* @prop {numher} count
* @prop {number} average
* @prop {number} variance
*/
/**
* combine variances
@yulanggong
yulanggong / vimsheet.md
Last active June 7, 2017 07:50
Vim Cheat Sheet

Vim Cheat Sheet

Global

  • :help keyword - open help for keyword
  • :o file - open file
  • :saveas file - save file as
  • :close - close current pane

Cursor movement

@yulanggong
yulanggong / github-page-switcher.js
Last active September 19, 2016 01:59
🔃 Switch between github.io and github.com
//Bookmarklet:
//javascript:!function(){var o=location.host.slice(-9);"github.io"==o?location.href.replace(/\/\/([^\.]+)\.github\.io\/([^\/]+)/,function(o,t,i){location.href="https://github.com/"+t+"/"+i}):"ithub.com"==o&&location.href.replace(/github\.com\/([^\/]+)\/([^\/]+)/,function(o,t,i){location.href="https://"+t.toLowerCase()+".github.io/"+i})}();
(function(){
var host = location.host.slice(-9);
if(host == 'github.io'){
location.href.replace(/\/\/([^\.]+)\.github\.io\/([^\/]+)/, function(a, name, project){
location.href = 'https://github.com/' + name + '/' + project;
})
} else if (host == 'ithub.com') {
@yulanggong
yulanggong / checkCompression.js
Last active May 3, 2016 02:28
Checking JS code compression
var isCompressed = (function(){/*This comment will be removed in compression*/}+'').length < 15;
@yulanggong
yulanggong / micro-jquery.js
Last active April 18, 2016 08:46
micro jQuery
var $ = function(s){
if(!(this instanceof $)){
return new $(s);
}
this.push.apply(this, document.querySelectorAll(s));
}
$.fn = $.prototype = [];
$.fn.each = function(fn){
@yulanggong
yulanggong / fajax.js
Created December 17, 2015 03:01
Fake AJAX
//Fake AJAX
$.fajax = function(options){
options = $.extend({
fTime: 16, //delay time
fData: {status: 1}, //response data
fDone: true //success or not
}, options);
return new $.Deferred(function(dfd){