Skip to content

Instantly share code, notes, and snippets.

View saitonakamura's full-sized avatar
😺

Michael サイトー 中村 Bashurov saitonakamura

😺
View GitHub Profile
@saitonakamura
saitonakamura / RoundedRectGeometry.ts
Created September 15, 2021 11:54
Rounded rectangle geometry for three.js
import {
BufferGeometry,
Float32BufferAttribute,
ShapeUtils,
Shape,
} from "three";
// Adapted from ShapeGeometry
export class RoundedRectGeometry extends BufferGeometry {
parameters: {
@saitonakamura
saitonakamura / github-download-latest-release.sh
Created January 15, 2021 19:28
Will return url of latest asset in given repository filtering asset by 2 substring patterns
# Will return url of latest asset in given repository filtering asset by 2 substring patterns
# e.g. get-github-latest-release ogham/exa exa-linux x86_64
# will returns https://github.com/ogham/exa/releases/download/v0.9.0/exa-linux-x86_64-0.9.0.zip
get-github-latest-release() {
curl -s -L "https://api.github.com/repos/$1/releases/latest" | \
jq ".assets[] | select(.name | contains(\"$2\") and contains(\"$3\")) | .browser_download_url" --raw-output
}
# Example of usage by installing exa
# curl -L "$(get-github-latest-release ogham/exa exa-linux x86_64)" -o /tmp/exa.zip
@saitonakamura
saitonakamura / iterm2-set-colors-preset.sh
Created November 20, 2020 16:44
Sets iTerm2 color preset based on MacOS setting
# Paste in your .bashrc/.zshrc
# Change to your color presets
ITERM2_DARK_PRESET='OneHalfDark'
ITERM2_LIGHT_PRESET='OneHalfLight'
theme=`defaults read -g AppleInterfaceStyle` &>/dev/null
if [ "$theme" = 'Dark' ] ; then
theme='dark'
import { noop, omit } from 'lodash';
import { getCLS, getFCP, getFID, getLCP, getTTFB, ReportHandler } from 'web-vitals'
type IEntryType = 'navigation' | 'resource' | 'paint' | 'measure' | string;
type IAppPerformanceMeasure = 'clientHydration' | 'ssrHydration' | string;
type IAppPerformanceMark =
| 'clientHydrateBegin'
| 'clientHydrateEnd'
/* eslint-disable no-console */
import React, {
useContext,
useEffect,
useCallback,
useMemo,
useRef,
} from 'react';
type LockId = number & { readonly __brand: unique symbol };
import { useReducer, Reducer, useRef, useEffect } from "react";
export type RemoteDataState<T> =
| { type: "initial" }
| { type: "loading" }
| { type: "error"; error: Error }
| { type: "complete"; payload: T };
export type RemoteDataAction<T> =
| { type: "beginLoad" }
@saitonakamura
saitonakamura / fixCircular.js
Last active October 27, 2021 03:29
Function that replace circular js object dependency with "[Circular]" so it can be consumed by JSON.stringify
// DISCLAIMER
// Original function was updated to a faster and es5-supporting version by @Quacky2200
var replaceCircular = function(val, cache) {
cache = cache || new WeakSet();
if (val && typeof(val) == 'object') {
if (cache.has(val)) return '[Circular]';
using System;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace KeyFinder
{
class Program
void Main()
{
var c = new ConfigStuff(new ConfigResolver());
c.GetNormalized().Dump();
}
// Define other methods and classes here
class ConfigStuff {
private readonly Lazy<object> _configNormalizedLazy;
open Js.Promise;
type state('a) = {
data: option('a),
isLoading: bool,
};
type action('a) =
| Load
| Loaded('a);