Skip to content

Instantly share code, notes, and snippets.

View asher-pembroke's full-sized avatar

Asher Pembroke asher-pembroke

View GitHub Profile
@asher-pembroke
asher-pembroke / partial.py
Last active March 12, 2025 08:35
A partial function decorator that doesn't suck (python3.7)
# pip install decorator
# pip install python-forge
from decorator import decorator, decorate
import forge
import inspect
def decorator_wrapper(f, *args, **kwargs):
"""Wrapper needed by decorator.decorate to pass through args, kwargs"""
return f(*args, **kwargs)
@asher-pembroke
asher-pembroke / blocks.py
Created April 11, 2021 02:01
pixel puzzler/conway game of life/plotly dash demo
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
import dash_daq as daq
# from plotly.offline import iplot
import dash_extendable_graph as deg
import plotly.graph_objs as go
@asher-pembroke
asher-pembroke / gist:01a8dc2844f6a7738ebddf2da18f18fc
Last active September 26, 2017 15:03
Merge two named tuples in python
def merge_tuples(a,b, name = 'Name'):
"""Returns a join of two named tuples
Duplicate names will raise an error.
"""
return namedtuple(name, a._fields + b._fields)(*(a+b))
from pint import quantity

import numpy as np

import pint
ureg = pint.UnitRegistry()

#shape of the galaxy
diameter = 1e5 * ureg.lightyear