Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View iahu's full-sized avatar
🌴
On vacation

i18u iahu

🌴
On vacation
View GitHub Profile
const mondayFirstWeekDay = day => (day + 7) % 8
const isWeekend = date => !!Math.floor(mondayFirstWeekDay(date.getDay()) / 6)
@iahu
iahu / helper.js
Last active June 23, 2020 10:56
use es6 destructuring assignment to reduce logic control (the if else statement)
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 April 29, 2021 08:52
importjs use tsconfig paths
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(/\*$/, '');
  • 在连接蓝牙键盘的情况下在触摸屏上调出软键盘:长按屏幕右下角(输入法工具栏最右边)的箭头
  • 开启全键盘控制后用上下键控制 Safari 滚动:按 ctrl-opt-cmd-p 开启直通模式
  • Safari 下开启 tabIndex 导航: opt-tab
— 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 09:50
importjs config file
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 03:27
Enable Emmet Tab key for Vue syntax in Sublime Text

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 July 17, 2019 07:23
通过 AppleScript 实现快速更新 iconfont.cn 网站 css 版本更新
  1. 通过在 Mac OSX 的 Automator 上创建一个 “快速操作” 可以为浏览器添加一个自定义的右键菜单命令。

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

@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": [
@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>