Skip to content

Instantly share code, notes, and snippets.

@maxrothman
maxrothman / gist:98ba2af4b2f1dd7df93f
Created January 8, 2015 19:09
Open iTerm to current Finder directory automator application
-- Add a button to Finder that opens iTerm to the current directory
-- Inspired by http://peterdowns.com/posts/open-iterm-finder-service.html
-- but updated to use the new iTerm nightly build AppleScript API and OSX 10.9.5 AppleScript
-- Setup (same as above link):
-- - Create a new Automator Application
-- - Add a "Run AppleScript" action
-- - Paste this in and save
-- - with Command-drag the application to the top bar in Finder
on run {input, parameters}
@maxrothman
maxrothman / gist:af71ff2cef2a04f69384
Created January 8, 2015 17:41
iTerm2 nightly build integration with Alfred
-- The nightly builds of iTerm have changed its AppleScript API, which breaks Alfred's default iTerm integration.
-- The new API examples are here: https://iterm2.com/applescript.html
-- Discussion about it and support can be found here: https://groups.google.com/forum/#!msg/iterm2-discuss/PcMGixwuceY/81JMZheXb_UJ
--Simply paste this into the box under Alfred Preferences > Terminal/Shell > Application: Custom
on alfred_script(q)
tell application "iTerm"
create window with default profile
tell current session of last terminal window
write text q & "; clear"
@maxrothman
maxrothman / gist:fbc17ca2c99822af7546
Created January 7, 2015 15:38
Handy Python datatypes
class Board(list):
'''Interprets board[1,2] as board[1][2]'''
def __getitem__(self, key):
try:
cur = self
key = list(key)
while len(key) > 0:
cur = list.__getitem__(cur, key.pop(0))
return cur
@maxrothman
maxrothman / formula.jison
Created October 31, 2014 13:56
spreadsheet-like formula jison language spec
/** Parses end executes mathematical expressions with functions mixed in.
* TODO: add referencing symbols elsewhere on the page (via some selector).
**/
%{
var funcs = {
pow: function(a,b) { return Math.pow(a,b); },
test: function(a) { return a*2; }
}
%}
@maxrothman
maxrothman / ita_word_numbers.py
Created October 14, 2014 17:10
ITA word numbers puzzle solution
'''My solution to the ITA puzzle "Word Numbers"
<http://www.itasoftware.com/careers/puzzle_archive.html>
"If the integers from 1 to 999,999,999 are written as words,
sorted alphabetically, and concatenated, what is the 51 billionth letter?"
To be precise: if the integers from 1 to 999,999,999 are expressed in words
(omitting spaces, 'and', and punctuation[1]), and sorted alphabetically
so that the first six integers are
@maxrothman
maxrothman / convert.py
Created October 14, 2014 17:03
Parsing the Arisia HTML schedule for conversion into your favorite calendar format
#!/usr/bin/python
#Converts arisia HTML schedule to the following format:
#{name:NAME, start:YYYY-MM-DDTHH:MM:SS.000-05:00, end:(same as start), location:LOCATION, body:TEXT}
#name includes type
import re
from datetime import datetime, timedelta
import dateutil.parser
from sample import main
@maxrothman
maxrothman / .bash_colors
Last active August 23, 2017 11:46
bash tips & one-liners
# Reset
NoColor='\[\e[m\]' # Text Reset
# Regular Colors
Black='\[\e[0;30m\]' # Black
Red='\[\e[0;31m\]' # Red
Green='\[\e[0;32m\]' # Green
Yellow='\[\e[0;33m\]' # Yellow
Blue='\[\e[0;34m\]' # Blue
Purple='\[\e[0;35m\]' # Purple