Skip to content

Instantly share code, notes, and snippets.

@AyeGill
AyeGill / view-latex.el
Last active December 21, 2015 11:38
A emacs lisp command that uses pdflatex to compile a pdf version of the active buffer, then view it with evince.
(defun view-latex ()
(interactive)
(if (buffer-modified-p) (save-buffer))
(shell-command (concat "pdflatex " buffer-file-name " >> /dev/null"))
(shell-command (concat "evince " (substring buffer-file-name 0
(- (length buffer-file-name) 4)) ".pdf >> /dev/null")))
;Obviously, replace "pdflatex" and "evince" with your own latex and pdf viewer systems, respectively.
;
@AyeGill
AyeGill / piseconds.tex
Last active June 1, 2016 17:46
Note on a particular approximation of the number of seconds in a year.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[ \pi * 10^7 \approx 365*24*60*60 = 1 yr\footnotemark
\]
\footnotetext{The actual astronomical year is, of course, slightly longer than this, depending on which standard you use. But the deviation is about .25 day, which is well within the margin of error anyways. For more information, you may consult the wikipedia article ``Year''}
More precisely:
@AyeGill
AyeGill / Retail.md
Last active December 29, 2015 23:59
Retail typing idea.

#Retail typing In which I describe an idea I had for a type system. Or something.

##Intro: Duck typing Duck typing (as in, "if it quacks like a duck...") typically refers to a specific sort of dynamic typing common in dynamically typed, object oriented languages. As an example, consider ruby:

def foo(arg)
  arg.bar.baz
end
@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
@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 / 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 / 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 / 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 / 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 / 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]]