Skip to content

Instantly share code, notes, and snippets.

View socker210's full-sized avatar
🏠
Working from home

Junn socker210

🏠
Working from home
  • Seoul, Republic of Korea
View GitHub Profile
@socker210
socker210 / process.nextTick.js
Created June 22, 2020 10:47 — forked from WebReflection/process.nextTick.js
process.nextTick(callback) for browsers too
!function (window) {"use strict";
// by WebReflection - WTFPL License
var
prefixes = "r webkitR mozR msR oR".split(" "),
process = "process",
nextTick = "nextTick",
i = 0,
p = window[process] || (window[process] = {})
;
while (!p[nextTick] && i < prefixes.length)
@socker210
socker210 / image-arraybuffer.js
Created June 24, 2020 10:43 — forked from harun/image-arraybuffer.js
Create a jpg image from ArrayBuffer data
// Simulate a call to Dropbox or other service that can
// return an image as an ArrayBuffer.
var xhr = new XMLHttpRequest();
// Use JSFiddle logo as a sample image to avoid complicating
// this example with cross-domain issues.
xhr.open( "GET", "http://fiddle.jshell.net/img/logo.png", true );
// Ask for the result as an ArrayBuffer.
xhr.responseType = "arraybuffer";
@socker210
socker210 / rAF.js
Created October 9, 2020 14:45 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@socker210
socker210 / .eslintrc.js
Created November 3, 2020 04:17
ESLint configuration of ts & js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
import React from 'react';
import type { Story, Meta } from '../storybook';
import { Button, ButtonProps } from './button';
export default {
title: 'React/Button',
component: Button,
argTypes: {
children: { name: 'label', control: 'text' },
},
@socker210
socker210 / .prettierignore
Last active June 24, 2021 14:31
prettier configuration
# Folders
node_modules/
dist/
public/
# Files
**/*.json
**/*.md
**/*.html
**/*.sass
@socker210
socker210 / tsconfig.json
Last active August 16, 2021 09:31
tsconfig.json
{
"compilerOptions": {
"skipLibCheck": true,
"isolatedModules": true,
"lib": ["DOM"],
"target": "ES2018",
"noEmit": true,
"strict": true,
"alwaysStrict": true,
"noImplicitAny": true,
@socker210
socker210 / gist:20fd08bad75211cff736bfcde14b9e03
Created July 21, 2021 02:30
vscode core.editor command
git config --global core.editor "code --wait"

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@socker210
socker210 / createChainedFunction.js
Created August 8, 2021 17:08
createChainedFunction
/**
* @see https://github.com/react-bootstrap/react-bootstrap/blob/master/src/createChainedFunction.tsx
*/
function createChainedFunction(...funcs) {
return funcs
.filter(f => f !== null)
.reduce((acc, f) => {
if (typeof f !== 'function') {
throw new Error('Invalid type')
}