Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
~ The only constant is change ~

Cem Turan cem2ran

⚛️
~ The only constant is change ~
View GitHub Profile
@dienhoa
dienhoa / SSD.ipynb
Created Aug 21, 2022
SSD Implementation using fastai
View SSD.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@souporserious
souporserious / createComponent.tsx
Last active Apr 10, 2021
createComponent API exploration for JSXUI
View createComponent.tsx
import { createComponent, Stack, Text, Theme, Events } from '@jsxui/react'
export type ButtonProps = {
title: string
background: Theme.Color
color: Theme.Color
stroke: {
align: 'inside' | 'outside'
size: number
color: Theme.Color
@Alia5
Alia5 / cheatsheet.ts
Last active Jun 14, 2022
Advanced Typescript Cheatsheet
View cheatsheet.ts
export type Await<T> = T extends PromiseLike<infer U> ? Await<U> : T;
export type IsPromise<T> = PromiseLike<infer U> ? true : false;
export type Length<T> = T extends { length: infer L } ? L : never;
export type KeysOfType<O, T> = {
[K in keyof O]: O[K] extends T ? K : never;
}[keyof O];
// ConvertLiterals would convert literal types like `1337` to their base type like `number` if set to true
@threepointone
threepointone / feature-flags-client-implementation.md
Last active Aug 24, 2022
Implementing a client for feature flags
View feature-flags-client-implementation.md

On implementing a client for feature flags in your UI codebase

This document isn't an explainer on Feature Flags, you can find that with my amateur writeup, or literally hundreds of better writeups out there.

This document is also agnostic to the choice of service you'd use: LaunchDarkly or split.io or optimizely or whatever; that's orthogonal to this conversation.

Instead, this document is a list of considerations for implementing a client for using Feature Flags for User Interface development. Service providers usually give a simple fetch and use client and that's it; I contend that there's a lot more to care about. Let's dive in.

To encourage usage, we'd like for the developer experience to be as brutally simple as possible. So, this should be valid usage:

@gullyn
gullyn / flappy.html
Last active Sep 28, 2022
Flappy bird in 205 bytes (improved!)
View flappy.html
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>
@angerman
angerman / Installation.md
Last active Apr 9, 2022
Installing nix on macOS BigSur
View Installation.md

The nixos.org website suggests to use:

sh <(curl -L https://nixos.org/nix/install)

For macOS on Intel (x86_64) or Apple Silicon (arm64) based macs, we need to use

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
View setup_conda.sh
#!/usr/bin/env bash
set -e
cd
case "$OSTYPE" in
darwin*) DOWNLOAD=https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh; RC_FILE=.bash_profile ;;
linux*) DOWNLOAD=https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; RC_FILE=.bashrc ;;
*) echo "unknown: $OSTYPE" ;;
esac
@threepointone
threepointone / feature-flags.md
Last active Aug 22, 2022
Feature flags: why, how, all that
View feature-flags.md

(I'm enjoying doing these raw, barely edited writeups; I hope they're useful to you too)

Feature flags

This is my own writeup on feature flags; for a deep dive I'd recommend something like Martin Fowler's article (https://martinfowler.com/articles/feature-toggles.html).

So. Feature flags. The basic idea that you'll store configuration/values on a database/service somewhere, and by changing those values, you can change the user experience/features for a user on the fly.

Let's say that you're building a new feature, called 'new-button' which changes the color of buttons, which is currently red, to blue. Then you'd change code that looks like this -

@jaredpalmer
jaredpalmer / react-scripts+3.4.1.patch
Created May 26, 2020
Speed up Create React App with TypeScript in development
View react-scripts+3.4.1.patch
diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index 25840d9..25c3c41 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -172,7 +172,7 @@ module.exports = function(webpackEnv) {
// The build folder.
path: isEnvProduction ? paths.appBuild : undefined,
// Add /* filename */ comments to generated require()s in the output.
- pathinfo: isEnvDevelopment,
+ pathinfo: false,
View a_description.md

Reading the (already impressive) compiled output in helper.bs.js in the tutorial by Michele Riva on Calling ReasonML from TypeScript, I thought the output could be made nearly identical (bar comments and some weird nest paren wrapping) to what an experienced dev might write by hand

If we:

  1. have Flat-variants-(and polymorphic-variants)-as-strings (see
  2. Omit String(x) when x is already a string (already merged): rescript-lang/rescript-compiler#4293
  3. Propogate the variable names from destructuring a tuple to the output (see ideal_output_2.bs.js)
  4. Don't do nested parens inside of {j|$x foo $y bar $z baz|j} output

Then the output (minus the /* tuple */ comments) would be exactly what you'd write by hand!