Skip to content

Instantly share code, notes, and snippets.

@leiming
leiming / ex01_1.38.scm
Last active June 6, 2017 13:20
ex01_1.38.scm
#lang sicp
(define (cont-d i)
(let ((n (floor (/ (+ i 1) 3))))
(if (= 0 (remainder (+ i 1) 3))
(* 2 n)
1)))
(define (cont-frac n d k)
(define (iter i result)
var badJSON = '{one : "1:1", two : { three: \'3:3\' }}';
var fixedJSON = badJSON
.replace(/:\s*"([^"]*)"/g, function(match, p1) {
return ': "' + p1.replace(/:/g, '@colon@') + '"';
})
.replace(/:\s*'([^']*)'/g, function(match, p1) {
return ': "' + p1.replace(/:/g, '@colon@') + '"';
})
.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?\s*:/g, '"$2": ')
@leiming
leiming / berlin-jsconf-2014.md
Created May 17, 2016 17:47 — forked from nikcorg/berlin-jsconf-2014.md
Slide decks of JSConf 2014
@leiming
leiming / post-checkout
Last active September 7, 2015 03:49
git-hoots/ 执行 checkout 至特定分支时,执行特定脚本
#!/usr/bin/env bash
#
# Copyright (c) 2015 GAME_TEAM.
#
# -------------------------------------------------
# File: post-checkout
# Location: $GIT_ROOT/.git/hooks/
# Doc: http://git-scm.com/docs/githooks
# Usage:
# cd $GIT_ROOT
@leiming
leiming / addEventListener-polyfill.js
Last active August 29, 2015 14:27 — forked from eirikbacker/addEventListener-polyfill.js
addEventListener polyfill for IE6+
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
@leiming
leiming / default.css
Last active December 28, 2015 15:28
.ace_editor{position:relative;overflow:hidden;font-family:'Microsoft Yahei','Menlo','Ubuntu Mono','Consolas','source-code-pro',monospace;font-size:12px;line-height:normal;color:black;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none;user-select:none}
.ace_scroller{position:absolute;overflow:hidden;top:0;bottom:0;background-color:inherit}
.ace_content{position:absolute;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:text}
.ace_dragging,.ace_dragging *{cursor:move !important}
.ace_dragging .ace_scroller:before{position:absolute;top:0;left:0;right:0;bottom:0;content:'';background:rgba(250,250,250,0.01);z-index:1000}
.ace_dragging.ace_dark .ace_scroller:before{background:rgba(0,0,0,0.01)}
.ace_selecting,.ace_selecting *{cursor:text !important}
.ace_gutter{position:absolute;overflow:hidden;width:auto;top:0;bottom:0;left:0;cursor:default;z-index:4}
.ace_gutter-active-line{position:absolute;left:0;right:0}
.ace_scroller.ace_scroll-left{box-shadow:17px 0 16px -1
@leiming
leiming / gist:6749018
Last active December 24, 2015 05:09
Javascript Vim
" Load Vundle. Manages all of the bundles.
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Specify all bundles.
Bundle 'gmarik/vundle'
" Syntax and language improvements.
Bundle 'helino/vim-json'
@leiming
leiming / reverse.js
Last active December 15, 2015 12:59
array reverse
var array = ["1","2","3","4","5","6","7"];
var j = array.length - 1;
var temp, i = 0;
while(i<j){
temp = array[i];
array[i] = array[j];
array[j] = temp;
i++;
j--;
@leiming
leiming / gist:3762717
Created September 21, 2012 17:15
vimrc
set nocompatible " 非兼容模式
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "honza/snipmate-snippets"
Bundle "garbas/vim-snipmate"