Skip to content

Instantly share code, notes, and snippets.

View nickleefly's full-sized avatar

Xiuyu Li nickleefly

  • Shanghai
View GitHub Profile
@nickleefly
nickleefly / fs_write_stream.js
Last active December 11, 2015 11:38
createWriteStream
var fs = require('fs');
var writeStream = fs.createWriteStream('/Users/asus/Documents/work/writeStream.txt');
var interval = setInterval(function() {
var flushed = writeStream.write((new Date()).toString() + '\n');
console.log('flushed: ', flushed);
}, 100);
setTimeout(function() {
@nickleefly
nickleefly / http_server.js
Created January 22, 2013 14:38
curl -X POST -d "im doing testing" http://localhost:8080 createServer using writeStream and readStream
var http = require('http');
var fs = require('fs');
function randomFileName() {
return '/' + Date.now() + '_' + Math.random() * 1000000 + '.txt';
}
http.createServer(function(req, res) {
var fileName = randomFileName();
console.log('writing request to', fileName);
@nickleefly
nickleefly / register.py
Last active November 14, 2021 07:29
When you install python for all user, this problem will occurs, if you select install python for current, there is no issue. Save this file in your D disk for example, go to cmd run 'python register.py', then you will be able to install easy_install then go to C:\Python27\Scripts run easy_install.exe -U bottle
#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
@nickleefly
nickleefly / python.encode
Created January 26, 2013 08:54
python encoding
> chcp 65001
> set PYTHONIOENCODING=utf-8
> python example.py
Encoding is utf-8
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@nickleefly
nickleefly / net-chat.js
Last active December 11, 2015 21:38
net chat.js
var net = require('net');
var count = 0;
var users = {};
var server = net.createServer(function (conn) {
conn.write(
'\n > welcome to \033[92mnode-chat\033[39m!'
+ '\n > ' + count + ' other people are connnected at this time.'
+ '\n> please write your name and press enter: ');
count++;
@nickleefly
nickleefly / dnode-auth.js
Last active December 13, 2015 21:18
dnode REPL
require('dnode').connect(8090, function(remote) { console.dir(remote)});
@nickleefly
nickleefly / interview.txt
Created February 18, 2013 14:23
Interview With Eliot Horowitz – CTO Of 10gen / MongoDB In this interview, we talk with Eliot Horowitz, founder of 10gen, which is the company that created MongoDB. What's MongoDB? Well, it's an open source, document oriented, schema free database designed for massive scale and performance. If that got your attention, then I invite you to read on…
The evolution of various data models in databases
Advantages of object-oriented databases in terms of horizontal scaling
Handling issues when columns are added or deleted between application versions
Suitability of MongoDB for the cloud
OS support and usage with MongoDB
The company (10gen) wrapped around MongoDB
Community involvement in the development of MongoDB
Scott Swigart: To start, can you introduce yourself, 10gen, and the role of open source behind it?
@nickleefly
nickleefly / Default (OSX).sublime-keymap
Last active May 4, 2018 09:18
sublime setting and plugins
[
{ "keys": ["j", "j"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
},
{ "keys": ["ctrl+d"], "command": "find_under_expand" },
{ "keys": ["ctrl+t"], "command": "toggle_setting",
@nickleefly
nickleefly / check-memory.sh
Last active December 14, 2015 10:09
check memory usage, including RSS PageTables SlabInfo
#/bin/bash
for PROC in `ls /proc/|grep "^[0-9]"`
do
if [ -f /proc/$PROC/statm ]; then
TEP=`cat /proc/$PROC/statm | awk '{print ($2)}'`
RSS=`expr $RSS + $TEP`
fi
done
RSS=`expr $RSS \* 4 / 1024`
PageTable=`grep PageTables /proc/meminfo | awk '{print $2 / 1024}'`