Skip to content

Instantly share code, notes, and snippets.

View theY4Kman's full-sized avatar

Zach Kanzler theY4Kman

View GitHub Profile
# XXX######################################################################################
# XXX######################################################################################
import os
import linecache
import sys
import time
from trace import Trace
import sys
import threading
import time
if sys.version_info < (3, 4):
def is_main_thread(thread):
return isinstance(thread, threading._MainThread)
else:
def is_main_thread(thread):
return threading.current_thread() == threading.main_thread()
from typing import Union
def resolve(d: dict) -> dict:
"""Helper which resolves references marked with ref(id)
>>> resolve({'frames': {'0': 'test'}, 'paths': {'0': [ref('0')]}})
{'frames': {'0': 'test'}, 'paths': {'0': ['test']}}
"""
frame_refs = d['frames']
from collections import OrderedDict
from contextlib import contextmanager
@contextmanager
def preserve_dict_order(d: OrderedDict):
"""Allow mutations on an OrderedDict, restoring its original order after
"""
original_order = list(d)
@theY4Kman
theY4Kman / docker-compose.yml
Last active September 23, 2018 21:10 — forked from divideby0/docker-compose.yml
Quick and Dirty ES 6 on Docker Compose
# Instructions
# 1. Download this script into its own directory.
# 2. Install Docker for Mac (https://docs.docker.com/docker-for-mac/install/)
# 3. Run `docker-compose up`
# 4. Kibana will be available at http://localhost:5601
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.0.0
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
const HoverContext = React.createContext({
hovering: null,
hovered: null,
});
@theY4Kman
theY4Kman / neo4j_minesweeper.py
Created July 17, 2018 05:51
Screwing around on Neo4j to implement a graphing Minesweeper solver.
##
# Define observations
observations = {
'v': (1, 'ab'),
'w': (2, 'abc'),
'x': (2, 'bcd'),
'y': (2, 'cde'
'f'
'g'),
@theY4Kman
theY4Kman / convenient-pycharm-templates.md
Created November 8, 2017 03:36
A little write-up on some of the PyCharm Live Templates I use on a daily basis

Convenient PyCharm Live Templates

I find the real beauty of PyCharm to be its code insight. vim seems to be winning on the scripting side of things, but it looks like the JetBrains ecosystem made it economical to build deeply insightful and performant language tooling, enabling ways to navigate, produce, and refactor code – regardless of who wrote it – without waiting for an executable to start, or a plugin to be written, or a maintainer to patch the eighteen bugs affecting only others... in his pro bono, personal-use tool. And one day when JetBrains realizes the selling power of (or I get off my ass and embed) a scripting language for customization, shit's gon' explode.

Till then, PyCharm has a few semi-customizable features which make dev life easier. One of them is Live Templates, which are text templates which can either be expanded by typing an abbreviation and pressing tab; or by selecting some text, pressing Option+Command+T, autocompl

@theY4Kman
theY4Kman / gtd-pycharm-live-templates.xml
Last active January 8, 2025 09:38
These are some PyCharm live templates which expand into some convenient Python statements, made even easier with context-sensitive autocomplete.
<template name="ds" value="$DICT$[['$VAR$'] = $VAR$" description="dict['variable'] = variable" toReformat="false" toShortenFQNames="true">
<variable name="DICT" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="VAR" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="Python" value="true" />
</context>
</template>
<template name="paren" value="$END$($SELECTION$)" description="Function call parentheses" toReformat="false" toShortenFQNames="true">
<context>
<option name="OTHER" value="true" />
import json
from djangorestframework_camel_case.util import camelize, underscoreize
class CamelCaseMixin:
def serialize_data(self, instance):
data = super().serialize_data(instance)
return camelize(data)