Skip to content

Instantly share code, notes, and snippets.

View jiayihu's full-sized avatar
:octocat:
Nyaning in O(1)

Jiayi Hu jiayihu

:octocat:
Nyaning in O(1)
View GitHub Profile
@jiayihu
jiayihu / scroll.ts
Created December 8, 2017 20:01
Pure JS animated scrollTop using requestAnimationFrame
export function animateScrollTop(element: HTMLElement, value: number, timing: number) {
let start: number = null;
let animationToken: number;
const valueSign = value >= 0 ? 1 : -1;
const currentScroll = element.scrollTop;
const step = (timestamp: number) => {
if (!start) {
start = timestamp;
}
@jiayihu
jiayihu / action-lifecycle.middleware.ts
Created March 9, 2017 14:32
Allow subscription, as Promise, to redux-saga and redux-observable POJO actions
import { Middleware } from 'redux';
export interface IActionLifecycle {
resolveType: string;
rejectType: string;
}
/**
* Middleware which allows to chain async actions as Promises.
* @see https://github.com/redux-observable/redux-observable/issues/90
@jiayihu
jiayihu / actionCreator.ts
Last active September 20, 2019 13:10
Minimal action creator factory for redux-observable and redux-saga
import { IAction } from '../types/redux.types';
import { actionTypes as errorTypes, showError } from './errors.actions';
interface IPayloadCreators {
request(...args: any[]): any;
success(...args: any[]): any;
failure?(errorMsg: string): any;
}
interface IActionCreator {
{
"Right Option Key Sends" : 0,
"Tags" : [
],
"Ansi 12 Color" : {
"Red Component" : 0.1268280595541,
"Color Space" : "Calibrated",
"Blue Component" : 0.998526930809021,
"Alpha Component" : 1,
@jiayihu
jiayihu / Preview.md
Last active October 31, 2018 21:54
Chrome snippet to console log your localStorage in a pretty format

Preview