Skip to content

Instantly share code, notes, and snippets.

View andrewheiss's full-sized avatar
👨‍💻
#rstats-ing all the things

Andrew Heiss andrewheiss

👨‍💻
#rstats-ing all the things
View GitHub Profile
@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
@jalavik
jalavik / unicode_to_latex.py
Created May 17, 2011 11:04 — forked from beniwohli/unicode_to_latex.py
Map to convert unicode characters to their respective LaTeX representation
# original XML at http://www.w3.org/Math/characters/unicode.xml
# XSL for conversion: https://gist.github.com/798546
unicode_to_latex = {
u"\u0020": "\\space ",
u"\u0023": "\\#",
u"\u0024": "\\textdollar ",
u"\u0025": "\\%",
u"\u0026": "\\&",
@dsanson
dsanson / extract_bib.rb
Created November 21, 2011 16:25
Generate a bibtex file containing works cited in a given pandoc extended markdown file
#!/usr/bin/env ruby
bibfile = "~/.pandoc/default.bib"
matches = ARGF.read.scan(/@(.*?)[\.,:;\] ]/)
reg = "\\(" + matches.join("\\)\\|\\(") + "\\)"
system 'bibtool -X \'' + reg + '\' ' + bibfile
@brantfaircloth
brantfaircloth / cool_argparse_stuff.py
Created December 7, 2011 16:47
Some cool argparse stuff
class FullPaths(argparse.Action):
"""Expand user- and relative-paths"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
def is_dir(dirname):
"""Checks if a path is an actual directory"""
if not os.path.isdir(dirname):
msg = "{0} is not a directory".format(dirname)
raise argparse.ArgumentTypeError(msg)
@ttscoff
ttscoff / text_score.rb
Created June 17, 2012 16:17
Readability stats for passed text using ipeirotis.appspot.com
#!/usr/bin/env ruby
# Uses the Readability Metrics API from http://ipeirotis.appspot.com/readability-api.html
# Accepts text from STDIN (piped) or as an argument
=begin examples
pbpaste|text_score.rb # copy text and run (on OS X) to get the stats for the clipboard.
cat myfile.md|text_score.rb # get scores for the contents of a file
=end
require 'open-uri'
require 'net/http'
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active June 13, 2024 02:39
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@lg0
lg0 / toggleiTerm2icon
Last active January 11, 2018 02:51
show/hide iTerm2 Dock icon
# toggle iTerm Dock icon
# add this to your .bash_profile or .zshrc
function toggleiTerm() {
pb='/usr/libexec/PlistBuddy'
iTerm='/Applications/iTerm.app/Contents/Info.plist'
echo "Do you wish to hide iTerm in Dock?"
select ync in "Hide" "Show" "Cancel"; do
case $ync in
'Hide' )
@alexhanna
alexhanna / split_ln.py
Last active February 19, 2020 03:43
Script for splitting Lexis-Nexis files. Adapted from an original from Neal Caren.
#!/usr/bin/env python
# encoding: utf-8
"""
split_ln.py
Created by Neal Caren on 2012-05-14.
neal.caren@unc.edu
Edited by Alex Hanna on 2015-01-29
alex.hanna@gmail.com
@jefferys
jefferys / roxygen2MultiFunctionDocumentation.gist.R
Created June 21, 2015 17:29
R function documentation with roxygen2 - multiple functions
#===================================================
# Demo multi-function roxygen2 - three ways to do it
#===================================================
# This shows how things do work, including wierd corner cases, not
# how they should be done. Most of the information comes from
# http://r-pkgs.had.co.nz/man.html
#====================================================
# Demo multi-function roxygen2 page using @describeIn
@mdlincoln
mdlincoln / rstudio-cc.yml
Last active August 9, 2022 11:46
cloud-config script to setup Rstudio server and Shiny server on Ubuntu 14.04 on Digital Ocean
#cloud-config
# In order to access RStudio server via the web interface, you must log on with
# a user account that allows password access. This script does not add that user
# by default. You may either ssh as root into the server and `adduser` as
# normal, or script a user addition here:
# users:
# - name: # username #
# lock-passwd: false # allow login with password