Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrisirhc
chrisirhc / template.mermaid
Last active November 3, 2024 12:34
xychart template
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chrisirhc
chrisirhc / money movement.d2
Last active November 7, 2024 13:12
Moving money
IBKR -> Wise (USD): \$1 if over the withdrawal limit
IBKR -> Singapore Banks (SGD): \$15 if over the withdrawal limit, 1/month
// Not allowed at all.
// Wise (USD) -> StraitsX: SWIFT fee (1.13 USD)
// Wise (USD) -> Coinbase: Wire fee min. 11.33 USD
StraitsX -> USDC on Ethereum: Eth network fee max. 30 USD
StraitsX -> USDC on Polygon
StraitsX -> USDT on Tron: Fee 2 USDT
@chrisirhc
chrisirhc / App.test.js
Last active November 12, 2022 14:04
Example using Profiler, keyboard events, and demonstrating effect of memoization. https://reactjs.org/docs/profiler.html
import { Profiler, useState, useMemo } from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event'
let msgs = [];
function pushMsg(id, phase, actualDuration, baseDuration, startTime, commitTime) {
msgs.push([id, phase])
}
function PushProfiler({id, children}) {
return (
https://github.com/jethrokuan/z
@chrisirhc
chrisirhc / next-input.js
Created March 14, 2021 21:55
Next Tab Keystroke goes to next input
function nextFocusInput(e) {
if (e.target.tagName == 'INPUT') {
return;
}
if (!e.relatedTarget || e.relatedTarget.tagName != 'INPUT') {
return;
}
e.preventDefault();
var allInputs = Array.from(document.querySelectorAll('input'));
allInputs[allInputs.indexOf(e.relatedTarget) + 1].focus();
@chrisirhc
chrisirhc / es-animation.js
Created May 25, 2020 21:47
First few lines of react-vis/es/animation.js
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; de
@chrisirhc
chrisirhc / es-animation.js
Created May 25, 2020 21:47
First few lines of react-vis/es/animation.js
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; de
@chrisirhc
chrisirhc / jsx-array.js
Created March 9, 2019 05:01
Convert jsx arrays
'use strict';
module.exports = function(file, api, options) {
const j = api.jscodeshift;
const root = j(file.source);
const ReactUtils = require('./utils/ReactUtils')(j);
function makeSafe(node) {
if (node.type !== 'JSXElement') {
return j.jsxExpressionContainer(node);
@chrisirhc
chrisirhc / gifsicle.sh
Created February 14, 2019 20:54
Gifsicle command
gifsicle -O3 image13.gif -o image13-opt.gif --colors 64 --scale 0.5