Skip to content

Instantly share code, notes, and snippets.

View anjiro's full-sized avatar

Daniel Ashbrook anjiro

View GitHub Profile
@anjiro
anjiro / gist:aa92039c9a40a708a936
Created July 15, 2014 21:42
jQuery.mmenu dynamic content bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script>
<script src="js/jquery.mmenu.min.all.js"></script>
<link rel="stylesheet" href="css/jquery.mmenu.all.css">
@anjiro
anjiro / PythagorasTree.js
Last active August 29, 2015 14:24
Pythagoras tree in OpenJSCAD
//Experiment with rendering L-Systems in OpenJSCAD
// (see https://en.wikipedia.org/wiki/L-system#Example_2:_Pythagoras_tree)
//Production rules
var rules =
{
"1": "11",
"0": "1[0]0",
};
@anjiro
anjiro / trello_json_to_html_outline.py
Last active August 29, 2015 14:26
Quick and dirty conversion of a Trello JSON export to an HTML outline
import json, codecs, mistune
from collections import defaultdict
def trello_json_to_html(jsonfile, outfile):
markdown = mistune.Markdown()
trello = json.load(open(jsonfile))
cards = defaultdict(list)
for card in trello['cards']:
cards[card['idList']].append(card)
@anjiro
anjiro / trello_days_left.js
Last active October 30, 2019 23:10
Trello show days left Greasemonkey script
// ==UserScript==
// @name Trello days left
// @namespace edu.rit.ashbrook.daniel
// @include https://trello.com/*
// @version 1.1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// @description Add the number of days left until an item is due to each applicable card.
// ==/UserScript==
@anjiro
anjiro / basic_vis.html
Created August 25, 2016 19:22
Assignment 1 example
<html>
<head>
<meta charset="utf-8">
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="paperjs-v0.9.23/dist/paper-full.js"></script>
<script type="text/paperscript" canvas="paper">
var $ = window.$;
//Fill in the background
var background = new Shape.Rectangle(view.bounds);
@anjiro
anjiro / papers_to_trello.py
Created March 6, 2017 15:43
Take selected papers from Papers app and put them on a Trello board. Useful for maintaining reading lists.
#!/usr/bin/env python
import Papers
import trello
proxy_strip = 'PROXY_STRIP_HERE' #This prefix will be stripped from the URL that comes from Papers
api_key = 'YOUR_TRELLO_API_KEY_HERE'
token = 'YOUR_TRELLO_TOKEN_HERE'
org_name = 'YOUR_TRELLO_ORG_NAME_HERE' #Or use "me" if you don't have a Trello org
board_name = 'DEFAULT_BOARD_NAME_HERE'
@anjiro
anjiro / eac.py
Created December 17, 2017 02:07
Enhanced autocorrelation
"""Perform enhanced autocorrelation on a wave file.
Based very loosely on https://bitbucket.org/yeisoneng/python-eac
which is based on Audacity's implementation. This version uses
Numpy features to significantly speed up processing."""
from __future__ import division
import numpy as np
from numpy.fft.fftpack import fft, rfft
from scipy.interpolate import interp1d
from scipy.signal import argrelextrema
@anjiro
anjiro / gen_drills.py
Created July 16, 2019 11:05
A script to generate gCode for drilling rectangular arrays of holes on the xCarve CNC mill. Originally developed for drilling in acrylic, going breadth-first to allow cooling in between drill steps.
"""Code to output gCode to drill holes. Drills breadth first to allow
cooling time for e.g. acrylic."""
import numpy as np
from mecode import G
def gen_holes(nx:int, ny:int, spacing:float, x0:float, y0:float,
depth:float, outfile, *, depth_step=1.0, feedrate=150.0,
z_clearance=4.0, start_depth=0.0, view=False):
"""Generate gCode to drill a matrix of holes, going breadth-first
@anjiro
anjiro / Papers3_to_Zotero.py
Created October 4, 2019 13:31 — forked from daeh/Papers3_to_Zotero.py
Script to facilitate the import of a Readcube Papers 3 library into Zotero
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script takes as input a BibTeX library exported from readcube/mekentosj Papers3 and outputs a BibTex library for Zotero to import.
The script preserves your Papers citekeys, adds supplementary files from the Papers3 Library, removes duplicate links to PDFs and removes extraneous *.html and *.webarchive files that are often created by importing articles into Paper from a web browser.
__Instructions for use__:
* Make sure to have Better BibTeX pre-installed to Zotero if you want to preserve the Papers citekeys.
@anjiro
anjiro / zotero_batch.js
Created October 21, 2019 12:38
Batch edit Zotero 5 items
//Make batch changes to selected items in Zotero. Paste this into Tools -> Developer -> Run JavaScript.
async function batch_edit(field, value)
{
var zp = Zotero.getActiveZoteroPane(); //Active Zotero window
var selected = zp.getSelectedItems(); //Get the items that are selected
for(const item of selected)
{
item.setField(field, value);
await item.saveTx();
}