Skip to content

Instantly share code, notes, and snippets.

View jmdfm's full-sized avatar
💭
😺

John McDowall jmdfm

💭
😺
View GitHub Profile
@jmdfm
jmdfm / tailwindForms.js
Created October 10, 2024 03:32 — forked from srcrip/tailwindForms.js
This is just a copy-and-paste of the Tailwind Forms plugin that you can actually edit/customize/maintain + JSDoc types.
// Tailwind plugin for forms.
// Basically: https://github.com/tailwindlabs/tailwindcss-forms/blob/main/src/index.js
// But with a few changes. And it's easier to maintain this way.
const svgToDataUri = require("mini-svg-data-uri")
const plugin = require("tailwindcss/plugin")
const defaultTheme = require("tailwindcss/defaultTheme")
const colors = require("tailwindcss/colors")
const [baseFontSize, { lineHeight: baseLineHeight }] =
defaultTheme.fontSize.base
const { spacing, borderWidth, borderRadius } = defaultTheme
from transformers import AutoTokenizer, AutoModel
import torch
# MODEL CKPT is downloaded from: "jinaai/jina-embeddings-v2-base-en" # has context len of 8192
MODEL_CKPT = "/Users/rohan/3_Resources/ai_models/jina-embeddings-v2-base-en"
def recursive_splitter(text: str, separators: list[str], chunk_size: int) -> list[str]:
if len(separators) == 0:
words = text.strip().split(' ')
@jmdfm
jmdfm / keymap.json
Created June 6, 2024 23:53 — forked from adibhanna/keymap.json
zed keymaps
[
{
"context": "Editor && VimControl && !VimWaiting && !menu",
"bindings": {
"ctrl-w z": "workspace::ToggleZoom",
"ctrl-w t": "terminal_panel::ToggleFocus",
"g ]": "editor::GoToDiagnostic",
"g [": "editor::GoToPrevDiagnostic",
"g r": "editor::FindAllReferences",
"shift-k": "editor::Hover",
worker | [IMPORTANT]
worker | Don't forget to include the Crash Report log file under
worker | DiagnosticReports directory in bug reports.
worker |
worker | /Users/jmd/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/pg-1.5.6/lib/pg/connection.rb:695: [BUG] Segmentation fault at 0x000000011d800b04
worker | ruby 3.3.1 (2024-04-23 revision c56cd86388) [arm64-darwin23]
worker |
worker | -- Crash Report log information --------------------------------------------
worker | See Crash Report log file in one of the following locations:
worker | * ~/Library/Logs/DiagnosticReports
@jmdfm
jmdfm / lsp.lua
Created February 19, 2024 23:42
Setup TailwindCSS LSP in LazyVim to provide completions in Ruby / Phlex components
-- textDocument/diagnostic support until 0.10.0 is released
_timers = {}
local function setup_diagnostics(client, buffer)
if require("vim.lsp.diagnostic")._enable then
return
end
local diagnostic_handler = function()
local params = vim.lsp.util.make_text_document_params(buffer)
client.request("textDocument/diagnostic", { textDocument = params }, function(err, result)
@jmdfm
jmdfm / cheatsheet.rb
Created February 18, 2024 18:02 — forked from mabenson00/cheatsheet.rb
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
# Required minimum dip version
version: "7.1.1"
environment:
COMPOSE_EXT: development
compose:
files:
- .docker/docker-compose.yml
project_name: vocsurveys
require "json"
Rack::Attack.safelist("allow RSpec") { |_req| Rails.env.test? }
Rack::Attack.safelist("allow development") { |req| Rails.env.development? }
# Allow the other containers on the server unlimited access, tweak IP range for your situation
Rack::Attack.safelist_ip("10.10.0.0/24")
# Limit data modification requests
Rack::Attack.throttle("unsafe/req/ip", limit: 30, period: 60.seconds) do |req|
@jmdfm
jmdfm / aws.tf
Created November 16, 2023 03:34
The Terraform config to setup a managed LB, Firewall, PSQL DB, Redis and droplets on DO, with bonus ECR on AWS.
resource "aws_ecr_repository" "repo" {
name = "${var.product_name}-app"
}
resource "aws_ecr_lifecycle_policy" "ecr-lifecycle-policy" {
repository = aws_ecr_repository.repo.name
policy = jsonencode({
rules = [
{
@jmdfm
jmdfm / run.js
Created November 8, 2023 02:52 — forked from thdxr/run.js
Remove all linkedin connections
// Run on https://www.linkedin.com/mynetwork/invite-connect/connections/
while(true) {
document.querySelector('.mn-connection-card__dropdown-trigger').click()
await new Promise(resolve => setTimeout(resolve, 500))
document.querySelector(".artdeco-dropdown__content-inner button").click()
await new Promise(resolve => setTimeout(resolve, 500))
document.querySelector("[data-test-dialog-primary-btn]").click()
await new Promise(resolve => setTimeout(resolve, 500))
}