Skip to content

Instantly share code, notes, and snippets.

View saibotsivad's full-sized avatar
💖
JavaScript

Tobias Davis saibotsivad

💖
JavaScript
View GitHub Profile
@saibotsivad
saibotsivad / generate-embeddings.py
Last active February 9, 2024 14:18
Generate embeddings for a single file
from transformers import AutoTokenizer, AutoModel
import torch
def load_model(model_name="sentence-transformers/bert-base-nli-mean-tokens"):
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModel.from_pretrained(model_name)
return tokenizer, model
def generate_embedding(text, tokenizer, model):
@saibotsivad
saibotsivad / README.md
Created December 14, 2021 22:17
OpenAPI with @cfworker/json-schema

Given an OpenAPI definition, I would like to validate a request (query params, path params, etc.) using @cfworker/json-schema.

I've developed a way to do it, but it requires me to use the validate function instead of new Validator.

A simple OpenAPI definition might look like this:

{
    "openapi": "3.1.0",
    "components": {
@saibotsivad
saibotsivad / .editorconfig
Last active November 3, 2023 20:08
editor config
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
[*.js]
insert_final_newline = true
trim_trailing_whitespace = true
@saibotsivad
saibotsivad / README.md
Created October 1, 2020 17:05
Hacktoberfest Burnout Bot
@saibotsivad
saibotsivad / just-an11ty-starter.txt
Created September 30, 2020 04:29
an11ty starter template dependency tree
davistobias.com@0.0.0 /Users/saibotsivad/Development/git/davistobias.com
├─┬ @an11ty/template@0.0.4
│ ├─┬ @11ty/eleventy@0.11.0
│ │ ├── @11ty/dependency-tree@1.0.0
│ │ ├─┬ browser-sync@2.26.12
│ │ │ ├─┬ browser-sync-client@2.26.12
│ │ │ │ ├── etag@1.8.1 deduped
│ │ │ │ ├── fresh@0.5.2 deduped
│ │ │ │ ├── mitt@1.2.0
│ │ │ │ └─┬ rxjs@5.5.12
@saibotsivad
saibotsivad / just-11ty.txt
Created September 30, 2020 02:04
eleventy / 11ty with all its dependencies
just-11ty@1.0.0 /Users/saibotsivad/Development/just-11ty
└─┬ @11ty/eleventy@0.11.0
├── @11ty/dependency-tree@1.0.0
├─┬ browser-sync@2.26.12
│ ├─┬ browser-sync-client@2.26.12
│ │ ├── etag@1.8.1 deduped
│ │ ├── fresh@0.5.2 deduped
│ │ ├── mitt@1.2.0
│ │ └─┬ rxjs@5.5.12
│ │ └── symbol-observable@1.0.1
@saibotsivad
saibotsivad / example.js
Created August 13, 2020 17:17
Example attempting to combine two operations into one
async function ({ client, key, now }) => {
try {
await client.put({
TableName: 'my-table',
ConditionExpression: 'PrimaryPartitionKey <> :key',
ExpressionAttributeValues: {
':key': key
},
Item: {
PrimaryPartitionKey: key,
@saibotsivad
saibotsivad / keybase.md
Created April 24, 2020 03:13
keybase.md

Keybase proof

I hereby claim:

  • I am saibotsivad on github.
  • I am saibotsivad (https://keybase.io/saibotsivad) on keybase.
  • I have a public key ASC1MSP2Hj4YKKJhcZc04pfRq2WwcIvpv3nmCJDq_ASYrAo

To claim this, I am signing this object:

@saibotsivad
saibotsivad / _README.md
Last active January 28, 2020 02:02
Possibly Inaccurate AWS Signature V4 Tests

While writing a JavaScript library to generate AWS Signature V4 Requests, I have come across what I believe are inaccuracies in the provided V4 test suite.

This gist documents the AWS signature tests that I believe are inaccurate. If I find my understanding to be inaccurate, or if the tests are corrected by AWS, I will update this gist.

Note: The official test suite is provided by AWS here but I will link to the version I have put on Github here, so that I can better link to specific tests.

@saibotsivad
saibotsivad / index.js
Created October 2, 2019 15:03
generate id in nodejs
const { randomBytes } = require('crypto')
const ID_LENGTH = 64
const escape = string => string
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '')
module.exports = async () => new Promise((resolve, reject) => {