Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
Trying to figure out how to look up comments I've left

Pat Maddox patmaddox

🤔
Trying to figure out how to look up comments I've left
View GitHub Profile
View or_else_what.rb
class Object
def or_else
self
end
end
class NilClass
def or_else
yield
end
@patmaddox
patmaddox / Dockerfile
Created Jan 12, 2017
Using personal SSH keys on docker container (OS X)
View Dockerfile
RUN mkdir ~/.ssh
RUN echo 'IdentityFile ~/.ssh-local/id_rsa' > ~/.ssh/config
@patmaddox
patmaddox / 1_use-toggle.js
Last active Apr 2, 2020
toggles and hooks
View 1_use-toggle.js
import { useState, useCallback } from 'react';
export default function useToggle(initialState) {
const [isOn, setIsOn] = useState(initialState);
const turnOn = useCallback(() => setIsOn(true), [setIsOn]);
const turnOff = useCallback(() => setIsOn(false), [setIsOn]);
const toggle = useCallback(() => setIsOn(prevState => !prevState), [setIsOn]);
return { isOn, turnOn, turnOff, toggle, setIsOn };
}
View 01_original.rb
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end
@patmaddox
patmaddox / fluid_srp.rb
Created Sep 18, 2019
SOLID in Ruby is fluid
View fluid_srp.rb
class Foo1
def foo
puts "hello foo"
end
end
module FooModule
def foo
puts "hello foo"
end
@patmaddox
patmaddox / _README.md
Last active Apr 7, 2019
dorico custom instrument groups
View _README.md

To add custom instruments, you need to modify some XML files under /Applications/Dorico 2.app/Contents/Resources. Only do this if you're comfortable doing something like that!

I have included the complete file contents here so you can just replace the existing files on disk. You will overwrite the following files in the Resources folder:

This configuration will create a new "Parts" instrument group at the top of the list. It provides three instruments:

@patmaddox
patmaddox / 01_README.md
Created Apr 7, 2019
dorico custom instruments
View 01_README.md

To add custom instruments, you need to modify some XML files under /Applications/Dorico 2.app/Contents/Resources. Only do this if you're comfortable doing something like that!

For instruments.xml and instrumentnames_en.xml, you will add new entries. I placed them after the Pianoforte entry.

If your computer isn't set to English, choose the correct localization file for your system.

For instrumentFamiliesDefinitions.xml you will replace the existing keyboards entry (essentially you add instrument.keyboard.piano.alias.part to the <instrumentDefinitionIDs> element for Keyboards.

View highlight.css
.markdown-preview:not([data-use-github-style]) { padding: 2em; font-size: 1.2em; color: rgb(171, 178, 191); background-color: rgb(40, 44, 52); overflow: auto; }
.markdown-preview:not([data-use-github-style]) > :first-child { margin-top: 0px; }
.markdown-preview:not([data-use-github-style]) h1, .markdown-preview:not([data-use-github-style]) h2, .markdown-preview:not([data-use-github-style]) h3, .markdown-preview:not([data-use-github-style]) h4, .markdown-preview:not([data-use-github-style]) h5, .markdown-preview:not([data-use-github-style]) h6 { line-height: 1.2; margin-top: 1.5em; margin-bottom: 0.5em; color: rgb(255, 255, 255); }
.markdown-preview:not([data-use-github-style]) h1 { font-size: 2.4em; font-weight: 300; }
.markdown-preview:not([data-use-github-style]) h2 { font-size: 1.8em; font-weight: 400; }
.markdown-preview:not([data-use-github-style]) h3 { font-size: 1.5em; font-weight: 500; }
.markdown-preview:not([data-use-github-style]) h4 { font-size: 1.2em; font-weight: 600; }
.markdown-preview:not([da
View foobarbaz.rb
module Foo
def baz
"I am from foo!"
end
end
module Bar
def baz
"I am from bar!"
end
@patmaddox
patmaddox / new_note.scpt
Last active May 27, 2018
applescript to make a new markdown note in DEVONthink and open it in an editor
View new_note.scpt
display dialog "Name your note..." default answer ""
set theName to text returned of result
tell application id "DNtp"
set theID to "F76B0AC1-6B7B-45A2-ADE6-8514F54671F4"
set theGroup to get record with uuid theID
set theRecord to create record with {name:theName, type:markdown, content:"# " & theName} in theGroup
set theFile to path of theRecord as POSIX file
tell application "Finder" to open theFile
end tell
You can’t perform that action at this time.