Skip to content

Instantly share code, notes, and snippets.

@AyeGill
AyeGill / scan_git_diff.py
Last active November 11, 2020 15:04
A script to scan a git repo with notes and send a digest mail
#!/usr/bin/env python3
import sys
import re
import urllib.request
import requests
import os
import logging
from bs4 import BeautifulSoup
@AyeGill
AyeGill / sendmail.py
Created October 31, 2020 17:35
Sendmail.py: A simple script that uses mailgun.org to send an email
#!/usr/bin/env python3
import requests
import sys
import os
## Send stdin as an email with first cmdline arg as subject
# could also hardcode thes
@AyeGill
AyeGill / para.jl
Last active August 8, 2020 19:09
Para(Euc) from Backprop as Functor(https://arxiv.org/abs/1711.10455) in Catlab.jl
using Catlab.GAT
using Catlab.Theories
using Flux
struct EucSpc
dim::Int
end
struct ParaEucFun
domdim::Int
@AyeGill
AyeGill / org-roam-rescue.py
Created April 11, 2020 07:35
Fix roam files exported to org
#!/usr/bin/env python
import urllib as ul
import re
import sys
import os.path
#Pandoc turns this: [foo]([[My Foo Page]])
#Into this: [[file:%5B%5BMy%20Foo%20Page%5B%5B][foo]]
#We want this: [[file:My Foo Page.org][foo]]
@AyeGill
AyeGill / graph-workflow.md
Created March 15, 2020 10:55
How to make tikz graphs easily

How to make graphs for tikz easily

Necessary utilities: graphviz, dot2tex, xsel. Install these:

$ sudo apt install graphviz
$ sudo apt install xsel
$ pip3 install dot2tex
@AyeGill
AyeGill / arxiref.py
Last active August 15, 2019 17:46
Python script to pull a bibtex reference from arxiv.
#!/usr/bin/python3
import arxiv
import sys
import PyPDF4
import re
## Usage: arxiref.py 1711.07059
## or: arxiref.py paper.pdf
## If given something that looks like an arXiv id, searches for something with that name
## If given a filename, treats it as a pdf, looks for an arXiv id on page 1, then proceeds as in first case
@AyeGill
AyeGill / HaskellIOIntro.md
Last active August 29, 2015 14:16
Intro to IO, mutation, monads, haskell, oh my!

So, haskell is a "Pure Functional" language, which basically means that functions behave(almost) like mathematical functions, rather than how they behave in other languages. So in most other languages a function can do whatever before it returns, print some text, wipe the root partition, launch nukes against China, whatever. In haskell, that's (almost) not allowed: a function takes an argument, returns an argument, and that's it.

So how do you accomplish anything? Software has to actually do stuff, so how do you interact with anything? To explain that, we need a brief interlude to explain types in haskell. First there are simple types like int, string, so on. Just like a type in C. Then you have parametric types, like List. So you can have a List int, or a List string, and that's a linked list of integers or strings. Lastly, we need to explain parametric types. For example, you might have a function that takes the length of a list. The thing about that function is that it actually doesn't care abou

@AyeGill
AyeGill / Prehaskell
Created February 6, 2014 21:48
Syntax example for haskell-based preprocessor idea.
{{
--Arbitrary haskell code in double curly brackets
--Top-level definitions are available throughout text
emph s = "*" ++ s ++ "*"
}}
This will be rendered raw.
{{
-- String-typed expressions will be printed into the final text wherever they appear
emph "This will be emphasized"
@AyeGill
AyeGill / Constraint.hs
Last active December 31, 2015 12:49
Constraints(but mostly vectors)
{-# LANGUAGE DataKinds, GADTs, StandaloneDeriving, FlexibleInstances, FlexibleContexts #-}
import Data.Foldable hiding (foldl)
import Data.Traversable
import Data.Monoid
import Control.Applicative
-- vector stuff --
data Nat = Z | S Nat
@AyeGill
AyeGill / Ducks.hs
Last active December 30, 2015 16:59
Duck typing in haskell
{-# LANGUAGE TypeOperators
, Arrows
, FlexibleInstances
, DeriveDataTypeable
, StandaloneDeriving
, GeneralizedNewtypeDeriving#-}
import Prelude hiding ((.))
import Data.Dynamic
import qualified Data.Map as M