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.
From the root folder of your site:
$ mkdir shortcodes
(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] |
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. | |
""" |
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: |
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() |
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 |
# 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) |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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: "): |