Skip to content

Instantly share code, notes, and snippets.

View ruanyl's full-sized avatar

Yulong Ruan ruanyl

  • Amazon Web Service
View GitHub Profile
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));
@ruanyl
ruanyl / if_cmd_exist
Created July 21, 2014 20:06
Bash Shell Find Out If A Command Exists On UNIX / Linux System ($PATH) OR Not
#!/bin/bash
# POSIX command lookup example
CMDS="tar /usr/bin/mysqldump /path/to/other/command"
for i in $CMDS
do
# command -v will return >0 when the $i is not found
command -v $i >/dev/null && continue || { echo "$i command not found."; exit 1; }
done