Skip to content

Instantly share code, notes, and snippets.

@varHarrie
varHarrie / useAsync.ts
Last active April 1, 2019 06:26
React Hooks
import * as React from 'react'
type Args<F> = F extends (...args: infer A) => any ? A : never
type Parser<T> = (data: any, prevData: T) => T
interface AsyncState<T> {
/** 是否加载中 */
loading: boolean
/** 成功数据 */
@chrislopresto
chrislopresto / component.tsx
Created September 10, 2018 20:12
styled-components v4 + createGlobalStyle + TypeScript
import * as React from 'react';
import { theme } from './theme';
import { ThemeProvider, createGlobalStyle } from './styled-components';
const GlobalStyle = createGlobalStyle`
body {
font-family: Times New Roman;
}
`;
{
"rulesDirectory": [
"node_modules/codelyzer",
"node_modules/rxjs-tslint"
],
"extends": "tslint:latest",
"rules": {
"align": [
true,
"parameters",
@varHarrie
varHarrie / aliases
Last active February 21, 2017 05:47
Set aliases in windows (Place all file in c:\bin and run set_cmd_autorun.reg)
ls=dir /ONE $*
cd=cd /d $*
cnpm=npm $* --registry=https://registry.npm.taobao.org
@btroncone
btroncone / rxjs_operators_by_example.md
Last active September 14, 2025 16:48
RxJS 5 Operators By Example
@tkon99
tkon99 / name.js
Last active October 31, 2025 17:39
Random Name Generator for Javascript
/*
(c) by Thomas Konings
Random Name Generator for Javascript
*/
function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getRandomInt(min, max) {
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active July 24, 2025 16:11
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@markgoodyear
markgoodyear / 01-gulpfile.js
Last active May 5, 2023 03:21
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: