Skip to content

Instantly share code, notes, and snippets.

curve = hv.Curve(range(10)) # Could be any HoloViews object
renderer = hv.renderer('bokeh')
# Using renderer save
renderer.save(curve, 'graph')
printenv | grep -P '(UID.*|SEGMENT.*)' | awk '{print "export",$0}'
import importlib
importlib.reload(my_module)
@robdmc
robdmc / ambition_debug_doit_script.py
Created October 8, 2019 15:22
Script to debug ambition
#! /usr/bin/env python
import os
import sys
import django
sys.path.append('/ambition')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ambition.settings")
django.setup()
from entity.models import Entity
#!/usr/bin/env bash
# Save this to appify on your path and make executable
# Usage: appify my_bash_script.sh "My Name To Click On In Finder"
APPNAME=${2:-$(basename "${1}" '.sh')};
DIR="${APPNAME}.app/Contents/MacOS";
if [ -a "${APPNAME}.app" ]; then
@robdmc
robdmc / jupyter_ipython_autocomplete_fix.py
Created September 18, 2019 16:11
Fix Jupyter autocomplete
%config Completer.use_jedi = False
# From https://github.com/Qix-/better-exceptions
# Install: pip install better_exceptions
# Example usage
from ambition.apps.trigger_management.segment_trackers import TriggerUtilizationTracker
import better_exceptions; better_exceptions.hook()
%load_ext autoreload
%autoreload 2
@robdmc
robdmc / postgres_sql_query_time_batch_batcher.py
Created August 19, 2019 19:00
Postgres SQL time query batcher
class TimeBatcher:
def __init__(self, ending=None, starting=None, num_days=None, num_batches=5):
if ending is None:
ending = datetime.datetime.now()
if {starting, num_days} == {None}:
raise ValueError('You must supply either starting or num_days')
if num_days is not None:
starting = ending - datetime.timedelta(days=num_days)
@robdmc
robdmc / jupyter_notebook_screen_width_cells.css
Last active August 7, 2019 14:59
Make Jupyter Notebooks be full width
/**************************************************/
/**** put this in ~/.jupyter/custom/custom.css ****/
/**************************************************/
/* Make the notebook cells take almost all available width */
.container {
width: 99% !important;
}
/* Prevent the edit cell highlight box from getting clipped;