Skip to content

Instantly share code, notes, and snippets.

@moyix
moyix / copilot_proxy.py
Created July 29, 2022 03:58
Proxy between Copilot and a Triton inference server running FasterTransformer
#!/usr/bin/env python
import time
import random
import string
from flask import Flask, request
import numpy as np
import tritonclient.grpc as client_util
import json
from tritonclient.utils import np_to_triton_dtype
load("@io_bazel_rules_docker//container:providers.bzl", "BundleInfo", "ImageInfo")
load("//deployment/docker:image_name.bzl", "image_name")
load(":providers.bzl", "DigestInfo", "RepoInfo")
def _bundle_impl(target, ctx):
bundle_info = target[BundleInfo]
return RepoInfo(image_digests = {
image_name(bundle_info, x[ImageInfo]): x[DigestInfo]
for x in ctx.rule.attr.image_targets
})
@mlin
mlin / README.md
Last active December 1, 2023 13:56
static.wiki database compression

Context: static.wiki and Show HN post

We downloaded static.wiki's 40.3 GiB SQLite database of English Wikipedia and created a compressed version of it with sqlite_zstd_vfs, our read/write Zstandard compression layer for SQLite3. The compressed version is 10.4 GiB (26%), and the VFS supports HTTP random access in the spirit of the original (although we don't yet have a WebAssembly build; it's a library for CLI & desktop apps for now). You can try it out on Linux or macOS x86-64:

pip3 install genomicsqlite
genomicsqlite https://f000.backblazeb2.com/file/mlin-public/static.wiki/en.zstd.db \
    "select text from wiki_articles where title = 'SQLite'"
@anedward01
anedward01 / Edit_Repack_ISO_tutorial.md
Last active March 25, 2024 03:17 — forked from AkdM/Edit_Repack_ISO_tutorial.md
Edit and repack .iso bootable image

On Linux

Installing mkisofs

apt-get install mkisofs

Editing ISO image

mkdir /tmp/custom_iso

@bokwoon95
bokwoon95 / comments.sql
Last active March 22, 2024 22:31
how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- The comment tree:
-- [1]
-- / \
-- [2] [4]
-- / \ \
-- [3] [7] [6]
-- /
-- [5]
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
load("@io_bazel_rules_docker//container:providers.bzl", "BundleInfo", "ImageInfo")
load("//deployment/docker:image_name.bzl", "image_name")
load(":providers.bzl", "DigestInfo", "RepoInfo")
def _bundle_impl(target, ctx):
bundle_info = target[BundleInfo]
return RepoInfo(image_digests = {
image_name(bundle_info, x[ImageInfo]): x[DigestInfo]
for x in ctx.rule.attr.image_targets
})

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@frzi
frzi / index.d.ts
Last active September 19, 2019 19:56
Polka Typescript definitions
/**
* Potential candidate for @types/polka.
*/
// Type definitions for polka 1.0.0
// Project: https://github.com/lukeed/polka
// Definitions by: Freek Zijlmans <https://github.com/frzi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
@ServerlessBot
ServerlessBot / IAMCredentials.json
Last active December 20, 2023 16:50
Minimum credential set for Serverless Framework
{
"Statement": [
{
"Action": [
"apigateway:*",
"cloudformation:CancelUpdateStack",
"cloudformation:ContinueUpdateRollback",
"cloudformation:CreateChangeSet",
"cloudformation:CreateStack",
"cloudformation:CreateUploadBucket",