Skip to content

Instantly share code, notes, and snippets.

View lsongdev's full-sized avatar
👨‍💻
Thinking ...

Lsong lsongdev

👨‍💻
Thinking ...
View GitHub Profile
var gulp = require('gulp');
var less = require('gulp-less');
var jade = require('gulp-jade');
var express = require('express');
var static = require('express-static');
gulp.task('default', [ 'less', 'jade', 'copy', 'watch', 'server' ]);
gulp.task('less', function(){
/**
* sort method
*/
String.prototype.sort = function(){
return this
.split('')
.sort()
.join('');
};
/**
#!/usr/bin/env bash
BIN_NODE=/usr/local/bin/node
# remove link file first .
if [[ -h $BIN_NODE ]]; then
rm -f /usr/local/bin/node
fi
TARGET_NODE=`which $1`
#!/bin/bash
RCol='\033[0m' # Text Reset
# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
Bla='\033[0;30m'; BBla='\033[1;30m'; UBla='\033[4;30m'; IBla='\033[0;90m'; BIBla='\033[1;90m'; On_Bla='\033[40m'; On_IBla='\033[0;100m';
Red='\033[0;31m'; BRed='\033[1;31m'; URed='\033[4;31m'; IRed='\033[0;91m'; BIRed='\033[1;91m'; On_Red='\033[41m'; On_IRed='\033[0;101m';
Gre='\033[0;32m'; BGre='\033[1;32m'; UGre='\033[4;32m'; IGre='\033[0;92m'; BIGre='\033[1;92m'; On_Gre='\033[42m'; On_IGre='\033[0;102m';
Yel='\033[0;33m'; BYel='\033[1;33m'; UYel='\033[4;33m'; IYel='\033[0;93m'; BIYel='\033[1;93m'; On_Yel='\033[43m'; On_IYel='\033[0;103m';
Blu='\033[0;34m'; BBlu='\033[1;34m'; UBlu='\033[4;34m'; IBlu='\033[0;94m'; BIBlu='\033[1;94m'; On_Blu='\033[44m'; On_IBlu='\033[0;104m';
@lsongdev
lsongdev / unsplash-download.js
Last active August 29, 2015 14:22
unsplash images downloader
/**
*
* > unsplash images downloader
*
* # Installtion
* ~$ npm install jsdom
*
* # Usage
* ~$ node unsplash.js
*/
@lsongdev
lsongdev / dump.ftl
Last active August 29, 2015 14:22
Generates tree representations of data model items.
<#-- dump.ftl
--
-- Generates tree representations of data model items.
--
-- Usage:
-- <#import "dump.ftl" as dumper>
--
-- When used within html pages you've to use <pre>-tags to get the wanted
-- result:
-- <pre>
@lsongdev
lsongdev / path-helper.sh
Last active December 25, 2015 11:44
auto load PATH config from /etc/path.d/*
#!/usr/bin/env bash
PATH_DIR=/etc/path.d
for file in $(ls $PATH_DIR); do
for line in $(cat "$PATH_DIR/$file"); do
PATH=$PATH:$line
done
done
var arr = [
{id:1, pid:0, name:"SYSTEM"},
{id:2, pid:1, name:"aa"},
{id:3, pid:2, name:"aaa"},
{id:4, pid:2, name:"b"},
{id:5, pid:0, name:"c"},
{id:6, pid:5, name:"cc"}
];
function generateTree(arr) {
@lsongdev
lsongdev / fire.sh
Last active August 29, 2015 14:23
#!/usr/bin/env bash
# curl -so /usr/local/bin/fire https://gist.githubusercontent.com/song940/0af7aeadbea766bd8a63/raw/fire.sh && chmod +x /usr/local/bin/fire && echo "> DONE"
#
# usage: fire [PORT]
#
REMOTE_HOST=www.lsong.org
REMOTE_PORT=$RANDOM
REMOTE_USER="lsong"
var tmpl = function(str, data){
return str.replace(/#{([\s\S]*?)}/g, function(matchs, key){
return data[key.trim()] || '';
});
};
tmpl("My name is #{name} .", { name: 'lsong' });