Skip to content

Instantly share code, notes, and snippets.

@estasney
estasney / env_override.py
Created October 25, 2024 21:19
Wrapped Env Override Decorator
import inspect
import os
from functools import wraps
def env_override(func):
sig = inspect.signature(func)
# Identify parameters with default value None
none_defaults = [
name for name, param in sig.parameters.items()
if param.default is None
@estasney
estasney / mapper.py
Last active October 28, 2024 14:05
Get ORM Attributes to Column Names
# This is useful for when an orm model has a property that references a column that has a different name
class Model():
__table_name__ = "sometable"
legacy_id = Column("id", Integer)
attrs = Model.__mapper__ # or inspect(Model)
{c.key: c.columns[0].key for c in attrs.column_attrs}
# {'legacy_id': 'id'}
@estasney
estasney / variables.groovy
Created December 24, 2023 04:47
JetBrains Live Templates GroovyScript
// Split a comma sep string into an array
groovyScript("def result=_1.split(',').collect { '\"' + it.trim() + '\"' }.findAll { it != '\"\"' }.join(', ');return '[' + result+ ']';", SELECTION)
@estasney
estasney / profiler.py
Created September 7, 2022 21:16
Line Profiler Decorator
import atexit
_PROFILER = None
def get_stats():
global _PROFILER
if _PROFILER is None:
print("No Profiler")
return
This file has been truncated, but you can view the full file.
(()=>{"use strict";var __webpack_modules__={922:module=>{eval('\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\n\nmodule.exports = function (cssWithMappingToString) {\n var list = []; // return the list of modules as css string\n\n list.toString = function toString() {\n return this.map(function (item) {\n var content = "";\n var needLayer = typeof item[5] !== "undefined";\n\n if (item[4]) {\n content += "@supports (".concat(item[4], ") {");\n }\n\n if (item[2]) {\n content += "@media ".concat(item[2], " {");\n }\n\n if (needLayer) {\n content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");\n }\n\n content += cssWithMappingToString(item);\n\n if (needLayer) {\n content += "}";\n }\n\n if (item[2]) {\n content += "}";\n }\n\n if (item[4]) {\n content += "}";\n }\n\n return content;\n }).join("");\n
@estasney
estasney / ButtonRunner.ahk
Created October 1, 2021 17:23
GUI Script Runner
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir C:\path\to\scripts\folder
padX := 10 ; X Padding Between Buttons
padY := 10 ; Y Padding Between Buttons
nCols := 3 ; Number of Columns
btnWidth := 150 ; Width of Buttons
@estasney
estasney / index.html
Last active December 13, 2021 21:51
JSON Tidy Tree
<!doctype html><html><head><meta charset="utf-8"><title>Tidy Tree</title><meta name="viewport" content="width=device-width,initial-scale=1"><script defer="defer" src="tidyTree.1b0427f078801b34e4e5.js"></script></head><body></body></html>
@estasney
estasney / Runner.ahk
Created April 20, 2021 15:03
AutoHotKey Script Runner
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
# Change to folder with .bat scripts
SetWorkingDir C:\path\to\folder
#
FileListMsg :=""
from sqlalchemy import create_engine
from collections import namedtuple
import re
from tqdm.auto import tqdm
Tag = namedtuple('Tag', 'id name count regex')
USERNAME = ''
PASSWORD = ''
URL = 'localhost'
@estasney
estasney / README.md
Created December 6, 2019 14:17 — forked from robschmuecker/README.md
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.