Skip to content

Instantly share code, notes, and snippets.

View sigma-andex's full-sized avatar

Jan Schulte sigma-andex

View GitHub Profile
@sigma-andex
sigma-andex / Main.js
Created October 30, 2021 16:58
TS Enum representation
"use strict"
exports.x = 15
exports.y = 16
const numberSyntax = 15
exports.numberSyntax = numberSyntax
const stringSyntax = 16
exports.stringSyntax = stringSyntax
@sigma-andex
sigma-andex / tensorflow-rust.md
Created January 24, 2022 10:22
tensorflow 2.7.0 applle m1 rust

Build tensorflow 2.7.0

bazel build --compilation_mode=opt --jobs=4 --config=macos_arm64 tensorflow:libtensorflow.so
bazel build --compilation_mode=opt --jobs=4 --config=macos_arm64 tensorflow/tools/lib_package:libtensorflow

Export variables

export TF_VERSION=v2.7.0
export PKG_CONFIG_PATH=$HOME/.pkg-config
(() => {
// output/Data.Unit/foreign.js
var unit = {};
// output/Control.Lazy/index.js
var defer = function(dict) {
return dict.defer;
};
// output/Data.Bounded/foreign.js
@sigma-andex
sigma-andex / Example.purs
Created May 1, 2022 08:21
HTTPure routing duplex example
module Main where
import Prelude hiding ((/))
import Data.Either (Either(..))
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Effect.Console (log)
import HTTPure (ServerM, found', headers, notFound, ok, serve)
module Main where
import Prelude
import Effect (Effect)
import Effect.Class.Console (logShow)
import Effect.Console (log)
import Record as Record
mergeFlipped = flip Record.merge
@sigma-andex
sigma-andex / hmr-verdaccio.md
Created March 30, 2023 16:44
HMR for verdaccio plugin development

HMR for verdaccio plugin development

Verdaccio doesn't automatically reload plugins when files change, making plugin development a bit painful. So here is my approach for a hot module reload in verdaccio, so that verdaccio restarts whenever your plugin changes.

  1. Create a project folder and a subfolder plugins. Bootstrap the plugin in that folder using the generator so that you end up with something like plugin/verdaccio-my-plugi/ folder structure.

  2. First, let's add a watch mode for your plugin (if you don't have it yet) by adding the following script to you package.json: In plugin/verdaccio-my-plugin/package.json

  "scripts": {
@sigma-andex
sigma-andex / newtype.ts
Created November 14, 2023 22:46
newtype.ts
type Newtype<S extends string, T extends any> = T & { readonly symbol: S}
type Currency = Newtype<'currency', number>
const wrap = <S extends string, T>(input: T): Newtype<S,T> => input as unknown as Newtype<S,T>
const unwrap = <S extends string, T>(input: Newtype<S,T>):T => input satisfies T
const over = <S extends string, T>(nt: Newtype<S,T>, f: (t:T) => T):Newtype<S,T> => {
const t: T = unwrap(nt)
const ft: T = f(t)
return wrap(ft)}
const eur: Currency = wrap(1)