Skip to content

Instantly share code, notes, and snippets.

View ahuigo's full-sized avatar
😇
I may be slow to respond.

Ahuigo ahuigo

😇
I may be slow to respond.
View GitHub Profile
@russellr922
russellr922 / useMergeState.ts
Created April 4, 2020 10:45
React setState hook typescript (merge)
function isSimpleObject(value: any): boolean {
return !!value && value.constructor === Object;
}
function useMergeState<T>(initialState?: T) {
const [mergeState, setMergeState] = isSimpleObject(initialState)
? React.useState<T>(initialState as T)
: React.useState<Partial<T>>();
const setState = React.useCallback((newState: Partial<T>) => {
@simonrelet
simonrelet / asynchronous.js
Last active March 18, 2023 20:13
React hooks for asynchronous calls
import React from 'react'
/**
* @typedef {object} State The state of asynchronous hooks.
* @property {object | null} error The error.
* @property {boolean} pending Whether the call is pending.
* @property {any | null} result The result of the asynchronous call.
*/
/** @type {State} */
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static