Skip to content

Instantly share code, notes, and snippets.

View kaw2k's full-sized avatar

Rasa Welcher kaw2k

View GitHub Profile
@kaw2k
kaw2k / aptos-oidb-zk-ceremony_attestation.log
Created February 26, 2024 18:45
Attestation for aptos-oidb-zk-ceremony MPC Phase 2 Trusted Setup ceremony
Hey, I'm kaw2k-694324 and I have contributed to the aptos-oidb-zk-ceremony.
The following are my contribution signatures:
Circuit # 1 (main)
Contributor # 93
Contribution Hash: b1940c3f dbde7541 55600954 ac1de57e
607a8e2a 45e5225f b3a21106 cb91ca7a
3c4450b7 bc3f8cbc 53fbfa9c 821a9bd3
81b8877f 4e4c77e0 4ef6543f 88885a88
@kaw2k
kaw2k / aptos-oidb-zk-ceremony_attestation.log
Created February 14, 2024 18:33
Attestation for aptos-oidb-zk-ceremony MPC Phase 2 Trusted Setup ceremony
Hey, I'm kaw2k-694324 and I have contributed to the aptos-oidb-zk-ceremony.
The following are my contribution signatures:
Circuit # 1 (main)
Contributor # 4
Contribution Hash: 9c9af0a3 a9915c74 c7d89dd0 2523fd1a
16dcf0a2 5ee60e65 f93ef5be abdad9f5
6815c608 93c4127f bc654673 f05c89a7
34839c44 14c05cf1 8f635093 1b9a6e62
@kaw2k
kaw2k / hooks.tsx
Last active December 20, 2018 15:02
type Loading<T extends object> =
| { loading: true }
| { loading: false; error: true }
| ({ loading: false; error: false } & T)
function usePlayer(id: PlayerId): Loading<{ data: Player }> {
const { value, loading, error } = useDocument(database.players.doc(id))
if (loading) return { loading: true }
if (error) return { loading: false, error: true }
return { loading: false, error: false, data: value.data() }
@kaw2k
kaw2k / generics.md
Last active November 2, 2017 15:43

Hey Fam 👋

I struggled with using typescript and ramda for a long time and figured I would brain dump a little. Maybe it will help some one else! Specifically, I struggled with how typescript can't always infer generics that ramda defines. The result is writing verbose types that are not really necessary, or forcing types with as and !.

Generics are super weird when getting into them, that coupled with ramda being a monster and typescript not being able to readily infer everything is a perfect shitstorm.

Whenever I work with ramda, my workflow is:

  1. Do a thing and assign it to a variable.
  2. If the variable isn't the type I expect, jump to the definition of the function in ramda
/// <reference types="react" />
declare namespace MaterialUI {
type ReactEl = React.ReactChild | null | boolean
export interface MuiTheme {
palette: {
primary?: string,
accent?: string,
import * as React from 'react';
import * as cx from 'classnames';
import Icon, { IconOptions } from './icon';
export interface IClickableIconProps {
iconName?: IconOptions;
iconPosition?: 'before' | 'after';
}
export const addClickableIcon = (children: React.ReactNode, iconName?: IconOptions, iconPosition: 'before' | 'after' = 'before') => {
if (!iconName) { return children; };
import * as React from 'react';
import * as cx from 'classnames';
import * as Router from 'react-router';
import Icon, { IconOptions } from './icon';
/*
We have a few things that are `clickable`:
- buttons
- internal links
- external links
const setPath = (value, path, json) => {
// We reached the end, return the value as a leaf
if (!path.length) return value
// Figure out if we are going down an array or object
const isArrayMatch = path[0].match(/^\[(\d+)\]$/)
const name = isArrayMatch ? isArrayMatch[1] : path[0]
// Add the value to our json recursivly
json = json || (isArrayMatch ? [] : {})
const treeArray = [
{ path: 'name', value: 'name' },
{ path: 'meta.age', value: 'age' },
{ path: 'meta.eyes', value: 'eyes' },
{ path: 'friends.[0]', value: 'friends 0' },
{ path: 'friends.[1]', value: 'friends 1' },
{ path: 'friends.[2]', value: 'friends 2' },
{ path: 'friends.[3].name', value: 'friends 3 name' },
]
export type Tree<T> = Leaf<T> | TreeNodeArray<T> | TreeNodeObject<T>;
type GenericObject<T> = { [key: string]: T };
type ChildrenArray<T> = Tree<T>[];
type ChildrenObject<T> = GenericObject<Tree<T>>
function mapObj<T, U>(fn: ((value: T, key: string) => U), obj: GenericObject<T>): GenericObject<U> {
let ret = {};