Skip to content

Instantly share code, notes, and snippets.

Avatar
🏕️
I’m trying to do my job, please respect my time and attention.

Brandon Pittman brandonpittman

🏕️
I’m trying to do my job, please respect my time and attention.
View GitHub Profile
@brandonpittman
brandonpittman / Counter.php
Created Jul 29, 2019
Livewire Counter component
View Counter.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Counter extends Component
{
public $count = 0;
@brandonpittman
brandonpittman / OpenAndComplete.js
Last active May 1, 2019
Things OpenAndComplete written in JS (v2)
View OpenAndComplete.js
function run(argv) {
var app = Application('Things3')
var currentApp = Application.currentApplication()
currentApp.includeStandardAdditions = true
var selected = app.selectedToDos()
if (selected.length !== 0) {
selected.forEach(todo => {
todo.completionDate = new Date()
@brandonpittman
brandonpittman / OpenAndComplete.applescript
Created Apr 30, 2019
Open and Complete for Things 3
View OpenAndComplete.applescript
on run
tell application "Things3"
repeat with todo in selected to dos
set completion date of todo to (current date)
set theNotes to notes of todo
repeat with todoParagraph in paragraphs of theNotes
if todoParagraph contains "://" then
do shell script "open " & quoted form of todoParagraph
end if
@brandonpittman
brandonpittman / WeeklyReview.js
Created Apr 17, 2019
Weekly Review in Things
View WeeklyReview.js
const Things = require('things-json').default
const showList = list => `things:///show?id=${list}`
const project = Things.project({
title: 'Weekly Review',
})
const todos = [
Things.todo({ title: 'Brain Dump' }),
@brandonpittman
brandonpittman / omnisort.applescript
Created Dec 4, 2017
Sort stuff by name |> status
View omnisort.applescript
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "System Events"
click menu item "By Name" of menu "Sort Once" of menu item "Sort Once" of menu "Organize" of menu bar item "Organize" of menu bar 1 of application process "OmniFocus"
click menu item "By Status" of menu "Sort Once" of menu item "Sort Once" of menu "Organize" of menu bar item "Organize" of menu bar 1 of application process "OmniFocus"
end tell
View lists.exs
def even_length?([]), do: true
def even_length?([_]), do: false
def even_length?([ _, _ | t ]), do: even_length?(t)
View lists.exs
defmodule Lists do
def len([]), do: 0
def len([ _head | tail ]), do: 1 + len(tail)
def sum([]), do: 0
def sum([h | t]), do: h + sum(t)
def double([]), do: []
def double([head | tail ]), do: [2*head | double(tail)]
@brandonpittman
brandonpittman / 99bottles.rb
Last active Jun 19, 2017
99 Bottles of OOP assignment
View 99bottles.rb
class Bottles
def verse(number_of_bottles)
first_line(number_of_bottles) << "\n" << second_line(number_of_bottles) << "\n"
end
def verses(number_of_bottles_start, number_of_bottles_end)
number_of_bottles_start.downto(number_of_bottles_end).map do |number_of_bottles|
verse(number_of_bottles)
end.join("\n")
end
@brandonpittman
brandonpittman / Gotconvert.vim
Created Feb 16, 2017
Convert a ThronesDB decklist into a usable format for ThronesTeki
View Gotconvert.vim
function! Gotconvert() abort
silent g/^\D/d
silent g/^$/d
silent %s/\v^(\d)x (.+)/\1\2
endfunction
@brandonpittman
brandonpittman / proof.fish
Created Jan 6, 2017
Fish function for using writing scripts
View proof.fish
# Check out the individual writing scripts here:
# http://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/
# red is wrapper for the fish utility "cprintf" that uses `cprintf "<fg:red>%s</fg>" "Weasel words:"`
function proof --description 'Check writing for dups, passive voice and weasel words'
red "Weasel words:"
weasel $argv
red "Passive voice:"
passive $argv
red "duplicates:"