Skip to content

Instantly share code, notes, and snippets.

View ggd543's full-sized avatar

刘永健 ggd543

  • UC
  • 中国广州
View GitHub Profile
@ggd543
ggd543 / scripts
Created June 11, 2017 02:35
Xgdjdv
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.main {
font-size: 18px;
}
@ggd543
ggd543 / index.js
Last active February 22, 2016 13:17
关于nodejs vm.runInNewContext()会出现内存泄露的一点说明
var fs = require('fs');
var vm = require('vm');
var exp = require('express');
var app = exp();
var script = new vm.Script(fs.readFileSync("t2.js", 'utf8'));
var context = { module: {} };
var fn = script.runInNewContext(context);
@ggd543
ggd543 / node-command-line-options.txt
Created February 22, 2016 03:24 — forked from listochkin/node-command-line-options.txt
Node V8 GC-related options
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
@ggd543
ggd543 / gist:1807050
Created February 12, 2012 07:24
插入排序的尾递归写法
@scala.annotation.tailrec
def _insertSort[T](x1: List[T], x2: List[T])(p: (T, T) => Boolean): List[T] = x2 match {
case Nil => x1
case x2_head :: x2_tail =>
val (x1_left, x1_right) = x1.partition( x => p(x, x2_head) )
val x1_new = (x1_left ::: (x2_head :: x1_right))
_insertSort(x1_new, x2_tail)(p)
}
def insertSort[T](xs: List[T])(p: (T, T) => Boolean) = xs match{
class Op(var x : Int) {
def +++(op: Op) = { println(this.x+ " +++ "+op.x); this.x += op.x; this;}
def ***(op: Op) = { println(this.x+ " *** " + op.x); this.x *= op.x ; this;}
}
val op1 = new Op(1)
val op2 = new Op(2)
val op3 = new Op(3)
val op4 = new Op(4)
op1 +++ op2 +++ op3 *** op4 //be equivalent to op1 +++ op2 +++ (op3 *** op4)
@ggd543
ggd543 / 思考一下TernaryOp.test中发生了什么.scala
Created November 23, 2011 07:30
一个比较难懂的隐式转换过程
object TernaryOp {
class Ternary[T](t: T) {
println("Ternary")
def is[R](bte: BranchThenElse[T,R]) = {
println("is ... ")
if (bte.branch(t)) bte.then(t) else bte.elze(t)
}
}
class Branch[T](branch: T => Boolean) {
println("branch");
@ggd543
ggd543 / gist:1343074
Created November 6, 2011 16:02 — forked from notyy/gist:1343063
logger mixin
abstract class BizService {
def doIt()
}
class Worker extends BizService {
def doIt() {println("I am working")}
}
trait Logger extends BizService {
abstract override def doIt() {println("logMe first");super.doIt()}
@ggd543
ggd543 / IO.java
Created September 24, 2011 13:09
java.io.EOFException: Unexpected end of ZLIB
package com.travelsky.esb.emd.utils;
import org.mule.util.IOUtils;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* Created by IntelliJ IDEA.
@ggd543
ggd543 / test
Created May 11, 2011 15:59
test
test