Skip to content

Instantly share code, notes, and snippets.

View resolv.conf
# Hard-code DNS resolver to Google's servers
# *Setup*
# # download this file while DNS is working
# curl --output ~/google-resolv.conf
# # replace your old DNS resolver
# sudo cp /etc/resolv.conf /etc/ && sudo mv ~/google-resolv.conf /etc/resolv.conf
# # make it uneditable so Vagrant doesn't clobber it
# sudo chattr +i /etc/resolv.conf
turadg /
Last active Dec 22, 2015 — forked from hughsaunders/
Script to swap your Bluetooth devices connections between two Macs. Works great with to quickly switch your iMac between being a laptop monitor or full computer.
#!/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
turadg / application.rb
Last active May 14, 2019
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.
View application.rb
module MyApp
class Application < Rails::Application
require Rails.root + 'lib/custom_public_exceptions'
config.exceptions_app = Rails.public_path
turadg / subdomains.rb
Last active Oct 12, 2020 — forked from rtekie/subdomains.rb
Drop-in utility to test your app subdomains with Capybara, Rspec, and a Javascript driver (Poltergeist, Webkit, or Selenium)
View subdomains.rb
# 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)
# always resolves to
hostname = subdomain ? "#{subdomain}" : ""
Capybara.app_host = "http://#{hostname}"
turadg / poltergeist_screenshot_helper.rb
Last active Dec 15, 2015
Poltergeist screenshot helper for Rspec
View poltergeist_screenshot_helper.rb
# spec/support/poltergeist_screenshot_helper.rb
module PoltergeistScreenshotHelper
def snap!(options={})
path = options.fetch :path, "~/.Trash"
file = options.fetch :file, "#{}.png"
full = options.fetch :full, true
path = File.expand_path path
View levenshteinDistanceMixin
# usage _.levenshteinDistance("PART", "PARTY") or _("PART").levenshteinDistance("PARTY")
levenshtein : (str1, str2) ->
return str2.length if str1.length == 0
distance = []
for i in [0..str1.length]
distance[i] = []
distance[i][0] = i
turadg /
Last active Aug 9, 2018 — forked from sferik/
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
View Send Chrome to OmniFocus.scpt
-- based on post by iNik:
global theTitle, theTaskNote
set theTaskNote to ""
tell application "Google Chrome"
-- activate
tell window 1 to tell active tab
turadg / .htaccess
Created Sep 16, 2011
Rsync to CMU Andrew publishing and push to publish
View .htaccess
RewriteEngine on
# match any directory
RewriteCond %{REQUEST_FILENAME} -d
# redirect somewhere instead of serving it
RewriteRule ^(.*)$ [R,NC,L]
turadg / gist:941550
Created Apr 26, 2011
Shim for HTML5 number input type
View gist:941550
/* Requires:
* Modernizr <>
* 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(); });
You can’t perform that action at this time.