Skip to content

Instantly share code, notes, and snippets.

View brandonpittman's full-sized avatar

Brandon Pittman brandonpittman

View GitHub Profile
@brandonpittman
brandonpittman / kit-google-translate.ts
Last active November 5, 2021 07:55
Translate selected text into with Google Translate.
// Menu: JA → EN
// Description: Translate selected text into with Google Translate.
// Author: Brandon Pittman
// Shortcut: ctrl j
import "@johnlindquist/kit";
const origin = "https://translate.google.com";
const text = await getSelectedText();
const sl = "ja";
@brandonpittman
brandonpittman / weeks.tsx
Last active August 26, 2021 05:44
4000 Weeks
import clsx from 'clsx';
import { differenceInWeeks } from 'date-fns';
const fillIn = (complete: boolean) =>
clsx(
complete ? 'bg-gray-300' : 'bg-transparent',
'h-1.5 w-1.5 border border-gray-300 rounded-full'
);
const weekCount = differenceInWeeks(new Date(), new Date('8/31/1983'));
@brandonpittman
brandonpittman / tabata.cjs
Last active June 15, 2021 23:58
Script to announce Tabata intervals
#!/usr/bin/env node
const os = require("os");
if (os.platform() !== "darwin") {
console.error("This script only works with macOS.");
process.exit(1);
}
const { spawn } = require("child_process");
await $`mkdir example`
await cd('example')
@brandonpittman
brandonpittman / EvernoteBatchRename.applescript
Last active March 30, 2021 07:49
Batch Rename Evernote Notes
tell application "Evernote"
set the_notes to selection
set the_dialog to display dialog "What would you like to title these notes?" default answer ""
set the_title to text returned of the_dialog
set the_count to 1
@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 / 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 / of.zsh
Last active August 4, 2020 08:13
A simple shell function to create tasks in OmniFocus
#!/bin/zsh
# If you use #'s for defer and start dates, you'll need to escape the #'s or
# quote the whole string.
function of () {
if [[ $# -eq 0 ]]; then
open -a "OmniFocus"
else
osascript <<EOT
@brandonpittman
brandonpittman / omnifocus_javascript.js
Last active March 7, 2020 16:09
Examples for using JavaScript for Automation with OmniFocus
// Here are some examples of using Javascript for Automation with OmniFocus
// Create an inbox task
//
// Here, we call inboxTasks without parens because we want it as a function to call later
of = Application('OmniFocus')
inbox = of.defaultDocument.inboxTasks
task = of.InboxTask({name: "testing"})
inbox.push(task)