Skip to content

Instantly share code, notes, and snippets.

View iahu's full-sized avatar
🌴
On vacation

i18u iahu

🌴
On vacation
View GitHub Profile
@iahu
iahu / pre-commit-eslint
Created March 11, 2016 10:42 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@iahu
iahu / scopes.txt
Created March 28, 2016 10:16 — forked from iambibhas/scopes.txt
Sublime Text 2: Snippet scopes
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
@iahu
iahu / autoTimeString.js
Created May 31, 2016 10:00
最近更新时间
function zPad (n) {
var l = 2;
var z = new Array(l+1).join('0');
return (z+n).slice(-l);
}
function autoTimeString(s) {
s = '' + s.replace(/^\s+/,'').replace(/\s+$/, '');
if ( s.length === 10 ) {
s = s + '000';
@iahu
iahu / tips.css
Created June 14, 2016 03:05
tiny tips module
.mo-tips {
position: fixed;
top: 50%;
left: 50%;
width: 240px;
/*min-height: 100px;*/
margin-top: -50px;
margin-left: -120px;
background-color: #fff;
// a trick of load .config as JSON ;)
require.extensions['.config'] = require.extensions['.json'];
var gulp = require('gulp');
var rmdir = require('rmdir');
var browserify = require('gulp-browserify');
// var named = require('vinyl-named');
var uglify = require('gulp-uglify');
@iahu
iahu / vue.html
Last active November 4, 2016 06:44
Vue 数据绑定原理 简单实现
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<ul id="todo"></ul>
<body>
<script>
@iahu
iahu / webpack.config.js
Created November 29, 2016 14:41
react webpack config file, witch babel and sass
{
"name": "webpack-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server --devtool eval --progress --colors --hot --content-base build",
"test": "echo \"Error: no test specified\" && exit 1"
},
@iahu
iahu / app.js
Last active October 18, 2019 11:07
const dgram = require('dgram');
const serverSocket = dgram.createSocket('udp4');
const multicastAddress = '224.0.0.50';
const multicastPort = 4321;
const serverPort = 9898;
var AqaraAccessoryFactory;
function startServer() {
@iahu
iahu / screenshot-auto-connect.html
Created February 19, 2018 06:49
长图-截图自动拼接demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- select two pictures, and the top one first -->
<input type="file" name="file" id="file" multiple>
<script>
@iahu
iahu / Default(OSX).sublime-keymap
Created July 17, 2019 07:16
Sublime Text 通过 RegReplace 实现对 Mock.js 到 TypeScript 类型声明语句的自动转换
// 绑定/修改 快捷键
[
{ "keys": ["super+v"], "command": "chain",
"args": {
"commands": [
["paste"],
["reg_replace", {"replacements": ["mock_to_number", "mock_to_string", "fix_key_argument", "fix_array_type"]}]
]
},
"context": [