Skip to content

Instantly share code, notes, and snippets.

View chauncey-garrett's full-sized avatar

Chauncey Garrett chauncey-garrett

View GitHub Profile
@chauncey-garrett
chauncey-garrett / ssh-forward-clipboard.md
Created December 22, 2017 17:25 — forked from dergachev/ssh-forward-clipboard.md
Forward your clipboard via SSH reverse tunnels

Exposing your clipboard over SSH

I frequently administer remote servers over SSH, and need to copy data to my clipboard. If the text I want to copy all fits on one screen, then I simply select it with my mouse and press CMD-C, which asks relies on m y terminal emulator (xterm2) to throw it to the clipboard.

This isn't practical for larger texts, like when I want to copy the whole contents of a file.

If I had been editing large-file.txt locally, I could easily copy its contents by using the pbcopy command:

@chauncey-garrett
chauncey-garrett / appinfo.rb
Created December 5, 2017 20:44 — forked from ttscoff/appinfo.md
A quick ruby script for Mac that returns some information for a specified Mac app in Terminal. Includes icon display if using iTerm2.
#!/usr/bin/env ruby
require 'date'
###################################################
# iii fff #
# aa aa pp pp pp pp nn nnn ff oooo #
# aa aaa ppp pp ppp pp iii nnn nn ffff oo oo #
# aa aaa pppppp pppppp iii nn nn ff oo oo #
# aaa aa pp pp iii nn nn ff oooo #
# pp pp #
###################################################
array=(one two three)
for number in ${(@)array}; do
echo "$number"
done
@chauncey-garrett
chauncey-garrett / prepare-commit-msg.sh
Created April 14, 2017 04:21 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@chauncey-garrett
chauncey-garrett / macOS-get-password-from-keychain
Last active November 18, 2016 16:57
Get password from macOS keychain
security find-generic-password -a "insert_account_name_here" -g 2>&1 \
| grep password \
| sed -e "s/password: \"//" -e "s/\"//"
@chauncey-garrett
chauncey-garrett / gist:fcb1deea4cf2db4e24596bb5dd0334f6
Created October 13, 2016 14:47
Create RSS Feed of the releases of all your starred GitHub repositories

Create RSS Feed of the releases of all your starred GitHub repositories

I have done this with Google Chrome.

  1. Get your starred repositories from the GitHub API: https://api.github.com/users/USERNAME/starred?page=1&per_page=100
  2. Open the Web developer tools in Chrome. Select the pre Tag in the HTML-View and execute this Javascript in the console: JSON.parse($0.innerText).map(function(repo) { return 'https://github.com/' + repo.full_name + '/releases.atom' }).join('\n'). This generates a list of the Release-Feed-URLs.
  3. Copy the URL list to http://reader.feedshow.com/goodies/opml/OPMLBuilder-create-opml-from-rss-list.php If you have more than 100 starred repositories, you need repeat step 1 to 3 and increment the page in the URL in step 1 each time.
  4. Click "Create OPML".
  5. Save the OPML XML file to disk.
@chauncey-garrett
chauncey-garrett / how-to-set-up-stress-free-ssl-on-os-x.md
Created August 18, 2016 16:47 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

#!/bin/bash
# g@ut.am
SSHCONFIG_Linux=$(cat << 'HERE-DOC'
Host *
StrictHostKeyChecking no
ServerAliveInterval 60
ForwardAgent yes
ServerAliveCountMax 4
copy() {
if [[ $1 =~ ^-?[hH] ]]; then
echo "Intelligently copies command results, text file, or raw text to"
echo "OS X clipboard"
echo
echo "Usage: copy [command or text]"
echo " or pipe a command: [command] | copy"
return
fi