Skip to content

Instantly share code, notes, and snippets.

View imnemo's full-sized avatar
🎯
focusing on preparing magicjs

imnemo imnemo

🎯
focusing on preparing magicjs
  • Chengdu in Sichuan of China
View GitHub Profile
@imnemo
imnemo / lazy.ts
Created August 26, 2020 09:57 — forked from kingfolk/lazy.ts
typescript lazy decorator
function Lazy<T>(initializer: () => T) {
// the return type of a property decorator function must be either 'void' or 'any'
return function lazy(target, name): any {
function set(value, that = this) {
Object.defineProperty(that, name, {
enumerable: true,
configurable: false,
writable: false,
value: value,
});
@imnemo
imnemo / net.js
Created May 21, 2019 08:09 — forked from sid24rane/net.js
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
var net = require('net');
// creates the server
var server = net.createServer();
//emitted when server closes ...not emitted until all connections closes.
server.on('close',function(){
console.log('Server closed !');
});
@imnemo
imnemo / Clang-format Comparison.md
Created April 28, 2019 09:27 — forked from andrewseidl/ Clang-format Comparison.md
Clang-format style comparison

This is a comparison of the different formatting styles including with clang-format.

Generated via:

styles=( LLVM Google Chromium Mozilla WebKit )
for style in $styles
do
  clang-format -style=$style ChLcpIterativeAPGD.h > ChLcpIterativeAPGD.$style.h

done

{"sig":"e22e19ae3ce79a23bd2897824e0320b5c24411937555576203bde75c30eb7ca9dd87f747d02350f904098435e1a174df61df2505cbf4d345bc27d909b29c34110","msghash":"6e39c1ce5a2a06826791f224ae1f208aa494f72eaa15c948c9bb204de9c361df"}
@imnemo
imnemo / emfile.js
Created August 29, 2013 10:07 — forked from joshkehn/emfile.js
var exec = require('child_process').exec,
spawn = require('child_process').spawn;
function create_path (basename, y, m, d, callback) {
var path = [basename, y, m, d].join('/'), mkdir;
mkdir = spawn('mkdir', ['-p', path], function (err, out, err_out) {
if (err) throw err;
callback(path, {stdout: out, stderr: err_out});
});
@imnemo
imnemo / rAF.js
Created May 15, 2013 02:19 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@imnemo
imnemo / test_closure
Created April 26, 2013 09:26
JS闭包test
!function(win){
var b = 'b';
var doSth = function(cb){
cb.call(this, b);
}
win.doSth = doSth;
}(window)
!function(win){
var a = 'a';
win.doSth(function(param){
@imnemo
imnemo / Secrets of PHP.php
Last active December 10, 2015 08:08
Secrets of PHP
<?php
/**
* 数组下标可以是一个空字符串
* /
var_dump(array(''=>1));
/**
* 关于三目条件运算符 ?:(h1 ? h2 : h3)
* 第二个操作数h1与第一个操作数h2相同时, h2可以省略不写!
* 这省了不少事儿!
@imnemo
imnemo / mouse.js
Created December 3, 2012 07:01 — forked from rhiokim/mouse.js
Read Linux mouse(s) in node.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe (marcloehe@gmail.com)
*
* Adapted from Tim Caswell's nice solution to read a linux joystick
* http://nodebits.org/linux-joystick
* https://github.com/nodebits/linux-joystick
*/
var fs = require('fs'),