Skip to content

Instantly share code, notes, and snippets.

@zD98
zD98 / NodeJS-MD5
Created August 8, 2017 03:05
create md5 by using crypto
crypto.createHash('md5').update(data).digest("hex");
@zD98
zD98 / CryptoJS-DES.html
Created July 13, 2017 11:33 — forked from ufologist/CryptoJS-DES.html
Use CryptoJS encrypt message by DES and direct decrypt ciphertext, compatible with Java Cipher.getInstance("DES")
<!-- test pass with CryptoJS v3.1.2 -->
<script src="rollups/tripledes.js"></script>
<script src="components/mode-ecb.js"></script>
<script>
/**
* Encrypt message by DES in ECB mode and Pkcs7 padding scheme
*
* NOTE: DES is weak, please use 3DES(Triple DES) or AES
*
* @param {String} message
@zD98
zD98 / nodejs.errno.h
Created July 6, 2017 07:24 — forked from pbojinov/nodejs.errno.h
node.js errno descriptions. Useful for debugging.
/* Pulled from https://github.com/joyent/node/blob/master/deps/uv/include/uv.h */
/* Expand this list if necessary. */
#define UV_ERRNO_MAP(XX) \
XX(E2BIG, "argument list too long") \
XX(EACCES, "permission denied") \
XX(EADDRINUSE, "address already in use") \
XX(EADDRNOTAVAIL, "address not available") \
XX(EAFNOSUPPORT, "address family not supported") \
XX(EAGAIN, "resource temporarily unavailable") \
XX(EAI_ADDRFAMILY, "address family not supported") \
@zD98
zD98 / Flyweight.md
Created March 23, 2016 01:02
设计模式-享元模式

##Flyweight模式

###总结 用于优化重复, 缓慢及数据共享效率较低的代码, 通过与相关对象共享尽可能多的数据来减少应用程序中的内存使用 理解:将公用的数据抽象出来作为内层数据, 外层数据是对内层数据的一种处理与引用

###例子 //Book是享元的内层

@zD98
zD98 / Decorator.md
Created March 23, 2016 01:01
设计模式-装饰器模式

##Decorator模式(*) ###总结 向基本对象添加(装饰)属性或方法, 而不是进行子类化

###例子 eg.1简单实现-对对象的属性扩展 function vehicle(vehicleType) { this.xxx = ...; }

@zD98
zD98 / Mixin.md
Created March 23, 2016 01:00
设计模式-混入模式

##Mixin模式 ###总结 函数复用, 从其它对象原型中共享属性和方法的对象 子类化 ###例子

function augment(receivingClass, givingClass){
	//覆盖&扩展
	if(arguments[2]){

for(var i=2,len=arguments.length; i

@zD98
zD98 / Facade.md
Last active March 19, 2016 01:41
设计模式-外观模式

##Facade模式

###总结 提供了更简单的公有接口, 隐藏底层的真实复杂性 ###例子 eg.jQuery.ready() bindReady : function() { ... if(document.addEventListener){ document.addListener("DOMContentLoaded", DOMContentLoaded, false);

@zD98
zD98 / Factory.md
Created March 19, 2016 01:41
设计模式-工厂模式

##Factory模式 ###总结 提供一个通用的接口来创造对象 ###例子 eg function Car(options){} function Truck(options){}

function VehicleFactory() {}

##Command模式 ###总结

将方法调用, 请求, 操作等封装到单一对象, 
从而根据不同的请求对客户进行参数化和传递可供执行的方法调用

###例子 eg.1 (function(){ var CarManager = {

@zD98
zD98 / Prototype.md
Created March 19, 2016 01:37
设计模式-原型模式

##Prototype模式 ###总结 在一个对象中定义一个函数, 它们都是由引用创建(所有子对象都指向相同的函数),而不是单独copy,提高了性能

###例子 eg 1. (规定)要求原型继承使用object.create

	var vechile= { 

getModel:function () {}