Skip to content

Instantly share code, notes, and snippets.

Avatar

John Woodell woodie

View GitHub Profile
@woodie
woodie / midi_keypad.md
Last active Jun 8, 2021
A little program to capture input from a keypad and change programs on the midi device.
View midi_keypad.md
@woodie
woodie / prompt.bash
Created May 16, 2021
The git status prompt I've been using for years
View prompt.bash
# username@ ~/workspace/repo (branch)
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\] \[\033[33;1m\]\w\[\033[m\] (\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)) \$ "
View add_new_issues.yml
name: Add new issues to project board
on:
issues:
types: [opened]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
View set-new-issues.yml
name: Set new issues with Monday details
on:
issues:
types: [opened]
jobs:
set-new-issues-with-monday-details:
runs-on: ubuntu-latest
steps:
View install_p4_on_ubuntu.bash
#!/bin/bash
# Keep this associative array up-to-date based on perforce packages
declare -A releases=( ["12.04"]="precise" ["14.04"]="trusty" ["16.04"]="xenial")
# https://www.perforce.com/perforce/doc.current/manuals/p4sag/chapter.install.html#install.linux.packages
os_name=`grep ^NAME= /etc/os-release | cut -c6- | tr -d '"'`
if [[ $os_name != "Ubuntu" ]] ; then
echo 'Sorry, only for Ubuntu.'
exit 1
@woodie
woodie / iis_mail.rb
Last active Dec 15, 2016
Local mail delivery on Windows Server using IIS SMTP Service
View iis_mail.rb
# config/environments/production.rb
# Local mail delivery using IIS SMTP Service
require 'shim/mail_message' # fix line endings
config.action_mailer.delivery_method = :file
config.action_mailer.file_settings = { location: "#{ENV['SystemDrive']}/InetPub/MailRoot/Pickup" }
# lib/shim/mail_message.rb
# Patch Mail::Message to enforce proper line-endings for Windows IIS file-type delivery.
module Mail
class Message
View hello.ts
#!/usr/bin/env typescript
class Greeter {
name: string;
constructor(name?: string) {
this.name = name || 'Nobody';
}
say_hello() {
console.log("Hello " + this.name);
@woodie
woodie / usr_local_bin_typescript
Last active Dec 27, 2015
I use this wrapper to run TypeScript files on-the-fly.
View usr_local_bin_typescript
#!/usr/bin/env bash
TSFILE=${@##*/}
JSFILE=${TSFILE/%ts/js}
MD5DIR=`md5 -q ${@}`/
if [ ! -d $TMPDIR$MD5DIR ]; then
mkdir $TMPDIR$MD5DIR
fi
if [ ! -f $TMPDIR$MD5DIR$JSFILE ] || [ ${@} -nt $TMPDIR$MD5DIR$JSFILE ]; then
tsc --outDir $TMPDIR$MD5DIR ${@}
fi
View gist:2c86aa9d4d2b6d9be43a
class SomeStatsModel < ActiveRecord::Base
establish_connection "that_other_stats_db_#{Rails.env}".to_sym
TABLE_NAME = 'some_oddly_named_stats_table'
self.table_name = "some_default_schema.#{TABLE_NAME}"
def self.sum_select(*args)
self.select(*args.map {|s| "SUM(#{s}) AS #{s}"}.join(', '))
end
def self.for(account_specific_schema)
View FixedQueue.java
// A Queue of fixed size, using an array for storage
package cis;
public class FixedQueue {
private int added = 0;
private int removed = 0;
private int capacity;
private Object[] data;