Skip to content

Instantly share code, notes, and snippets.

View ClausClaus's full-sized avatar
😁
Happy coding

ClausClaus

😁
Happy coding
View GitHub Profile
@ClausClaus
ClausClaus / phpstorm-auto-semicolon-macro.txt
Created October 7, 2017 01:23 — forked from umidjons/phpstorm-auto-semicolon-macro.txt
PhpStorm: Record Auto semicolon macro and bind shortcut to it
Record Auto semicolon macro and bind shortcut to it:
1. Edit -> Macros -> Start Macro Recording
2. In the editor go to the end of line by pressing End
3. put semicolon ';'
4. Edit -> Macros -> Stop Macro Recording
5. Give a name, for example 'Auto semicolon'
6. Open settings (Ctrl + Alt + s), select Keymap
7. Expand Macros node
8. Select 'Auto semicolon', in the context menu choose Add Keyboard Shortcut
9. Set Ctrl + ; as First keystroke
@ClausClaus
ClausClaus / parseUrl.js
Last active June 29, 2020 03:17
将链接格式化为对象
function parseUrl(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function(){
@ClausClaus
ClausClaus / important.md
Last active April 5, 2020 14:34 — forked from stettix/things-i-believe.md
Things I believe

Important

  • 系统设计

    • 更好的系统通常是更小,更简单的系统
    • 要设计健康的系统,请分而治之。将问题分成较小的部分
    • 分而治之的工作是递归的:将系统分为更简单的子系统和组件的层次结构
    • 告诉您的应用过去的工作尤为重要,因此请确保其可审核
  • 技术

    • 当心炒作或时髦的技术,随着时间的流逝,计算机科学和工程学的基础不会发生太大变化
@ClausClaus
ClausClaus / openNewPage.js
Last active April 4, 2020 10:07
点击a标签打开新页面
function openNewPage(url) {
let a = document.createElement('a');
a.href = url;
a.target="_blank";
a.innerHTML = "链接";
let d = a.getAttribute('href');
try {
let e = document.createEvent('MouseEvents')
e.initEvent('click', true, true) //模拟点击操作
d.dispatchEvent(e)
const array = [1,23,124,23,4,1.423,4,123,222,111,22,23];
[...new Set(array)]
array.filter((item,index)=>array.indexOf(item) === index)
array.reduce((unique,item) => unique.includes(item) ? unique: [...unique,item],[])
@ClausClaus
ClausClaus / regPhoneNum.js
Created April 4, 2020 09:39
格式化手机号码,以横杆分割
'11111111111'.replace(/^(...)(....)/g,'$1-$2-');
@ClausClaus
ClausClaus / publish.sh
Last active August 22, 2019 10:22
一键发布npm包的脚本
#!/usr/bin/env bash
# 1. 版本号每次自增;
# 2. 区分测试和生产 package.json.test, package.json.prod
# 3. 发布到生产前会二次确认
srcName='package.json.test'
if [[ $1 == "prod" ]]
then
srcName='package.json.prod'
read -p "Are you sure to publish to PRODUCTION? [Y/N]" -n 1 -r
echo ""
@ClausClaus
ClausClaus / assign.js
Created July 16, 2019 06:25
assign 对象合并
export const assign = Object.assign || function (target, ...args) {
target = Object(target);
for (let i = 0; i < args.length; i++) {
const source = args[i];
if (source !== null) {
for (const key in source) {
if (hasOwn(source, key)) {
target[key] = source[key];
}
}
@ClausClaus
ClausClaus / formatObj.html
Created March 15, 2019 14:21
从多个对象中取出需要的属性值,隐式的判断ID是否相等
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body></body>
<script type="text/javascript">
/* 无需显式的比较ID是否相等实现数据的对应格式化 */
var friends = { items: [{ user_id: 1 }] }
@ClausClaus
ClausClaus / index.html
Created February 1, 2019 09:14
jsonp example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>jsonp请求测试</title>
</head>
<body>