Sign a ssl cert and renew by cronjob.
softwares:
- wget
- nginx
- nano
'use strict'; | |
/** | |
* Deep object flattener | |
* flatten an object, the message will be pull out, array index/nested key will be chained to be a new key. | |
* @param {object} obj - the target object | |
* @param {string} [prefix = ''] - the prefix of each key | |
* @return {object} flattened object | |
*/ | |
function deepFlatten(obj, prefix = '') { |
/** | |
* @param {Function} fn - The function wanted to be currified | |
* @return {Function} a currified function | |
*/ | |
function curry(fn) { | |
return curryHelper(fn); | |
} | |
// private helper, not expose to client | |
function curryHelper(fn, memory = [], ...args) { |
/** | |
* Transform CSV to a 2D array | |
* @param {String} csvString | |
* @param {String} [separator=,] | |
* | |
*/ | |
function csvToArray(csvString, separator = ',') { | |
const sRegExp = new RegExp(`(^"|${separator}"|{linebreak}")(.*?)("${separator}|"{linebreak}|"$)`, 'g'); // matching field contents | |
return csvString | |
.replace(/\r/g, '') // remove part of window linebreak symbols |
function isBalanced(val) { | |
if(val.length) { | |
// strip off the nestest braces | |
const replaced_val = replaceBraces(val); | |
if(val === replaced_val) | |
return 'NO'; | |
else | |
return isBalanced(replaced_val); | |
} else { | |
return 'YES'; |
/** | |
* Remove html tag, css, js of html string to extract the contents | |
* @param {String} html | |
* @return {String} contents of the html | |
*/ | |
function extractContents(html) { | |
return html | |
.replace(/(\n|\r|\t)/gm, '') // remove linebreaks | |
.replace(/<(style|script|link|noscript).*?>.*?<\/(style|script|link|noscript)>/g, '') // remove css, js blocks | |
.replace(/<!--.*?-->/g, '') // remove comments |
class Counting extends Array { | |
constructor(...items) { | |
if (items.length > 1) super(...items); | |
else { | |
super(); | |
this.push(...items); | |
} | |
} | |
swap(idx1, idx2) { | |
const length = this.length; |
// http://imweb.io/topic/59dc5a8b856028aa249e2a58 | |
// https://segmentfault.com/a/1190000006930013 | |
// 總之,IE真的是毒瘤... | |
{ | |
"presets": [ | |
["es2015", | |
{ | |
"loose": true | |
}], | |
"stage-0" |
#!/bin/bash | |
while read oldrev newrev ref | |
do | |
branch=`echo $ref | cut -d/ -f3` | |
if [ "master" == "$branch" ]; then | |
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch | |
echo 'Changes pushed live.' | |
fi |
SELECT * FROM singers LIMIT 5; | |
SELECT * FROM songs WHERE singer_id = 1; | |
SELECT * FROM songs WHERE singer_id = 2; | |
SELECT * FROM songs WHERE singer_id = 3; | |
SELECT * FROM songs WHERE singer_id = 4; | |
SELECT * FROM songs WHERE singer_id = 5; |