Skip to content

Instantly share code, notes, and snippets.

View dangom's full-sized avatar

Daniel Gomez dangom

  • Cambridge, MA
View GitHub Profile
@sankalp-khare
sankalp-khare / switch-gnupg.sh
Created July 3, 2023 11:00
Downgrade / switch gnupg version in homebrew and pin it
#!/bin/bash -e
#-------------------------------------------------------------------------------------
# Summary: Executes commands to...
# * Check/output currently installed version of gnupg
# * Change into the brew repo/install directory
# * Find the git commit-id of the specified version of gnupg
# * git branch/switch to the commit-id
# * replace the brew installed version with the specified version (and pin it)
# * clean up the branch, switch back to master, and remove cached files
# * Check/output the newly installed version of gnupg
@beshrkayali
beshrkayali / poly-pio-mode.el
Created February 19, 2021 20:35
Poly RaspberryPi PIO mode
;; Simple Polymode for RaspberryPi Pico PIO files that uses
;; both asm-mode as host-mode and c-mode for pass-through section
(define-hostmode poly-pio-hostmode
:mode 'asm-mode)
(define-auto-innermode poly-pio-c-innermode
:mode 'c-mode
:head-matcher "^% c-sdk {$"
:tail-matcher "^%}$"
@wtaysom
wtaysom / bel-eve-vr.md
Last active January 24, 2024 03:25
A Review of Paul Graham's Bel, Chris Granger's Eve, and a Silly VR Rant

Hello Friends,

This elf begging to climb onto the web for Christmas began as a personal email, a review of Paul Graham's little Lisp Bel. He sprouted arms, legs, and in gingerstyle ran away. Arms for symbols, legs for conses: these primitives are the mark a Lisp — even more so than the parenthesis. What do we get when we remove these foundation stones: naming and pairing?

No pairs. No cons. No structure. Unordered. Chaos. Eve, a beautifully incomplete aspect oriented triple store. No need for legs when you can effortlessly transport to your destination. Lazy. Pure. Here and now, a retrospective.

No symbols. No names. No variables. Combinators. Forth. No need for arms when you can effortlessly push and pop your stack. No words. A world without words. Virtual worlds. Virtual reality. Space. Time. Motion. Action. Kinetic Programming, a proposal.

I apologize in advance. Checking my pocketwatch, I see I haven't t

@mikhailov-work
mikhailov-work / turbo_colormap.c
Created August 15, 2019 23:04
Turbo Colormap Look-up Table
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Author: Anton Mikhailov
// The look-up tables contains 256 entries. Each entry is a an sRGB triplet.
float turbo_srgb_floats[256][3] = {{0.18995,0.07176,0.23217},{0.19483,0.08339,0.26149},{0.19956,0.09498,0.29024},{0.20415,0.10652,0.31844},{0.20860,0.11802,0.34607},{0.21291,0.12947,0.37314},{0.21708,0.14087,0.39964},{0.22111,0.15223,0.42558},{0.22500,0.16354,0.45096},{0.22875,0.17481,0.47578},{0.23236,0.18603,0.50004},{0.23582,0.19720,0.52373},{0.23915,0.20833,0.54686},{0.24234,0.21941,0.56942},{0.24539,0.23044,0.59142},{0.24830,0.24143,0.61286},{0.25107,0.25237,0.63374},{0.25369,0.26327,0.65406},{0.25618,0.27412,0.67381},{0.25853,0.28492,0.69300},{0.26074,0.29568,0.71162},{0.26280,0.30639,0.72968},{0.26473,0.31706,0.74718},{0.26652,0.32768,0.76412},{0.26816,0.33825,0.78050},{0.26967,0.34878,0.79631},{0.27103,0.35926,0.81156},{0.27226,0.36970,0.82624},{0.27334,0.38008,0.84037},{0.27429,0.39043,0.85393},{0.27509,0.40072,0.86692},{0.2757
@dangom
dangom / mecombine.py
Last active March 10, 2024 03:20
Optimal echo combination accounting for motion correction
""" Echo combination.
1. Motion correction
2. Compute weights on motion corrected data
3. Apply inverse transform on weights
4. Apply weights on original data to minimize interpolation.
Methods:
For the echo combination, the first echo was motion corrected using ANTs for
rigid transformation. The transforms were subsequently applied to the later
echoes. The mean images of the motion corrected echoes were subsequently used
for estimating a T2star map. Weights for each echo were computed from the T2star
@jdahm
jdahm / fill-sentences.el
Last active July 13, 2019 19:20
Complement to fill-paragraph. For LaTeX documents with version tracking, it is best practice to have sentences begin after newlines.
(defun fill-sentences ()
"Fills the current paragraph or region, starting each sentence on a new line."
(interactive)
(save-excursion
;; Determine region to operate on
(let ((beginning-of-region (if (use-region-p) (region-beginning)
(save-excursion (backward-paragraph) (point))))
(end-of-region (if (use-region-p) (region-end)
(save-excursion (forward-paragraph) (point)))))
(goto-char beginning-of-region)
@ipwnponies
ipwnponies / gist:0d00f5d6ce1ee335fafc339a7fc3dca6
Last active December 11, 2018 17:02
Add label to gif using imagemagick

Summary

Imagemagick is hard to use and the documentation/tutorials available are not intuitive. Here is a concise explanation of what needs to be done to edit a gif to add labels.

Code

convert foo.gif \                                                            # Specify the original gif
-gravity center -pointsize 30 -font ComicSans \                              # Set font position and styling
-duplicate 1,0-20 \                                                          # Clone frames and append to the end (clone frame once)
'(' -clone 21-40 -fill white -annotate -0-150 'Hello' -set delay 6 ')' \     # Clone frames, add 'Hello', and slow down gif delay for only these frames
-duplicate 1,41-89 \                                                         # Clone frames and append to the end (clone frame once)
@andyrbell
andyrbell / scanner.sh
Last active July 9, 2024 16:43
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
@pesterhazy
pesterhazy / ripgrep-in-emacs.md
Last active July 19, 2024 16:05
Using ripgrep in Emacs using helm-ag (Spacemacs)

Why

Ripgrep is a fast search tool like grep. It's mostly a drop-in replacement for ag, also know as the Silver Searcher.

helm-ag is a fantastic package for Emacs that allows you to display search results in a buffer. You can also jump to locations of matches. Despite the name, helm-ag works with ripgrep (rg) as well as with ag.

How

@xero
xero / irc.md
Last active July 10, 2024 12:09
irc cheat sheet

IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
  • Leaves the specified channel.