Skip to content

Instantly share code, notes, and snippets.

@deed02392
deed02392 / foo{1..6}.bar.baz.scpt
Last active Jun 14, 2019
AppleScript for iTerm2 which SSHs into multiple hosts with split panes across two rows
View foo{1..6}.bar.baz.scpt
-- Save me in ~/Library/Application Support/iTerm2/Scripts, then restart iTerm2 and find me in the Scripts menu
set hostnames to {"foo1.bar.baz", "foo2.bar.baz", "foo3.bar.baz", "foo4.bar.baz", "foo5.bar.baz", "foo6.bar.baz"}
tell application "iTerm"
activate
create window with default profile
tell current tab of current window
select
tell current session
write text "ssh " & (item 1 of hostnames)
View main.go
package main
import "go.mozilla.org/sops/decrypt"
import "fmt"
import "bytes"
import "bufio"
import "strings"
import "log"
//import "go.mozilla.org/sops/vendor/github.com/sirupsen/logrus"
//import "go.mozilla.org/sops/logging"
@deed02392
deed02392 / gist:7570930cdaaeba247ae88750f75c0b58
Last active Jan 10, 2018
Find and replace file names and leave softlink behind
View gist:7570930cdaaeba247ae88750f75c0b58

The following command will replace match with replace for all files in the cwd, and create a soft link to the new file name using the old file name.

$ find . -name '*.mkv' -type f -exec bash -c 'mv "$1" "${1/match/replace.}" && ln -s "${1/match/replace.}" "$1"' -- {} \;

So:

ls -l
total 27477872
-rw-r--r--. 1 george media_ 3517838477 Jan  9 20:04 match04e01.mkv
@deed02392
deed02392 / gist:a82cc86c2a6f9b23b6861de3f29e2847
Created Dec 20, 2017
Send OS X Mail Digitally Signed without Password
View gist:a82cc86c2a6f9b23b6861de3f29e2847
If you want to digitally sign your e-mail but not provide a password to unlock your keychain every time (for example, because you want to send Automator e-mails) you can do this in a few easy steps.
1. Open Keychain Access
2. Under the Keys category, find the private key associated with your e-mail certificate
3. Double click on it to open its info
4. Open the Access Control tab, providing credentials if asked
5. Select the Allow all applications to access this item radio button and then click Save Changes
Your mail client will no longer need to elevate privileges to access the private key and will therefore be able to sign and decrypt your mail messages without password.
@deed02392
deed02392 / pushover.py
Created Jul 22, 2017
no urllib2.URLError property called 'code'
View pushover.py
# send the request to pushover
try:
req = urllib2.Request(API_URL)
handle = urllib2.urlopen(req, data)
handle.close()
except urllib2.HTTPError as e:
logger.log(u'PUSHOVER: HTTPError: %s' % e.args, logger.ERROR)
except urllib2.URLError as e:
# HTTP status 404 if the provided email address isn't a Pushover user.
logger.log(u'PUSHOVER: URLError: %s' % e.reason, logger.ER
View gist:dd1715ba9050dc00ac717b825eb1ada5
openssl req -new -sha256 -nodes -out \*.your-new-domain.com.csr -newkey rsa:2048 -keyout \*.your-new-domain.com.key -config <(
cat <<-EOF
[req]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
View TV Episode Highlights!.md

Ray Donovan

You're so crass

Fish and Bird - 4x06 - 21:38

Tom and Jerry

I Love You - It is a Burning Flame

The Zoot Cat - 1940x13 - 4:44

Le Bureau des Légendes

@deed02392
deed02392 / Send-Email.ps1
Created Sep 3, 2015
PowerShell cmdlet that sends an e-mail via Outlook, with address and subject as arguments and message body from pipe
View Send-Email.ps1
Function Global:Send-Email {
[cmdletbinding()]
Param (
[Parameter(Mandatory=$True,Position=0)]
[String]$Address,
[Parameter(Mandatory=$True,Position=1)]
[String]$Subject,
[Parameter(ValueFromPipeline=$True)]
[String[]]$BodyLine
)
View jsbin.difuz.css
body {
font-family: arial;
cursor: crosshair;
}
h1 {
color: #00FF00;
text-align: center;
}
h2 {
border: thin dotted green;
View jsbin.voliz.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h1>Things I Like</h1>
<ol>
<li>Kittens</li>