Skip to content

Instantly share code, notes, and snippets.

View surenkov's full-sized avatar
💨
I may be slow to respond.

Savva Surenkov surenkov

💨
I may be slow to respond.
View GitHub Profile
@gaearon
gaearon / CurvedArrow.js
Last active October 26, 2021 14:14
Curved SVG arrow between two objects (rects or circles) https://twitter.com/dan_abramov/status/1362255543721672704
// from/to: { left, top, width, height, shape: 'circle' | 'rect' }
function CurvedArrow({ from, to }) {
function curvedHorizontal(x1, y1, x2, y2) {
function pos(t) {
let mx = x1 + (x2 - x1) / 2;
let p1 = {x: x1, y: y1};
let p2 = {x: mx, y: y1};
let p3 = {x: mx, y: y2};
let p4 = {x: x2, y: y2};
return {
@Bahus
Bahus / json_schemed_field.py
Last active February 28, 2025 10:07
Django JSONField with Pydantic schema support
from functools import partial
import pydantic
import logging
from django.contrib.postgres.fields import JSONField
from typing import Type, Union, Tuple
from django.core.serializers.json import DjangoJSONEncoder
@505aaron
505aaron / config.el
Created December 31, 2018 20:40
LSP Doom Emacs Module
;;; completion/lsp/config.el -*- lexical-binding: t; -*-
(def-package! lsp-mode
:commands (lsp-mode lsp-define-stdio-client))
(def-package! lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:config
(set-lookup-handlers! 'lsp-ui-mode
:definition #'lsp-ui-peek-find-definitions
@squarism
squarism / iterm2.md
Last active May 7, 2025 17:18
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@senko
senko / singleton.py
Created February 25, 2013 08:01
Singleton Django Model
# Written by Senko Rasic <[email protected]>
# Released into Public Domain. Use it as you like.
from django.db import models
class SingletonModel(models.Model):
"""Singleton Django Model
Ensures there's always only one entry in the database, and can fix the