Skip to content

Instantly share code, notes, and snippets.

@turadg
turadg / README.md
Created April 1, 2015 16:01
Retracked draft

Retracked wraps your event recording system in an API optimized for React components.

Usage

Setup

Somewhere early in execution:

# set the recording function
retracked.setup(myTrackingSystem.push);
@turadg
turadg / designer.html
Created July 28, 2014 11:26
designer
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/iconsets/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<polymer-element name="my-element">
<template>
@turadg
turadg / resolv.conf
Last active October 29, 2022 22:53
# Hard-code DNS resolver to Google's servers
#
# *Setup*
# # download this file while DNS is working
# curl https://gist.github.com/turadg/7876784/raw --output ~/google-resolv.conf
# # replace your old DNS resolver
# sudo cp /etc/resolv.conf /etc/resolv.conf.auto && sudo mv ~/google-resolv.conf /etc/resolv.conf
# # make it uneditable so Vagrant doesn't clobber it
# sudo chattr +i /etc/resolv.conf
@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 / application.rb
Last active May 14, 2019 06:04
Handle only 404s dynamically. It uses a normal controller and route for 404s, letting everything else go to the Rails default /public error pages. In my case it was to use the subdomain logic in my ApplicationController.
module MyApp
class Application < Rails::Application
require Rails.root + 'lib/custom_public_exceptions'
config.exceptions_app = CustomPublicExceptions.new Rails.public_path
end
end
@turadg
turadg / subdomains.rb
Last active January 21, 2024 19:45 — forked from rtekie/subdomains.rb
Drop-in utility to test your app subdomains with Capybara, Rspec, and a Javascript driver (Poltergeist, Webkit, or Selenium)
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
# (e.g. save as spec/support/subdomains.rb)
def switch_to_subdomain(subdomain)
# lvh.me always resolves to 127.0.0.1
hostname = subdomain ? "#{subdomain}.lvh.me" : "lvh.me"
Capybara.app_host = "http://#{hostname}"
end
@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
@turadg
turadg / install-ruby-2.0.0.sh
Last active August 9, 2018 06:58 — forked from sferik/install-ruby-2.0.0.sh
Install Ruby 2.0 with Readline and latest OpenSSL
#!/usr/bin/env sh
brew update
# upgrade any that were already installed
brew upgrade rbenv ruby-build readline openssl
# install what's missing
brew install rbenv ruby-build readline openssl
@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