Skip to content

Instantly share code, notes, and snippets.

View faun's full-sized avatar
🌵

Faun faun

🌵
View GitHub Profile
@faun
faun / smb_fs_automount.sh
Last active February 19, 2025 01:08
Script to mount remote SMB volume using password stored in Mac OS keychain without needing admin or sudo priveliges
#!/usr/bin/env bash
# Fetch the password from the keychain if it exists
PASSWORD_ENTERED=false
ACCOUNT_NAME='login'
SERVICE_NAME='mount_volume'
PASSWORD=$(
security 2> /dev/null \
find-generic-password -w \
-a $ACCOUNT_NAME \
@faun
faun / pallindrome.rb
Created December 30, 2014 23:49
Pallindromes
class String
def pallindrome?
string = self.downcase.gsub(/[^0-9a-z]/i,'')
return false if string.length <= 1
string.reverse == string
end
def collect_possible_starts_and_end
#{ a: [0, 1], b: [3], c: [1,4,6]}
@faun
faun / com.googlecode.iterm2.plist
Last active August 29, 2015 14:09
iTerm2 settings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AdjustWindowForFontSizeChange</key>
<true/>
<key>AllowClipboardAccess</key>
<true/>
<key>AnimateDimming</key>
<false/>
@faun
faun / pre-commit
Last active August 29, 2015 14:09
Pre-commit hook
#!/bin/bash
## START PRECOMMIT HOOK
# Install with:
# ln -s ../../bin/pre-commit .git/hooks/pre-commit
files_modified=`git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '`
for f in $files_modified; do
if [[ $f == vendor/* ]]; then
echo "skipping $f"
@faun
faun / .env.example
Created August 30, 2014 08:23
Sample .env file for zinedistro
export DEVISE_SECRET_KEY='A REALLY LONG KEY'
export SECRET_TOKEN='A REALLY LONG KEY'
export SECRET_KEY_BASE='A REALLY LONG KEY'
export CARRIERWAVE_PROVIDER='AWS'
export CARRIERWAVE_AWS_ACCESS_KEY_ID='A REALLY LONG KEY'
export CARRIERWAVE_AWS_SECRET_ACCESS_KEY='A REALLY LONG KEY'
export CARRIERWAVE_REGION='us-west-1'
export CARRIERWAVE_ENDPOINT='https://s3-us-west-1.amazonaws.com/'
export CARRIERWAVE_HOST='https://s3.amazonaws.com'
export CARRIERWAVE_ASSET_HOST='http://assets.zinedistro.org'
@faun
faun / keybase.md
Created June 14, 2014 04:55
Keybase Verification

Keybase proof

I hereby claim:

  • I am faun on github.
  • I am faun (https://keybase.io/faun) on keybase.
  • I have a public key whose fingerprint is D4C9 FFB9 F1DC EF35 9E0A 3D0D 92D9 A892 2212 44C4

To claim this, I am signing this object:

@faun
faun / install_nokogiri_with_homebrew
Last active October 2, 2018 06:50
Install Nokogiri with Homebrew
#! /bin/sh
set -e
BREW_PREFIX="$(brew --prefix)"
BREW_CELLAR="${BREW_PREFIX}/Cellar"
function libxslt_version()
{
brew list --versions libxslt | awk '{ print $2 }'
}
@faun
faun / Gemfile
Last active August 29, 2015 14:01
Issue with Rails 4.1 has_many uniq through and order
source 'https://rubygems.org'
# gem 'activerecord', '4.0.5'
gem 'activerecord', '4.1.1'
gem 'pg'
@faun
faun / decrypt_pdfs_service.sh
Created April 29, 2014 09:15
Service to decrypt all selected PDFs. This script is intended for use in an automator workflow. Files and folders selected should be passed in as arguments.
#! /bin/sh
password=$(security 2> /dev/null find-generic-password -a login -s decrypt_pdfs -D "application password" -w)
set -e
decrypt_file () {
source_file="$1"
filename="$(basename "$source_file")"
directory="$(dirname "$source_file")/decrypted"
@faun
faun / decrypt_pdfs
Last active January 28, 2025 15:17
Decrypt all PDFs in a directory using the given password and optionally store the password in the Mac OS system keychain
#! /bin/sh
# Check if qpdf is installed
installed=$(which qpdf &> /dev/null)
if [ $? -eq 1 ]; then
echo >&2 "Please install qpdf first (brew install qpdf)"
exit 1
fi
# Fetch the password from the keychain