Skip to content

Instantly share code, notes, and snippets.


Ian Beck onecrayon

View GitHub Profile
onecrayon / Pipfile
Last active Dec 30, 2020
async/await FastAPI with SQLAlchemy test
View Pipfile
name = "pypi"
url = ""
verify_ssl = true
pylint = "*"
sqlalchemy = "*"
onecrayon / ContentPostPage.vue
Last active Nov 30, 2020
Pages with next/prev links in Gridsome 0.6.x
View ContentPostPage.vue
<!-- Here there be markup... -->
query Chapter ($id: String, $prevId: String, $nextId: String) {
post: contentPost (id: $id) {
View zendesk_autopopulate_fields.js
* Automatically populates Zendesk public-facing "new ticket" fields
* on page load.
* To use, copy and paste into your New Request Page template (wrapped
* in a `<script></script>` tag).
* For most fields, just use the field name (so if the field is
* `request[subject]`, use `subject` in the URL, while
* `request[custom_fields][123456]` becomes `123456`). You can also use
onecrayon /
Created Dec 13, 2016
Custom MappedCollection example for SQLAlchemy returning a dict of lists
from sqlalchemy import Model, Column, Integer, ForeignKey, String, Text
from orm_helpers import KeyedListCollection
class ItemAttribute(Model):
__tablename__ = 'item_attributes'
id = Column(Integer, primary_key=True, autoincrement=True)
item_id = Column(Integer, ForeignKey(''))
attribute = Column(String(255))
value = Column(Text)
onecrayon /
Last active Dec 21, 2019
Use git installed in Windows Subsystem for Linux in Visual Studio Code

Proxy commands from Windows command line to Bash using the Windows Subsystem for Linux (WSL)

These scripts allow you to proxy commands (specifically git, in this example) to the Windows Subsystem for Linux from the normal Windows command line environment. This allows you to work with a single installation of git (under your Linux distribution) instead of trying to manage two concurrent installations.

I explicitly created these scripts to allow using Git in Visual Studio Code without installing it under Windows.

Please note that I have not extensively tested edge cases! If you run into problems, please let me know!

Using WSL git in Visual Studio Code

onecrayon /
Created Oct 4, 2016
Bash script for automatically creating a bare git repo in Dropbox (for tracking pre-existing private repo)
# This script adds a new git repo to Dropbox (named after the current working
# directory), adds it as a remote, and pushes everything to it. If there is an
# argument, then that will be used as the name of the repo instead of the
# current working directory.
# $ cd existing-repo
# $ /path/to/
View flattenArray.js
* flattenArray(nestedArray)
* Accepts an array of values and arrays and returns
* a single array of values.
* Usage:
* var nested = [[1, 2, [3]], 4];
* var flat = flattenArray(nested);
onecrayon / Languages.xml
Created Aug 1, 2013
Basic code necessary for a LESS/SASS shim Sugar for MacRabbit's Espresso
View Languages.xml
<?xml version="1.0" encoding="UTF-8"?>
<language id="com.onecrayon.less-sass-standin">
<name>LESS/SASS (shim)</name>
onecrayon / Postbox.plist
Created Jul 6, 2012
Postbox-style keybindings for MailMate (save in ~/Library/Application Support/MailMate/Resources/KeyBindings)
View Postbox.plist
// Keybindings to emulate Postbox defaults in MailMate
// From:
// Created by Ian Beck <>
"f" = "nextMessage:";
"b" = "previousMessage:";
"n" = "nextUnreadMessage:";
"p" = "previousUnreadMessage:";
"T" = "nextUnreadThread:";
onecrayon /
Created Jul 4, 2012
Sorts Markdown-formatted tweets monthly files; see for info
# -*- coding: utf-8 -*-
This script parses a text file of tweets (generated by [IFTTT][1],
for instance) and sorts them into files by month. You can run it
manually from the command line:
cd /path/to/containing/folder
./ /path/to/@username.txt