Skip to content

Instantly share code, notes, and snippets.

View BrianHung's full-sized avatar
💻
LLMs + local-first apps = autocomplete

Brian Hung BrianHung

💻
LLMs + local-first apps = autocomplete
View GitHub Profile

Keybase proof

I hereby claim:

  • I am brianhung on github.
  • I am blh (https://keybase.io/blh) on keybase.
  • I have a public key ASCM2M22DbC7kHRp54zMxm2W_Iv2YVZmZPFwvD6jOXywiwo

To claim this, I am signing this object:

def Floyd_Warshall(distance_matrix):
"""
An algorithm for finding shortest paths in a weighted graph (with no negative cycles).
Source
- https://en.wikipedia.org/wiki/Floyd–Warshall_algorithm
Output:
- shortest_distance: n**3 matrix from j to k using at most i vertices.
def row_reduce(M):
"""
Assume M is a square matrix whose entries are of type Fraction.
"""
num_rows, num_columns = len(M), len(M[0])
for i in range(num_rows):
# Finds next row to act as ith pivot.
next_row = find_next_row(M, i)
if next_row == None:
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from apiclient import errors
from apiclient.http import MediaIoBaseDownload
from googleapiclient.discovery import build
async function clearMessages() {
const server = ""; // server id number
const author = ""; // user id number
const authToken = ""; // authToken - look inside a network packet
const headers = { 'Authorization': authToken, 'Content-Type': 'application/json' };
const baseURL = `https://discordapp.com/api/v6/channels`;
let searchURL = `https://discordapp.com/api/v6/guilds/${server}/messages/search?author_id=${author}`;
if (typeof channel !== 'undefined') searchURL = searchURL + `&channel_id=${channel}`;
@BrianHung
BrianHung / nltk_most_frequent.py
Last active June 12, 2019 09:19
Given a text_block, return the n most frequent words excluding stop_words, punctuation, and optionally numbers.
import nltk
nltk.download('stopwords')
from nltk import ngrams
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
# Faster than looking at entire list; have to lowercase input.
stop_words = set(stopwords.words("english"))
@BrianHung
BrianHung / UNet3D.py
Last active June 29, 2019 09:02
Implements the UNet model with 3D Convolutions.
def unrolled_UNet3D(inputs):
"""
Implements the UNet model with 3D Convolutions. Refer to the following
source code: https://github.com/jocicmarko/ultrasound-nerve-segmentation.
"""
conv1 = Conv3D( 32, (3, 3), activation='relu', padding='same')(inputs)
conv1 = Conv3D( 32, (3, 3), activation='relu', padding='same')(conv1)
pool1 = MaxPooling3D(pool_size=(2, 2))(conv1)
@BrianHung
BrianHung / pupp.js
Created August 6, 2019 20:52
attempt at puppeteer from client side
!function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=44)}([function(e,t,i){(function(t){const{TimeoutError:n}=i(7),o=i(25)("puppeteer:error"),a=i(11);class r{static evalu
@BrianHung
BrianHung / Math.js
Created November 23, 2019 22:26
Math NodeView for TipTap
import {EditorState } from "prosemirror-state"
import {StepMap } from "prosemirror-transform"
import {keymap } from "prosemirror-keymap"
import {undo, redo } from "prosemirror-history"
import {EditorView } from "prosemirror-view"
import {InputRule } from "prosemirror-inputrules"
import {Node, Plugin } from 'tiptap'
import {PluginKey } from 'tiptap'
import {nodeInputRule } from 'tiptap-commands'
import {NodeSelection } from "prosemirror-state"
@BrianHung
BrianHung / Math.css
Last active October 30, 2022 04:58
Math NodeView for TipTap
.ProseMirror .Math {
display: contents;
}
.ProseMirror .Math .katex-editor {
display: inline;
}
.ProseMirror .Math .katex-render .katex {
font-size: 1em;