Skip to content

Instantly share code, notes, and snippets.

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

bglgwyng

🏠
Working from home
View GitHub Profile
@bglgwyng
bglgwyng / filter.idr
Created September 29, 2019 12:11
filter with fin
// https://stackoverflow.com/questions/58147978/type-mismatch-occurs-while-the-evaluated-values-are-equal/58148111#58148111
import Data.Fin
import Data.Vect
lemma : {n : _} -> (a : Fin n) -> finToNat (weaken a) = finToNat a
lemma FZ = Refl
lemma (FS x) = rewrite lemma x in Refl
filter : (elem -> Bool) -> Vect len elem -> (p: (Fin (S len)) ** Vect (finToNat p) elem)
@bglgwyng
bglgwyng / miniact.ts
Last active August 3, 2020 10:36
miniact
type UseLocal<Locals> = <K extends keyof Locals, Props>(name: K, call: [Render<Props, any, Locals[K]>, Props]) => Locals[K];
type Render<Props, Locals, Element> = (props: Props, useLocal: UseLocal<Locals>) => Element;
type LocalComponents<Locals> = { [key in keyof Locals]?: Component<any, any, any> };
class Component<Props, Locals, Element> {
private render: Render<Props, Locals, Element>;
constructor(render: Render<Props, Locals, Element>) {
this.render = render;
}
<body>
<textarea></textarea>
<p></p>
<script>
const input = document.querySelector("textarea");
const output = document.querySelector("p");
let isComposing = false;
const flush = () => {
output.innerText += input.value;
import assert from 'assert';
import { sample, shuffle } from 'lodash';
export enum Side {
Left,
Right,
}
export const { Left, Right } = Side;
<body>
<input type="file" accept="image/*" capture="user" />
<script>
const input = document.querySelector("input")
console.info(input)
input.addEventListener("input", async (e) => {
fetch("https://api.exchangeratesapi.io/v1/")
await new Promise((resolve) => setTimeout(resolve, 1000));
fetch("https://api.exchangeratesapi.io/v1/")
});
@bglgwyng
bglgwyng / App.tsx
Last active July 31, 2022 05:37
warm camera example
const App = () => {
return (
<View>
<WarmCamera />
<FooPage />
</View>
);
}
const FooPage = () => {
import * as aws from '@pulumi/aws';
import * as eks from '@pulumi/eks';
import * as k8s from '@pulumi/kubernetes';
import * as pulumi from '@pulumi/pulumi';
import { ComponentResourceOptions } from '@pulumi/pulumi';
export default class AlbIngressController extends pulumi.ComponentResource {
constructor(name: string, args: { cluster: eks.Cluster }, options?: ComponentResourceOptions) {
super('AlbIngressController', name, args, options);
const { cluster } = args;
import React, { ForwardedRef, forwardRef, memo, useCallback, useEffect, useMemo } from 'react';
import { Camera, CameraProps, useCameraDevices } from 'react-native-vision-camera';
import { atom, useRecoilValue, useRecoilValueLoadable, useResetRecoilState, useSetRecoilState } from 'recoil';
type CameraProxyProps = Omit<CameraProps, 'isActive'>;
export const cameraRefState = atom<ForwardedRef<Camera>>({
key: 'cameraRef',
default: null,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package com.rnvc3sandbox.frameprocessor.facerecognizer
import android.graphics.*
import androidx.camera.core.ImageProxy
import androidx.core.graphics.toRectF
import java.io.ByteArrayOutputStream
fun ImageProxy.cropBitmap(cropRect: Rect): Bitmap {
val yBuffer = this.planes[0].buffer // Y
val vuBuffer = this.planes[2].buffer // VU