Skip to content

Instantly share code, notes, and snippets.

@turadg
turadg / Send Chrome to OmniFocus.scpt
Created September 24, 2011 22:43
OmniFocus integrations
-- based on post by iNik: http://forums.omnigroup.com/showthread.php?p=101947#post101947
global theTitle, theTaskNote
set theTaskNote to ""
tell application "Google Chrome"
-- activate
tell window 1 to tell active tab
@turadg
turadg / swaggerTable.js
Created January 3, 2017 22:50
Generate a tab delimited table of endpoints on a Swagger-described API
#!/usr/bin/env node
/*
For Swagger 1.2 docs format.
Hardcode the base path in the urlFor() function.
Assumes Node 6+.
*/
#!/bin/bash
#
# Retroflow
#
# This makes it easier to retrofit Flow type checking onto your existing code.
#
# Given a path argument, it finds all the js/jsx files under that path that
# don't have the Flow (flowtype.org) preamble. It then adds it and runs the
# Flow check. If anything fails, it removes it again.
#
#!/bin/bash
# fork of https://codecov.io/bash
set -e +o pipefail
VERSION="0db33a1"
url="https://codecov.io"
url_o=""
verbose="0"
@turadg
turadg / bluetooth-swap.sh
Last active December 22, 2015 20:59 — forked from hughsaunders/release_bt_keyboard.sh
Script to swap your Bluetooth devices connections between two Macs. Works great with iMacMonitor.app to quickly switch your iMac between being a laptop monitor or full computer. http://bogner.sh/2013/07/os-x-how-to-use-an-imac-as-monitor/
#!/usr/bin/env bash
# This script works after you've paired the Bluetooth devices with
# both the local and remote computer. Turning one off and the other on
# forces the devices to reconnect with the only computer that has BT on.
# Look up local SSH hosts with Bonjour using `dns-sd -B _ssh`
# You may want to set up an SSH keypair to log in without typing a password
REMOTE=Stone.local
@turadg
turadg / poltergeist_screenshot_helper.rb
Last active December 15, 2015 20:59
Poltergeist screenshot helper for Rspec
# spec/support/poltergeist_screenshot_helper.rb
module PoltergeistScreenshotHelper
# FROM http://blog.jerodsanto.net/2012/12/capybara-and-poltergeist-snap/
def snap!(options={})
path = options.fetch :path, "~/.Trash"
file = options.fetch :file, "#{Time.now.to_i}.png"
full = options.fetch :full, true
path = File.expand_path path
@turadg
turadg / levenshteinDistanceMixin
Last active December 15, 2015 12:09
Underscore mixin for Levenshtein distance of two strings Adapted from [Levenshtein.coffee](https://raw.github.com/phstc/levenshtein/master/src/Levenshtein.coffee) by @phstc (http://coffeescriptcookbook.com/chapters/strings/matching-strings was broken)
# usage _.levenshteinDistance("PART", "PARTY") or _("PART").levenshteinDistance("PARTY")
_.mixin
levenshtein : (str1, str2) ->
return str2.length if str1.length == 0
distance = []
for i in [0..str1.length]
distance[i] = []
distance[i][0] = i

Keybase proof

I hereby claim:

  • I am turadg on github.
  • I am turadg (https://keybase.io/turadg) on keybase.
  • I have a public key whose fingerprint is 1AAF D87D B5DB 6B87 29A5 7646 0249 C9F5 1B7F 02C2

To claim this, I am signing this object:

@turadg
turadg / .htaccess
Created September 16, 2011 01:56
Rsync to CMU Andrew publishing and push to publish
RewriteEngine on
# match any directory
RewriteCond %{REQUEST_FILENAME} -d
# redirect somewhere instead of serving it
RewriteRule ^(.*)$ http://www.cs.cmu.edu/~taleahma/ [R,NC,L]
@turadg
turadg / gist:941550
Created April 26, 2011 00:35
Shim for HTML5 number input type
/* Requires:
* Modernizr <http://www.modernizr.com/>
* JQuery Numeric <http://www.texotela.co.uk/code/jquery/numeric/>
*/
// require numeric input even when HTML5 not available
if (!Modernizr.inputtypes.number) {
// no native support for <input type="number">
$("input[type=number]").numeric(false, function() { alert("Integers only"); this.value = ""; this.focus(); });
}