Skip to content

Instantly share code, notes, and snippets.

View lispandfound's full-sized avatar
🕶️
Vibing

Jake Faulkner lispandfound

🕶️
Vibing
  • QuakeCoRE
  • Christchurch, New Zealand
  • 15:26 (UTC +13:00)
View GitHub Profile
from pathlib import Path
import numpy as np
import pandas as pd
from empirical.util import openquake_wrapper_vectorized as openquake
from empirical.util import z_model_calculations
from empirical.util.classdef import GMM, TectType
from matplotlib import pyplot as plt
import numexpr as ne
from qcore import coordinates
@lispandfound
lispandfound / treesit-expand-region.el
Last active July 7, 2024 23:56
Expand region treesitter integration
(defun treesit-mark-bigger-node ()
(interactive)
(let* ((node (treesit-node-on (region-beginning) (region-end))))
(let ((next-node (treesit-parent-until node (lambda (n)
(not (and
(= (region-beginning) (treesit-node-start n))
(= (region-end) (treesit-node-end n))))))))
(set-mark (treesit-node-end next-node))
(goto-char (treesit-node-start next-node)))))
;; Invoke via M-x doc-view-transient
(transient-define-prefix doc-view-transient ()
"Transient for doc-view mode."
[:class transient-columns ;; the class sets how the transient is displayed; we have each category as a column.
["Zoom"
("+" "Enlarge" doc-view-enlarge :transient t) ;; :transient commands keep the transient prompt open
("-" "Shrink" doc-view-shrink :transient t)
("w" "Fit window to page" doc-view-fit-window-to-page :transient t)
("W" "Fit width to window" doc-view-fit-width-to-window :transient t)]
["Navigation"
@lispandfound
lispandfound / .stumpwmrc
Last active June 19, 2022 21:51
stumpwm config
;; -*- mode: Lisp -*-
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(in-package :stumpwm)
(require 'swank)
LoadPackage("fining");
e := 3;
q := 2 ^ e;
aut := 2^((e + 1) / 2);
pg := PG(2, q^2);
F := GF(q);
Ex := GF(q^2);
w := Z(q^2);
@lispandfound
lispandfound / model.py
Created May 5, 2021 08:51
Bengio et al model.
from collections import Counter
import tensorflow as tf
import tensorflow.keras as keras
import tensorflow.keras.layers as layers
from nltk import word_tokenize
class BengioModel(keras.Model):
''' Model that replicates the architecture of Bengio et al. '''
@lispandfound
lispandfound / ulam.hs
Created December 17, 2019 08:53
Ulam Spiral Code
module Lib
where
import Graphics.Gloss
density :: Float
density = 0.1
spiral :: [Float] -> [(Float, Float)]
spiral pts = map f pts
from enum import Enum, auto
class HeadMove(Enum):
LEFT = -1
RIGHT = 1
NOTHING = 0
class TuringMachine:
program := 0;
i := 0;
read program;
read i;
j := i;
l := 0;
data := 0;
while j >= 0 do
pow := 1;
k := 0;
@lispandfound
lispandfound / sort_of.py
Created March 29, 2019 23:53
sort_of in linear time
#!/usr/bin/env python
def sort_of(numbers):
""" Old bad code.
Computes the minimum element of each sublist from i..n where n is the length of the list. """
result = []
for i in range(len(numbers)):
sub = sorted(numbers[i:])