Skip to content

Instantly share code, notes, and snippets.

Avatar

Prasanna Swaminathan pswaminathan

View GitHub Profile
View git-stack
#!/bin/sh
#
# git-stack: Push this commit to a branch specified in its
# commit description.
#
# -- IMPORTANT -- this script is for macOS (using BSD sed)
#
# Taken from https://wchargin.github.io/posts/managing-dependent-pull-requests/
# Copyright (c) 2017 William Chargin. Released under the MIT license.
@pswaminathan
pswaminathan / multiple_results.md
Last active Aug 27, 2019
Benchmarking Go (Golang) UUID Packages
View multiple_results.md
pswaminathan at home in ~/uuidbench
$ gb test -v -bench=. -test.benchmem
uuids
testing: warning: no tests to run
PASS
BenchmarkPbormanParse-4	 3000000	       599 ns/op	      80 B/op	       5 allocs/op
BenchmarkPbormanDump-4 	  200000	      6756 ns/op	    1520 B/op	      60 allocs/op
BenchmarkSatoriParse-4 	 1000000	      1149 ns/op	     240 B/op	       5 allocs/op
BenchmarkSatoriDump-4  	 3000000	       584 ns/op	     240 B/op	       5 allocs/op
View gist:22327a85b1913f6c70aa

Exporting (iCloud) Keychain and Safari credentials to a CSV file

After my dad died, I wanted to be able to have access any of his online accounts going forward. My dad was a Safari user and used iCloud Keychain to sync his credentials across his devices. I don’t want to have to keep an OS X user account around just to access his accounts, so I wanted to export his credentials to a portable file.

This is the process I used to create a CSV file of his credentials in the format “example.com,user,pass”. This portable format would be pretty easy to import into 1Password or Safari in the future.

The way I went about this isn’t great; it opens up more opportunities for apps to control one’s Mac through Accessibility APIs, it writes plaintext passwords to disk, and it could use some cleaning up. A better approach might leverage the security command line tool that ships with OS X. That said, I found this method to be a fun illustration of what’s possible us

View index.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<h1>Choose a Service:</h1>
<select id="service-selector">
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<h1>Choose a Service:</h1>
<select id="service-selector">
@pswaminathan
pswaminathan / int_conv_test.go
Created Aug 28, 2016
Int Conversion Benchmarks
View int_conv_test.go
package main
import (
"fmt"
"strconv"
"testing"
)
var (
n = 12345
@pswaminathan
pswaminathan / email_address_regex.txt
Created Oct 3, 2013
Regex for matching email addresses
View email_address_regex.txt
^[\w.%+-]+@(?:[\w-]+\.)+[A-Za-z]{2,4}$
Explanation:
^ # Start of string. If searching in-line replace with \b
[\w.%+-]+ # Matches alphanumeric, _, ., %, +, or - repeatedly
@ # name-domain separator
(?:
[\w-]+ # Matches alphanumeric or - repeatedly
\. # Matches dot in domain separator
)+ # Matches for one domain or for multiple subdomains
@pswaminathan
pswaminathan / extract_function.sh
Created Aug 6, 2013
Function to extract most typical kinds of files, without needing to remember all the damn flags.
View extract_function.sh
# Extract Files
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar xvJf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
@pswaminathan
pswaminathan / python27_on_debian.sh
Last active Dec 16, 2015 — forked from willfill/python27_on_debian.sh
Only needed for debian<=6
View python27_on_debian.sh
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
#for lxml
sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
#for mysql client
sudo apt-get install libmysqlclient-dev
# On OS X instead (assuming brew installed...)
brew install mysql
You can’t perform that action at this time.