Skip to content

Instantly share code, notes, and snippets.

View lukesmurray's full-sized avatar
😎
Hard at work

Luke Murray lukesmurray

😎
Hard at work
View GitHub Profile
@lukesmurray
lukesmurray / sa.py
Created March 10, 2022 02:44
sql server compiles temporal clauses
# render `period for system_time` clause for mssql temporal tables
# example (specifically pay attention to the info argument passed to sys_end_time)
# the render_period has to reference the column names used to track the system start and end time
# class Card(Base):
# sys_start_time = Column(
# DATETIME2,
# Computed(text("ROW START HIDDEN")),
# nullable=False,
# info={"is_temporal": True},
# )
@lukesmurray
lukesmurray / rv-ro.tsx
Created March 8, 2022 12:58
react virtual with resize observers
import { useEffect, useMemo, useRef } from "react";
import { Options, useVirtual as useVirtualImpl } from "react-virtual";
// implementation of useVirtual that handles resizes after the element renders
// from https://codesandbox.io/s/usevirtualresizeobserver-04-11-2021-75ye2?file=/src/useVirtual.tsx
// found from this issue https://github.com/TanStack/react-virtual/issues/28
// which linked to this comment https://github.com/TanStack/react-virtual/discussions/212#discussioncomment-1587478
const defaultKeyExtractor = (index: number) => index;
@lukesmurray
lukesmurray / animation.js
Created January 8, 2022 16:32
background website animation
import paper from "paper";
import RBush from "rbush";
import knn from "rbush-knn";
// settings
// limit at which points are connected
// limit at which things are viewed by the mouse
/**
* radius in which dots are considered nearby
@lukesmurray
lukesmurray / example_usage.py
Last active October 8, 2021 21:25
strawberry_sqlalchemy updates
from __future__ import annotations
import typing as t
import strawberry
from sqlmodel import Field, Relationship, SQLModel
from .filter_generators import create_array_relationship_type, create_query_root
import typing as t
import pydantic
import strawberry
class UserModel(pydantic.BaseModel):
age: int
password: t.Optional[str]
@lukesmurray
lukesmurray / vim-settings.json
Created September 29, 2021 14:49
vim settings for vscode
"vim.normalModeKeyBindingsNonRecursive": [
// use ctrl-hjkl to navigate splits instead of (ctrl+w + h)
{
"after": ["<C-w>", "h"],
"before": ["<C-h>"]
},
{
"after": ["<C-w>", "j"],
"before": ["<C-j>"]
},
@lukesmurray
lukesmurray / Research Paper Prompt.md
Last active August 7, 2021 22:15
Prompts for evaluating ideas before starting a research project

Prompts

Fill these out when you start a project. Copy the file every week or two and modify your answers as you learn more and your idea becomes clearer.

  • 💡 Key Idea: one clear sharp idea, a reusable insight, useful to the reader
  • What is the problem?
  • Why is the problem interesting?
  • Why isn't the problem solved?
  • What is our idea?
This file has been truncated, but you can view the full file.
the 23135851162
of 13151942776
and 12997637966
to 12136980858
a 9081174698
in 8469404971
for 5933321709
is 4705743816
on 3750423199
that 3400031103
@lukesmurray
lukesmurray / setup.sh
Created February 18, 2021 02:32
Setup Conventional Commits
#!/bin/bash
# install commitizen, standard-version, husky, and commitilnt
yarn add -D commitizen standard-version husky @commitlint/{config-conventional,cli}
# initialize commitizen
./node_modules/.bin/commitizen init cz-conventional-changelog --yarn --save-dev --save-exact --force
# install husky
yarn husky install
# prepare commit msg with commitizen
yarn husky add .husky/prepare-commit-msg "exec < /dev/tty && git cz --hook || true"