Skip to content

Instantly share code, notes, and snippets.

@aggerdom
aggerdom / interface-changing.clj
Last active November 1, 2019 06:11
Various helpers for clojure
(defn monoid
"Takes identity element and two argument function, returns function implementing monoid pattern.
A monoid is a mathematical structure with an identity element and an associative binary operator.
NOTE: Associativity is required (but not enforced) for `pmonoid` the parallel version of this"
[id fn-2]
(fn g
([] id)
([x] x)
([x y] (fn-2 x y))
([x y & more]
@aggerdom
aggerdom / relations.py
Created December 23, 2018 22:39
Working Through Mathematical Structures For Computer Science
import itertools as it
from functools import singledispatch
from typing import List, FunctionType
"""
While I am working through "Mathematical Structures for Computer Science" by Judith L. Gersting, I find it useful to
translate the ideas into code. I do not make any guarantees about the code contained here, and this will likely be abandoned.
"""
@aggerdom
aggerdom / Intro.md
Last active July 9, 2016 01:54
Getting started writing nikola shortcodes

Today I was working a little on adding shortcodes to Nikola to create columns in Markdown. So I'm just writing up what I've figured out so far.

Step 1: Create a shortcodes folder

From the root folder of your site:

$ mkdir shortcodes

Step 2: Create a shortcode tmpl file

@aggerdom
aggerdom / getfunctionhandle.matlab
Created June 11, 2016 18:39
Matlab function to get function handle from a file not on the path
function output_handle = getfunctionhandle(varargin)
%% GETFUNCTIONHANDLE Arguments: function_location, function_name
%{
% Function to be used to get handles for functions that arent in the present location
% pr in the path. The function may be called 2 different was ways.
% ===========================================================================
% WAY 1: Specify the full path to the function you want.
% desired_function_name = getfunctionhandle(function_location)
% ===========================================================================
% Example:
@aggerdom
aggerdom / ticker.py
Created April 9, 2016 02:06
Cli Ticker (Work in progress)
from plumbum.cli.terminal import get_terminal_size
from time import sleep
class Ticker(object):
"""Cli ticker"""
def __init__(self, loop=True,sep=' <> ',statements=None):
self.width = None
self.height = None
self.sep = sep
self.update_terminal_size()
@aggerdom
aggerdom / flatten.py
Created March 10, 2016 01:01
Flatten nested lists of integers
def flat_list(array):
o = []
while array:
n = array.pop(0)
if type(n)==int:
o.append(n)
else:
for i in n[::-1]:
array.insert(0,i)
return o
@aggerdom
aggerdom / pdfprocessing.py
Created February 28, 2016 02:35
Pdf Pipeline (work in progress)
# mapIt.py - Launches a map in the browser using an address from the
# command line or clipboard.
import webbrowser, sys, pyperclip, os, Tkinter
import tkFileDialog
import pywinauto
import subprocess
from time import sleep
import ahk
import win32con
import tkinter as tk
from tkinter import messagebox
from PIL import ImageTk, Image
def make_tk_image(imagepath):
"""
Opens and reads in an image to display in tk widgets. Using for example
img=make_tk_image(imagepath)
label=tk.Label(foo,img=image)
@aggerdom
aggerdom / 0_reuse_code.js
Created January 26, 2016 05:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aggerdom
aggerdom / runfirefoxsession.py
Created January 22, 2016 22:27
Log in to facebook using selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Firefox()
def get_page_title(url):
driver.get(url)
return driver.title
def get_email(prompt="email: "):