Skip to content

Instantly share code, notes, and snippets.

View masnick's full-sized avatar

Max Masnick masnick

View GitHub Profile
@masnick
masnick / gist:b532d6d675b28e939e09
Created April 28, 2015 14:57
Close all Finder windows except the front one
tell application "Finder"
repeat while window 2 exists
close window 2
end repeat
end tell
@masnick
masnick / xtitle: Clipboard to titlecase helper
Created June 4, 2015 13:31
TextExpander: Clipboard to Titlecase
#!/bin/bash
echo -n "%snippet:xxxxtitle%" | tr -d '\n'
@masnick
masnick / Gemfile
Created June 25, 2015 14:45
LaunchBar 6 Action for posting to iDoneThis
source "https://rubygems.org"
gem 'json'
gem 'idonethis'
@masnick
masnick / cell.py
Last active August 29, 2015 14:25
IPython notebook snipped for a list of variables in a dataframe
# Assumes `df` is a Pandas DataFrame object
import IPython.core.display as di
for k, v in df.columns.to_series().groupby(df.dtypes).groups.iteritems():
di.display_html("<ul><li><b>%s</b><ul>%s</ul></li></ul>" % (k, ''.join(["<li>%s</li>" % vv for vv in sorted(v)])), raw=True)
@masnick
masnick / gridspec.ipynb
Created July 29, 2015 16:01
GridSpec histogram + box plot example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@masnick
masnick / cross_join_results_table.md
Created August 7, 2015 16:48
Cross join results table
friend_id friend_name pet_id owner_id pet_type pet_name
1 John 1 1 goldfish Fishy
2 Sarah 1 1 goldfish Fishy
3 Rachel 1 1 goldfish Fishy
4 Sam 1 1 goldfish Fishy
1 John 2 1 goldfish Nemo
2 Sarah 2 1 goldfish Nemo
3 Rachel 2 1 goldfish Nemo
4 Sam 2 1 goldfish Nemo
@masnick
masnick / bookmarklet.html
Created August 8, 2015 19:08
Amazon.com order history search bookmarklet
<a href="javascript:(function()%7Bvar%20x%20%3D%20window.prompt(%22Search%20Amazon.com%20order%20history%20for%3A%22)%3Bwindow.location.href%3D'https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyour-account%2Forder-history%2Fref%3Doh_aui_search%3Fopt%3Dab%26search%3D'%2BencodeURIComponent(x)%7D)()">Drag to your bookmarks bar</a>
@masnick
masnick / Web Confidential to KeePassX.rb
Created June 28, 2010 01:10
Web Confidential to KeePassX
#!/usr/bin/env ruby
# Usage:
# 1) Save as something.rb on Desktop. Optionally update the date on the line
# that beings with "time = " if you want the creation date to be correct in
# KeePassX.
# 2) Run in Terminal: chmod 777 ~/Desktop/something.rb
# 3) Run in Terminal: ~/Desktop/something.rb web_confidential_export.txt
# 4) Import the resulting export.xml into KeePassX
# 5) Use the "srm" command to delete the plaintext files containing passwords
# Put this in your ~/.bash_profile file
# To reload the .bash_profile without restarting Terminal, run "source ~/.bash_profile"
# http://stackoverflow.com/questions/420456/open-terminal-here-in-mac-os-finder
function ff { osascript -e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "get POSIX path of (target of window ${1-1} as alias)"\
-e 'else' -e 'get POSIX path of (desktop as alias)'\
-e 'end if' -e 'end tell'; };\
#
#
# test.rb
#
#
require 'rubygems'
require 'active_record'
require 'classifier'