Skip to content

Instantly share code, notes, and snippets.

@rwilcox
rwilcox / many_parameters_fill_out_missing.rb
Last active October 4, 2023 21:14
My starter template for creating scripts with lots of parameters that also prompt you to fill out the missing parameters
#!/usr/bin/env ruby
# Why not bash?
# bash is annoying for opts handling
# AND especially annoying if those opts need to be in both --key value AND --key=value format
# AND not DRY.
# and Ruby is pretty close to bash in syntax. Or it's close to Perl, which is close to Bash
# and Python feels like a bunch of boilerplate here
require 'optparse'
@rwilcox
rwilcox / scratchpad_now.applescript
Created March 21, 2012 13:11
Open Scratchpad *NOW*
-- but this in your system level Script menu (using the Script Menu builtin in OS X, or Fastscripts from http://red-sweater.com
tell application "BBEdit"
set newDoc to scratchpad window
select newDoc
activate
end tell
version: 1
tasks:
from-net:
command: python3
script: |
print("hi from the network")
// ==UserScript==
// @name Only Github News
// @version 1
// @grant none
// @include /^https?://github\.com\/\?news=only/
// ==/UserScript==
document.querySelector(".team-left-column").remove()
@rwilcox
rwilcox / spanner_client.ts
Last active February 27, 2023 17:17
Spanner and Typescript
// I should probably write a blog post about this, but whatever
import { Spanner, Instance } from '@google-cloud/spanner'
import type { Database } from '@google-cloud/spanner'
/**
Authentication is provided by the local machine user running
`gcloud auth application-default login`
*/
@rwilcox
rwilcox / web2bbedit.sh
Created May 8, 2012 11:59
Download something from the web directly into BBEdit
#!/bin/sh
curl $1 | /usr/local/bin/bbedit
# Call this script like so:
# web2bbedit.sh http://www.barebones.com
# This will open the Bare Bone Software homepage as HTML in BBEdit
@rwilcox
rwilcox / github_remove_relative_date_greasemonkey.user.js
Last active November 29, 2022 02:38
Remove Github's relative date
// ==UserScript==
// @name Github remove relative date stupidness
// @namespace http://www.wilcoxd.com
// @include https://github.com*
// @version 1
// @grant none
// ==/UserScript==
// created: WD-rpw 03-25-2013
@rwilcox
rwilcox / create_markdown_row_in_bbedit.applescript
Created March 31, 2012 22:33
BBEdit Create Markdown Table Row with BBEdit
-- by Ryan Wilcox, March 30, 2012, licensed under Public Domain
tell application "BBEdit"
tell window 1
set theRes to display dialog "Create how many columns?" default answer "3"
set columnNum to (text returned of theRes as number)
set insertionP to get selection
set tableColumnText to "| <##> "
set tableRowText to ""
@rwilcox
rwilcox / open_here_in_shell_worksheet.applescript
Created March 13, 2012 12:42
BBEdit Script to Open Here In Shell Worksheet
tell application "BBEdit" to set theFile to file of document 1
tell application "Finder" to set theFolder to (container of file theFile) as alias
set theUnixPath to POSIX path of theFolder
set output to return & "cd '" & theUnixPath & "'; pwd"
tell application "BBEdit"
set uws to Unix worksheet window
tell uws
select insertion point after last character
set selection to output
@rwilcox
rwilcox / run_selection_as_clipping.applescript
Created August 14, 2012 13:51
Run the current selection as a BBEdit clipping
tell application "BBEdit"
set theScript to selection as text
set clippingFileRef to (path to temporary items as string) & "clipping_as_selection"
--close access clippingFileRef
set fileref to open for access file clippingFileRef with write permission
set eof of fileref to 0 -- clear the file
write theScript to fileref
close access fileref