Skip to content

Instantly share code, notes, and snippets.

View yesvods's full-sized avatar
💭
Getting things done.

Jogis yesvods

💭
Getting things done.
View GitHub Profile
@yesvods
yesvods / index.js
Created February 6, 2017 12:08 — forked from edokeh/index.js
佛祖保佑,永无 BUG
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@yesvods
yesvods / source.list
Last active February 6, 2018 17:32
ubuntu 16.04
# Intel
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
@yesvods
yesvods / checkDirectorySync.js
Created April 19, 2016 14:36
check if directory exist, if not, create one.
function checkDirectorySync(directory) {
try {
fs.statSync(directory);
} catch(e) {
fs.mkdirSync(directory);
}
}
@yesvods
yesvods / template.js
Created April 4, 2016 08:32
Javascript template engine
function template(html, data){
//process html template
html = html.replace(/>/g, ">")
.replace(/&lt;/g, "<")
.replace(/[\r\t\n]\s+/g, '')
.trim();
var re = /<%([^>]+)?%>/g,
reExp = /(^( )?(if|for|else|switch|case|break|{|}|var|let|const))(.*)?/g,
code = 'var r=[];\n',
@yesvods
yesvods / save.js
Created January 22, 2016 03:41
Save variable string to file in browser
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
@yesvods
yesvods / ls.js
Created January 21, 2016 09:54
LocalStorage MaxSzie
if (localStorage && !localStorage.getItem('size')) {
var i = 0;
try {
// Test up to 10 MB
for (i = 250; i <= 10000; i += 250) {
localStorage.setItem('test', new Array((i * 1024) + 1).join('a'));
}
} catch (e) {
localStorage.removeItem('test');
localStorage.setItem('size', i - 250);
@yesvods
yesvods / express-lite.js
Last active January 2, 2016 15:46
Express-lite
function server(req, res){
let next = () => {
//deal with ending job
}
middlewares.reduceRight((next, middleware) => {
return () => {
middleware(req, res, next)
}
}, next)();
}
@yesvods
yesvods / gist:51af798dd1e7058625f4
Created August 15, 2015 11:13
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
@yesvods
yesvods / gist:4c7251f060029c8a5b07
Last active October 1, 2018 13:44
Merge Object with ES7 object spread
const obj1 = {name:"xiaoming", age: 23}
const obj2 = {age: 33}
const obj3 = {...obj1, ...obj2}
//obj3 ==> {"name":"xiaoming","age":33}
@yesvods
yesvods / node-folder-structure-options.md
Last active April 2, 2018 15:33 — forked from lancejpollard/node-folder-structure-options.md
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin