Skip to content

Instantly share code, notes, and snippets.

View alanhg's full-sized avatar
⌨️
Focusing

Alan.He alanhg

⌨️
Focusing
View GitHub Profile
@alanhg
alanhg / settings.xml
Created August 20, 2019 15:02
maven setting default config
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<repositories>
<repository>
<id> central</id>
<name> Maven Repository Switchboard</name>
<layout> default</layout>
@alanhg
alanhg / .huskyrc
Created September 13, 2019 07:38
husky config
{
"hooks": {
"pre-commit": "tsc --noEmit && lint-staged",
"pre-push": "yarn install && yarn run test"
}
}
@alanhg
alanhg / intl-enzyme-test-helper.ts
Created October 2, 2019 13:16
intl-enzyme-test-helper.ts
import React from 'react';
import { IntlProvider, intlShape } from 'react-intl';
import { mount, render, shallow } from 'enzyme';
const messages = {}; // en.json
const intlProvider = new IntlProvider({ locale: 'en', messages, onError: () => '' }, {});
const { intl } = intlProvider.getChildContext();
function nodeWithIntlProp(node) {
@alanhg
alanhg / enzyme-setup.ts
Created October 2, 2019 13:17
enzyme-setup.ts
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
// React 16 Enzyme adapter
configure({ adapter: new Adapter() });
export default class SagaSpecFactory {
static getAPIStub(apiMethodFunc: any, response: object): any {
return ({ fn, args }, next) => {
if (fn === apiMethodFunc) {
return response;
}
return next();
};
}
}
@alanhg
alanhg / tslint.json
Created January 13, 2020 15:35
tslint
{
"extends": ["tslint:latest", "tslint-react", "tslint-eslint-rules", "tslint-config-prettier"],
"linterOptions": {
"exclude": ["lib/**"]
},
"jsRules": {
"object-literal-sort-keys": false
},
"rules": {
"jsx-no-lambda": false,
import axios from 'axios';
/**
* Cancel previous pending request
*/
const pending = new Map();
export const addPending = config => {
const url = [config.method, config.url].join('&');
config.cancelToken =
@alanhg
alanhg / pre-commit.sh
Last active March 15, 2020 13:45
checkstyle when pre commit
#!/bin/bash
wd=`pwd`
function print(){
echo "===========$*============"
}
print "Start check style for Java"
@alanhg
alanhg / karabiner.json
Last active August 1, 2020 03:06
Filco 87配合Mac改键设置
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
#!/usr/bin/env bash
# Extract the host where the server is running, and add the URL to the APIs
[[ $HOST =~ ^https?://[^/]+ ]] && HOST="${BASH_REMATCH[0]}/api/v4/projects/"
# The description of our new MR, we want to remove the branch after the MR has
# been closed
BODY="{
\"id\": ${CI_PROJECT_ID},
\"source_branch\": \"${CI_COMMIT_REF_NAME}\",
\"target_branch\": \"${TARGET_BRANCH}\",