Skip to content

Instantly share code, notes, and snippets.

View jdreaver's full-sized avatar

David Reaver jdreaver

View GitHub Profile
@tacaswell
tacaswell / simp_zoom.py
Last active February 12, 2023 07:19
factory for adding zoom callback to matplotlib graphs
import matplotlib.pyplot as plt
def zoom_factory(ax,base_scale = 2.):
def zoom_fun(event):
# get the current x and y limits
cur_xlim = ax.get_xlim()
cur_ylim = ax.get_ylim()
# set the range
cur_xrange = (cur_xlim[1] - cur_xlim[0])*.5
@theanalyst
theanalyst / pushbullet.el
Last active January 28, 2019 01:20
Easily push from your emacs to Android phone??
;;; pushbullet.el --- An emacs client for the pushbullet android app
;;; Using the pushbullet api at https://pushbullet.com/api
;;; Uses grapnel for http requests https://github.com/leathekd/grapnel
;;;
;;; Commentary:
;;;
;;; Code:
(require 'grapnel)
(require 'json)
@jaredks
jaredks / listdict_setitem_subclass.py
Last active May 23, 2019 06:42
OrderedDict subclass implementing insertion methods to adjust the order.
from collections import OrderedDict as _OrderedDict
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
class ListDict(_OrderedDict):
def __init__(self, *args, **kwds):
try:
@i-e-b
i-e-b / Readme_NIX_OS.md
Last active July 4, 2023 16:53
/etc/nixos/configuration.nix

My experiments with an XMonad setup in NixOS. This is my work box now, so it pretty much works.

probably needs:

# useradd -m iain
# passwd iain ...
# passwd root ...
@Fristi
Fristi / Aggregate.hs
Last active November 6, 2022 20:50
DDD/Event Sourcing in Haskell. Implemented an aggregate as a type class and type families to couple event, command and error types specific to the aggregate. Errors are returned by using Either (Error e) (Event e). Applying Applicative Functors fits here well to sequentially check if the command suffice.
{-# LANGUAGE TypeFamilies #-}
import Data.Function (on)
import Control.Applicative
data EventData e = EventData {
eventId :: Int,
body :: Event e
}
@jaceklaskowski
jaceklaskowski / Rough Notes about CQRS and ES.md
Last active June 13, 2024 02:32
Rough Notes about CQRS and ES

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.

@zr40
zr40 / blocking.sql
Last active September 29, 2017 17:25
Show blocking locks
select
object,
case "lock requested"
when 'AccessExclusiveLock' then 'access exclusive'
when 'ExclusiveLock' then 'exclusive'
when 'ShareRowExclusiveLock' then 'share row exclusive'
when 'ShareLock' then 'share'
when 'ShareUpdateExclusiveLock' then 'share update exclusive'
when 'RowExclusiveLock' then 'row exclusive'
when 'RowShareLock' then 'row share'
@sydcanem
sydcanem / Nginx gzip.conf
Last active March 3, 2024 18:27
Gzip configuration for Nginx
#Enable Gzip compressed.
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
@jdnavarro
jdnavarro / PKGBUILD
Last active February 13, 2017 17:08
Updated libtinfo AUR PKGBUILD for ncurses-6
# Maintainer: Alexej Magura <agm2819*gmail*>
#
#
pkgname=libtinfo
pkgver=5
pkgrel=7
pkgdesc="symlink to ncurses for use in cuda and other packages"
arch=('any')
url="http://www.gnu.org/software/ncurses/"
license=('unknown')
@proger
proger / stack2.nix
Last active January 13, 2017 23:29
stack2nix
{ pkgs ? import (builtins.fetchTarball https://github.com/nixos/nixpkgs-channels/archive/nixos-unstable.tar.gz) {} }:
let
yaml = ./stack.yaml;
cabal2nix = "${pkgs.cabal2nix}/bin/cabal2nix --no-check --no-haddock";
in
pkgs.writeScript "build.sh" ''
export NIX_PATH=nixpkgs=${pkgs.path}
resolver=$(awk '/resolver:/{print $2}' ${yaml} | sed 's,\.,_,g')