Skip to content

Instantly share code, notes, and snippets.

View anjiro's full-sized avatar

Daniel Ashbrook anjiro

View GitHub Profile
@anjiro
anjiro / bp.yaml
Created October 17, 2022 17:45
Test
blueprint:
name: One-Time Scheduled Toggle
description: Turn something on or off at a scheduled time.
domain: automation
input:
what:
name: Action to do
description: On or off?
selector:
boolean:
@anjiro
anjiro / stridx_vs_match.vim
Created November 6, 2021 18:37
Vim stridx vs match
function RandStr(len)
py3 << EOF
import vim, random
rstr = ''.join([chr(random.randint(65,123)) for i in range(int(vim.eval('a:len')))])
vim.command(f"return '{rstr}'")
EOF
endfunction
function TimeStridx(numiter, candidates)
@anjiro
anjiro / Keynote randomly rotate images.scpt
Created May 4, 2020 11:49
Applescript to randomly rotate images on the current slide
tell application "Keynote"
set curslide to the front document's current slide
repeat with img in the images of curslide
-- iWork rotation is, irritatingly, an integer
set the rotation of img to random number from -5 to 5
end repeat
end tell
@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();
}
@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 / 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 / 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 / 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 / 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 / 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==