Skip to content

Instantly share code, notes, and snippets.

View dangom's full-sized avatar

Daniel Gomez dangom

  • Cambridge, MA
View GitHub Profile
@dangom
dangom / scanner.sh
Created April 19, 2022 15:26 — forked from andyrbell/scanner.sh
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@dangom
dangom / discrete_cmap.py
Created July 31, 2018 14:57 — forked from jakevdp/discrete_cmap.py
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
@dangom
dangom / jq-insert-var.sh
Created April 13, 2018 15:47 — forked from joar/jq-insert-var.sh
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{
@dangom
dangom / getFirafonts.sh
Created February 26, 2018 19:45 — forked from muammar/getFirafonts.sh
Download and install Fira fonts in Linux or Mac OS X
#!/bin/bash
## cf from http://programster.blogspot.com/2014/05/ubuntu-14-desktop-install-fira-sans-and.html
cd /tmp
# install unzip just in case the user doesn't already have it.
if [[ `uname` = Linux ]]; then
sudo apt-get install unzip -y
wget "http://www.carrois.com/downloads/fira_4_1/FiraFonts4106.zip"
@dangom
dangom / partial_corr.py
Created November 22, 2017 13:57 — forked from fabianp/partial_corr.py
Partial Correlation in Python (clone of Matlab's partialcorr)
"""
Partial Correlation in Python (clone of Matlab's partialcorr)
This uses the linear regression approach to compute the partial
correlation (might be slow for a huge number of variables). The
algorithm is detailed here:
http://en.wikipedia.org/wiki/Partial_correlation#Using_linear_regression
Taking X and Y two variables of interest and Z the matrix with all the variable minus {X, Y},
#! /usr/bin/python
#
# Author: Gaute Hope (gaute.hope@nersc.no) / 2015
#
# based on example from matlab sinc function and
# interpolate.m by H. Hobæk (1994).
#
# this implementation is similar to the matlab sinc-example, but
# calculates the values sequentially and not as a single matrix
# matrix operation for all the values.
@dangom
dangom / ob-skewer.el
Created May 18, 2016 14:25 — forked from zot/ob-skewer.el
Small hack to let orgmode babel JS blocks use skewer if it's currently connected
;; modify ob-js to redirect to skewer if it is currently connected
;; this code can go in an emacs settings file
(require 'ob-js)
(require 'cl)
(advice-add 'org-babel-execute:js :around 'bill/org-babel-execute:skewer)
;;(advice-remove 'org-babel-execute:js #'bill/org-babel-execute:skewer)
(defun bill/org-babel-execute:skewer (oldFunc body params)
(if (skewer-ping)
(lexical-let* ((result-type (cdr (assoc :result-type params)))