Skip to content

Instantly share code, notes, and snippets.

View sushruth's full-sized avatar
👋

Sushruth Sastry sushruth

👋
View GitHub Profile
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama
docker run --rm --volume /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once open-webui
open http://localhost:3000

Async function to Phasor state

Note: Phasor is the new Fetchable. It is a more general concept from physics and does not collide with other standard keywords in web development.

Introduction

Context

Imagine you have an async function, lets call this the runner -

@sushruth
sushruth / pipeable.ts
Created September 18, 2021 15:49
Another type safe pipe equivalent
class Pipeable<I> {
constructor(public value: I) {}
public pipe<O>(fn: (input: I) => O) {
const output = fn(this.value);
return {
p: new Pipeable(output).pipe,
value: output,
};
}
@sushruth
sushruth / pipeable.ts
Last active September 19, 2021 02:40
Type safe pipe operator equivalent
class Pipeable<I> {
constructor(public value: I) { }
public pipe<O>(fn: (input: I) => O) {
const output = fn(this.value);
return Object.assign(new Pipeable(output).pipe, {
value: output
});
}
}
directive @embedded on OBJECT
directive @collection(name: String!) on OBJECT
directive @index(name: String!) on FIELD_DEFINITION
directive @resolver(
name: String
paginated: Boolean! = false
) on FIELD_DEFINITION
directive @relation(name: String) on FIELD_DEFINITION
directive @unique(index: String) on FIELD_DEFINITION
scalar Date
@sushruth
sushruth / pseudo-with-event-detection.ts
Last active May 13, 2019 07:23
Pseudo logic for temple doors
// To keep track of timestamps
const timestamps = {
inside: null,
outside: null,
};
// `undefined` could be a third symbol like '5' or something
const insideRegister = [undefined, undefined];
const outsideRegister = [undefined, undefined];

Rules to add users

  1. Generate a new GUID somehow
  2. Add the user as a new member to store.users with GUID as the key

Rules to add source

  1. Generate a new GUID somehow
  2. Add the source as a new member to store.sources with GUID as the key
  3. Add this GUID to respective user's sources member
  4. If this is a card,
  • Use final: false and
@sushruth
sushruth / recompile-and-install.bat
Last active June 1, 2017 14:23 — forked from PuKoren/recompile-and-run.sh
Recompile APK + Sign with apktool - Windows version
echo off
:: This is the project folder
set PROJ=%1
shift
:: You must first install apktool (https://github.com/iBotPeaches/Apktool) and android SDK
:: You must also have APKTOOL_HOME, JAVA_HOME/tools and ANDROID_SDK_HOME/build-tools in your PATH (change location as needed)
:: and decompile apk using it
:: apktool d -rf my-app.apk
@sushruth
sushruth / file
Last active February 20, 2017 16:48
freedom_public
{"0.38333830578340966":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMEiut/39Hdf3EQwbKEV67R9SpkNMMFs/9T\r\nEdjSvcqlvQGKCZ1DFQnukZARiNo4oIg2dHFb0h+FoMVDmCBe3WEkOM3/AAAACDxn\r\naXRodWI+wv8AAACOBBATCABA/wAAAAWCWKhwzP8AAAACiwn/AAAACZA2uWpGW6C/\r\nRf8AAAAFlQgJCgv/AAAABJYDAQL/AAAAApsD/wAAAAKeAQAAkWwBAIQC7ubSOUFp\r\nYu6jpzWuF0/rSIl6pfVpgQGngjQ9VIwUAP0TnINUt0N/xqVBiDq6ukWqslPMWEji\r\nq4H67otdFGa2cs7/AAAAVgQAAAAAEggqhkjOPQMBBwIDBIGFmtYAt5PsXU0R5kS7\r\ngUC6WRiiKWhGsFSDy61wNPFivr8iUzTCw8bbPHm4G2lWb3POF/l4vM3hhAtpVNkn\r\nnb0DAQgHwv8AAABtBBgTCAAf/wAAAAWCWKhwzP8AAAAJkDa5akZboL9F/wAAAAKb\r\nDAAAC5gA/2GuZTt918KsmHfy9oy45CrjH97p0a5o4dqZptfJ0FauAQDYMwC6UII8\r\nYHRn7Bx1H3Rr3ugc5DAcgzNTghI9m+7LuA==\r\n=EHGh\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n","0.42092741041157344":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMEiut/39Hdf3EQwbKEV67R9SpkNMMFs/9T\r\nEdjSvcqlvQGKCZ1DFQnukZARiNo4oIg2dHFb0h+FoMVDmCBe3WEkOM3/AAAACDxn\r\naXRodWI+wv8AAACO
@sushruth
sushruth / app.component.ts
Last active February 15, 2017 03:37
Angular 2 empty templates
import {Component, OnInit} from 'angular2/core'
@Component({
selector: 'my-app', // So that wherever you use <my-app></my-app>, this component is compiled and inserted
template: '<h1>{{title}}</h1>', // alternative: templateUrl : '';
})
export class AppComponent implements OnInit { // The OnInit part
// $scope.* variables are declared here without the $scope
title = 'Minimal NgModule';