Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

i18u iahu

🌴
On vacation
View GitHub Profile
@iahu
iahu / helper.js
Last active Jun 23, 2020
use es6 destructuring assignment to reduce logic control (the if else statement)
View helper.js
export const NORMAL_RULE = 1
export const WEEKDAY_RULE = 2
export const WEEKEND_RULE = 3
export const getRuleTypeByDate = ms => Math.ceil(new Date(ms).getDay() / 5) + 1
export const typeMap = {
[NORMAL_RULE]: '不区分常规休息日',
[WEEKDAY_RULE]: '常规',
[WEEKEND_RULE]: '休息日'
@iahu
iahu / .importjs.js
Last active Apr 29, 2021
importjs use tsconfig paths
View .importjs.js
const Path = require('path');
const tsconfig = require('./tsconfig.json');
const baseUrl = tsconfig.compilerOptions.baseUrl;
const paths = tsconfig.compilerOptions.paths;
// 优先使用短的 key
const pathKeys = Object.keys(paths).sort((a, b) => b.length - a.length);
const removeWired = (str) => str.replace(/\*$/, '');
View ipadOS-full-keyboard-access.md
  • 在连接蓝牙键盘的情况下在触摸屏上调出软键盘:长按屏幕右下角(输入法工具栏最右边)的箭头
  • 开启全键盘控制后用上下键控制 Safari 滚动:按 ctrl-opt-cmd-p 开启直通模式
  • Safari 下开启 tabIndex 导航: opt-tab
View subl.key
— BEGIN LICENSE —–
ZYNGA INC.
50 User License
EA7E-811825
927BA117 84C9300F 4A0CCBC4 34A56B44
985E4562 59F2B63B CCCFF92F 0E646B83
0FD6487D 1507AE29 9CC4F9F5 0A6F32E3
0343D868 C18E2CD5 27641A71 25475648
309705B3 E468DDC4 1B766A18 7952D28C
E627DDBA 960A2153 69A2D98A C87C0607
@iahu
iahu / .importjs.js
Created May 14, 2020
importjs config file
View .importjs.js
module.exports = {
environments: ['browser'],
globals: ['Pagckage', 'Npm'],
namedExports: {
underscore: ['omit', 'debounce', 'memoize', 'groupBy']
},
groupImports: true,
sortImports: true,
danglingCommas: false,
stripFileExtensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
@iahu
iahu / README.md
Created May 9, 2020
Enable Emmet Tab key for Vue syntax in Sublime Text
View README.md

By default, Emmet disable Tab key works at text.html scope, so Tab key just work in a whitelist of the know html tags.

To enable Emmet for Vue syntax in Sublime Text, we can exclude the text.html.vue form text.html scope in our user Emmet setting:

{
  "disabled_single_snippet_for_scopes": "text.html - text.html.vue"
}
@iahu
iahu / README.md
Created Jul 17, 2019
通过 AppleScript 实现快速更新 iconfont.cn 网站 css 版本更新
View README.md
  1. 通过在 Mac OSX 的 Automator 上创建一个 “快速操作” 可以为浏览器添加一个自定义的右键菜单命令。

  2. 再利用脚本去更新对应文件就可以实现 css 版本的快速更新了。

@iahu
iahu / Default(OSX).sublime-keymap
Created Jul 17, 2019
Sublime Text 通过 RegReplace 实现对 Mock.js 到 TypeScript 类型声明语句的自动转换
View Default(OSX).sublime-keymap
// 绑定/修改 快捷键
[
{ "keys": ["super+v"], "command": "chain",
"args": {
"commands": [
["paste"],
["reg_replace", {"replacements": ["mock_to_number", "mock_to_string", "fix_key_argument", "fix_array_type"]}]
]
},
"context": [
@iahu
iahu / screenshot-auto-connect.html
Created Feb 19, 2018
长图-截图自动拼接demo
View screenshot-auto-connect.html
<!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>
View app.js
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() {