Skip to content

Instantly share code, notes, and snippets.

View dsanson's full-sized avatar

David Sanson dsanson

View GitHub Profile
#!/bin/sh
# This script converts RTF text on the OS X clipboard to HTML.
osascript -e 'the clipboard as «class RTF »' | \
perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \
textutil -format rtf -convert html -stdin -stdout | \
ruby -ne '@found=true if $_ =~ /<body>/; next unless @found; puts $_; exit if $_ =~ /<\/body>/' | \
grep -v "<body>" | \
#!/bin/sh
# Convert RTF contents of clipboard to HTML
osascript -e 'the clipboard as «class RTF »' | \
perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \
textutil -format rtf -convert html -stdin -stdout | \
ruby -ne '@found=true if $_ =~ /<body>/; next unless @found; exit if $_ =~ /<\/body>/; puts $_;' | \
grep -v "</body>" | \
pbcopy
#!/bin/sh
# Convert RTF contents of clipboard to HTML
osascript -e 'the clipboard as «class RTF »' | \
perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | \
textutil -format rtf -convert html -stdin -stdout | \
pandoc -f html -t markdown | \
pbcopy
@dsanson
dsanson / pdfocr.sh
Created September 15, 2010 15:13
pdfocr.sh: ocr scan pdfs to make them searchable
#!/bin/sh
#
# This is a shell wrapper around the command line version of
# [VelOCRaptor](http://www.velocraptor.com/), an affordable
# OCR program for OS X.
#
if [ $# = 2 ]; then
echo "Scanning file..."
/Applications/VelOCRaptor.app/Contents/SharedSupport/velocraptor.rb "$1" "$2" && \
@dsanson
dsanson / bibkey
Created September 15, 2010 15:14
extract bibtex keys
#!/usr/bin/ruby
## get a sorted list of cite keys that match an array of strings
##
## Usage:
##
## $ bibkey citekey1 [citekey2 ...]
## $ bibkey path-to-bibtex citekey1 [citekey2 ...]
##
## if the first argument is a path to a readable file, then the
@dsanson
dsanson / backuptosdhc.sh
Created September 15, 2010 15:17
backup to sdhc
#!/bin/sh
# A script that first checks if an external disk is mounted and
# then uses rsync to perform a time machine style backup.
#
# I need to work on the how the script behaves when the disk is
# full. Ideally, it would delete the oldest backup.
#
original="/"
@dsanson
dsanson / pd
Created March 6, 2011 20:24
pd: a wrapper around pandoc that allows setting up some default options
#!/usr/bin/env bash
#
# AUTHOR:: David Sanson
# URL: https://gist.github.com/857619
# LICENSE: http://creativecommons.org/licenses/MIT/
# VERSION: 0.2
#
# IN PROGRESS:
# Support for "profiles".
# Removed $defaultopts_markdown2pdf---just use formatopts[pdf] instead.
@dsanson
dsanson / export_chrome_history.sh
Created March 10, 2011 20:09
dump chrome's history to a text file for use with quicksilver.app
#!/bin/sh
#
# export_chrome_history.sh
#
# A script to dump a list of urls from Google Chrome's History
# database on OS X. It should work on any *nix, but you'll need
# to edit the values of $input_file and $output_file.
#
#
# Author: David Sanson
@dsanson
dsanson / custom.css
Created July 12, 2011 18:16
A custom.css for use with Marked.app
/*
This is my hacked up copy of Marked.app/Contents/Resources/gridless.css
Changes:
1. Smaller headings
2. ~~No scrollbars~~ (I now prefer the Lion default behavior)
3. Styling of definition lists ala LaTeX description lists.
4. Centering h1.title, h3.author, h4.date (pandoc's title/author/date block).
HOMEBREW_VERSION: 0.8
HEAD: 97b62b8b3f1c8973cf8a2575bfc98706ccbbde39
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: dual-core 64-bit penryn
OS X: 10.7.1
Kernel Architecture: x86_64
Ruby: 1.8.7-249