Skip to content

Instantly share code, notes, and snippets.

View datashaman's full-sized avatar

datashaman datashaman

  • datashaman
  • Cape Town, South Africa
View GitHub Profile
@datashaman
datashaman / README.md
Last active January 3, 2016 20:29
Cumulative object for filters

Cumulative object, useful for creating filters. It's closest to a Reader / Environment monad.

Every time you call it with arguments, it merges them into a running context, which it uses to create the next filter which is returned. You can create graphs of filters, deriving from a common point.

If the argument is callable, call it to get the new properties to merge. This allows you to dynamically create the properties on the fly.

When you want to get the current context, call the filter without arguments, which is a signal for the filter to return the internal context object.

This means you can easily merge two filters together, since filters are callable and produce their context if called without arguments.

Horizontal Stacked Bar Chart

Treat it exactly the same as a normal stacked bar chart, except invert the x and y values before stacking, and then invert them back afterwards.

@datashaman
datashaman / designer.html
Created October 23, 2014 04:39
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@datashaman
datashaman / README.md
Last active August 29, 2015 14:08 — forked from mbostock/.block

Basic grouped bar chart with one series, and two values: Planning and Implementation

##teamcity[progressStart 'Build']
XBuild Engine Version 12.0
Mono, Version 3.2.8.0
Copyright (C) 2005-2013 Various Mono authors
Build started 2016-01-20 07:41:38 AM.
__________________________________________________
/home/username/Projects/sonarr/src/NzbDrone.sln: warning : Don't know how to handle GlobalSection ExtensibilityGlobals, Ignoring.
/home/username/Projects/sonarr/src/NzbDrone.sln: warning : Don't know how to handle GlobalSection JSLint, Ignoring.
Project "/home/username/Projects/sonarr/src/NzbDrone.sln" (Clean target(s)):
@datashaman
datashaman / resilientsession.py
Last active March 11, 2022 21:11
Decorator version of resilientsession
from requests import Session
from requests.exceptions import ConnectionError
import logging
import time
def is_recoverable(error, url, request, counter=1):
if hasattr(error,'status_code'):
if error.status_code in [502, 503, 504]:
error = "HTTP %s" % error.status_code
@datashaman
datashaman / resilientsession.py
Last active November 9, 2023 01:05
More succinct resilient session
from requests import Session
import time
class ResilientSession(Session):
"""
This class is supposed to retry requests that return temporary errors.
At this moment it supports: 502, 503, 504
"""
@datashaman
datashaman / index.html
Last active April 18, 2016 10:28
getScript example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>getScript example</title>
</head>
<body>
<div id="panel"></div>
<script src="http://code.jquery.com/jquery-2.2.3.min.js"></script>
@datashaman
datashaman / transcode
Last active May 26, 2018 18:07
Convert audio to 320kbps CBR .mp3, convert video to x264 .mp4
#!/usr/bin/env bash
#
# Usage:
# transcode filename [filename...]
#
# File type is determined using:
#
# file --mime-type filename
#
# Audio files:

Keybase proof

I hereby claim:

  • I am datashaman on github.
  • I am datashaman (https://keybase.io/datashaman) on keybase.
  • I have a public key ASDNNIhV6WzvFIQH-gGySuk9DwIWdT4bpZXu4kpuzsHaogo

To claim this, I am signing this object: