Skip to content

Instantly share code, notes, and snippets.

View ruanyl's full-sized avatar

Yulong Ruan ruanyl

  • Amazon Web Service
View GitHub Profile
@ruanyl
ruanyl / generateUUID.js
Last active April 25, 2016 18:01
nodejs
var Crypto = require('crypto');
function generateUUID() {
var current_date = (new Date()).valueOf().toString();
var random = Math.random().toString();
var num = Crypto.createHash('sha1').update(current_date + random).digest('hex');
return num;
}
There are many ways to open a new buffer with no name, the simplest of which is :new.
:new will create a split window with an unnamed buffer.
:enew will open one in the current window.
:vnew will open one in a vertically split window.
:tabnew will open one in a new tab.
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
@ruanyl
ruanyl / sqrt.js
Last active August 29, 2015 13:57
//开根号
var sqrt = Math.pow(value, 1/2);
var viewportwidth;
var viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}
function ForDight(Dight,How){
Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);
return Dight;
}
@ruanyl
ruanyl / create a simple nodejs http server
Last active August 29, 2015 14:01
simple node js http server
1.npm install connect --save
2.touch server.js
var connect = require('connect');
connect().use(connect.static(__dirname)).listen(8080);
3.node server.js
4.visit localhost:8080
@ruanyl
ruanyl / github_project_pages
Created June 1, 2014 21:05
create github project pages
git checkout --orphan gh-pages
add files of your project pages
git commit -a -m "First pages commit"
git push origin gh-pages
username.github.io/projectname
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install https://github.com/norio-nomura/EasySIMBL/
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@ruanyl
ruanyl / copy_json_object
Created July 21, 2014 08:49
tricky to copy an JSON like object in javascript
JSON.parse(JSON.stringify(obj_json));