Skip to content

Instantly share code, notes, and snippets.

View brandonpittman's full-sized avatar

Brandon Pittman brandonpittman

View GitHub Profile
@brandonpittman
brandonpittman / withIcon.jsx
Created March 6, 2021 07:31
Icon Caching component
import * as React from 'react'
import hash from 'fnv1a'
export const IconCache = React.createContext({})
IconCache.displayName = 'IconCache'
export const useIconCache = () => React.useContext(IconCache)
const withIcon = (icon) => {
const Icon = (props) => {
const { size = 24, color = 'currentColor', ...propsWeDontControl } = props
const cache = useIconCache()
@brandonpittman
brandonpittman / dumb-angular-shit.md
Last active January 5, 2021 01:36
Super dumb, but this actually works
@HostBinding('attr.id')
externalId = '';

@Input()
set id(value: string) {
  this.#id = value;
  this.externalId = null;
}
@brandonpittman
brandonpittman / preact-test.html
Created January 22, 2020 02:00
Preact standalone module test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
@brandonpittman
brandonpittman / watermark.fish
Created September 4, 2019 07:45
Pass a glob into this function to quickly add a basic watermark of the filename
function watermark
for file in $argv
convert $file -font Arial -pointsize 20 -draw "gravity south fill black text 0,12 '$file' fill white text 1,11 '$file' " converted-$file
end
end
@brandonpittman
brandonpittman / Counter.php
Created July 29, 2019 02:18
Livewire Counter component
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Counter extends Component
{
public $count = 0;
@brandonpittman
brandonpittman / OpenAndComplete.js
Last active May 1, 2019 15:00
Things OpenAndComplete written in JS (v2)
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 April 30, 2019 10:16
Open and Complete for Things 3
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 April 17, 2019 10:28
Weekly Review in Things
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 December 4, 2017 06:14
Sort stuff by name |> status
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
def even_length?([]), do: true
def even_length?([_]), do: false
def even_length?([ _, _ | t ]), do: even_length?(t)