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",
@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
@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))
}
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@jmdfm
jmdfm / init.vim
Created April 19, 2020 20:23 — forked from benawad/init.vim
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@jmdfm
jmdfm / gist:2d949a9863f83260a1a977efda148d05
Created July 18, 2019 22:05 — forked from bessarabov/gist:674ea13c77fc8128f24b5e3f53b7f094
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@jmdfm
jmdfm / obfuscate.php
Created June 2, 2019 20:13 — forked from levelsio/obfuscate.php
WordPress plugin to progressively obfuscate text like MAKEbook.io
/*
--PIETZ OBFUSCATE CODE--
2019-06-01
from MAKEbook.io
Instructions:
1) put this in your functions.php file
2) add this to the post you want to obfuscate, on top
3) [obfuscate]
4) to start obfuscating, add a HTML code or HTML block with <start></start>
@jmdfm
jmdfm / html-editors.md
Created April 3, 2019 03:14 — forked from manigandham/rich-text-html-editors.md
Rich text / HTML editors and frameworks

Strictly Frameworks

Abstracted Editors

These use separate document structures instead of HTML, some are more modular libraries than full editors

  • ProseMirror - http://prosemirror.net - supports collaborative editing, offers similar options to Mobiledoc for data structure