Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# 以下配置信息请自己修改
mysql_user="root" #MySQL备份用户
mysql_password="123" #MySQL备份用户的密码
mysql_host="localhost"
mysql_port="3306"
mysql_charset="utf8" #MySQL编码
backup_db_arr=("infos") #要备份的数据库名称,多个用空格分开隔开 如("db1" "db2" "db3")
backup_location=/home/clinyong/backup/mysql #备份数据存放位置,末尾请不要带"/",此项可以保持默认,程序会自动创建文件夹
@clinyong
clinyong / showSignature.go
Last active August 29, 2015 14:27
Show func signature
func showSignature(any interface{}) string{
fn := reflect.ValueOf(any)
if fn.Kind() != reflect.Func {
return
}
sig := fn.Type().String()
return sig
}
@clinyong
clinyong / Layout.jsx
Last active January 16, 2016 11:19
redux-simple-router-sample
import React from 'react'
import { Link } from 'react-router'
export default class Layout extends React.Component {
render () {
return (
<div>
I'm Layout.
<div>
<Link to='/user'> User </Link>
@clinyong
clinyong / clear_and_margin.html
Created March 9, 2016 23:17
清除浮动两种方法的差异
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>clear与margin重叠</title>
</head>
<body>
1.
<div style="background-color: #f5f5f5;">
@clinyong
clinyong / build.js
Created March 11, 2016 15:38
webpack build script.
import webpack from 'webpack'
import config from './webpack'
import swig from 'swig'
import fs from 'fs'
function writeTemplate (name) {
let sourceTemplate = config.templatePath + '/prod.tmpl'
let targetTemplate = config.buildTemplatePath + '/index.tmpl'
let content = swig.renderFile(sourceTemplate, {name})
fs.writeFile(targetTemplate, content, err => {
var audioCtx = new AudioContext();
var source = audioCtx.createBufferSource();
fetch(
'http://7xsym0.com2.z0.glb.qiniucdn.com/%E9%82%93%E7%B4%AB%E6%A3%8B%20-%20A.I.N.Y.%2528%E7%88%B1%E4%BD%A0%2529.mp3', {
})
.then(function(resp){
resp.arrayBuffer().then(function(buffer){
audioCtx.decodeAudioData(buffer, function(decodedData) {
@clinyong
clinyong / checkTS
Last active January 22, 2017 14:07
use tslint to check ts or tsx file before commit
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM | grep -E "\.tsx?$")
if [ "$files" = "" ]; then
exit 0
fi
pass=true
for file in ${files}; do
@clinyong
clinyong / arguments.js
Created February 24, 2017 00:57
将传入的参数转成数组
var Thunk = function(fn){
return function (){
var args = Array.prototype.slice.call(arguments);
return function (callback){
args.push(callback);
return fn.apply(this, args);
}
};
};
@clinyong
clinyong / walkdir.js
Created February 24, 2017 14:52
walk directory
function walkDir(root) {
const stat = fs.statSync(root);
if (stat.isDirectory()) {
const dirs = fs.readdirSync(root).filter(item => !item.startsWith('.'));
let results = dirs.map(sub => walkDir(`${root}/${sub}`));
return [].concat(...results);
} else {
return root;
}
@clinyong
clinyong / Transaction.js
Created August 19, 2017 08:58
react transaction demo
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/