Skip to content

Instantly share code, notes, and snippets.

View airblade's full-sized avatar

Andy Stewart airblade

View GitHub Profile
@airblade
airblade / gist:2988877
Created June 25, 2012 14:11
Monkey-patch enabling Rails 3.0 - 3.1 to use SMTP over SSL
# config/initializers/email.rb
require 'mail'
# Monkey-patch Mail to support SSL, which Fastmail mandates by 30 June 2012.
#
# Mail introduced SSL support in v2.4.0.
# Rails / ActionMailer doesn't use that version of Mail until Rails 3.2.0.
#
@airblade
airblade / gist:2988937
Created June 25, 2012 14:21
Monkey-patch enabling Rails 2.3 to use SMTP over SSL
# config/initializers/email.rb
# Monkey-patch to enable ActionMailer to send STMP email over SSL.
# Necessitated by Fastmail mandating SSL by 30 June 2012.
module ActionMailer
class Base
def perform_delivery_smtp(mail)
destinations = mail.destinations
mail.ready_to_send
(*
# DESCRIPTION #
This script files the selected Mail messages to the specified folder (Action, by default).
# LICENSE #
Created by Dan Byler (contact: [email protected]); released as public domain.
@airblade
airblade / gist:4713705
Created February 5, 2013 10:53
Typhoeus example.
require 'typhoeus'
class ImageDownloader
# Returns an array of images at the given `urls`.
# Each element is either a StringIO representation of an image
# or nil if the image could not be downloaded for any reason.
#
# Params:
# urls - an array of URLs pointing to images
-- See article here: http://daringfireball.net/2007/07/simple_inbox_sweeper
-- The following should be one long line:
set _description to "All unflagged, read messages in each IMAP account
inbox will be moved to the “Archive” mailbox corresponding to that
account. This action is not undoable."
tell application "Mail"
display alert "Archive read messages from IMAP inboxes?" buttons ¬
{"Cancel", "Archive"} cancel button 1 message _description
@airblade
airblade / private.xml
Created August 8, 2013 09:50
Easier access to umlauts and sharp-s on OSX using KeyRemap4MacBook
<?xml version="1.0"?>
<root>
<item>
<name>Easier umlauts</name>
<appendix>Use left-control + vowel</appendix>
<identifier>private.easier_umlauts</identifier>
<autogen>
__KeyToKey__
KeyCode::A, ModifierFlag::CONTROL_L | ModifierFlag::SHIFT_L,
@airblade
airblade / gist:10651609
Last active February 20, 2018 22:57
Vim testing frameworks

In no particular order:

  • vroom

    • uses vim as a server
    • implemented in python
    • tests written in custom syntax
  • vimrunner

    • uses vim as a server
  • implemented in ruby

@airblade
airblade / sphinxsearch.conf
Created May 28, 2014 10:04
Upstart config for sphinx (sphinxsearch) v2.2.4.
# SphinxSearch Service
description "SphinxSearch Daemon"
author "Andrey Aksyonoff <[email protected]>"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@airblade
airblade / gist:f78946ed45ac10011ef8
Last active February 4, 2020 12:44
Vim highlight groups

Changing attributes on a group linked to another disconnects the link

Link a highlight group to another.

:hi link Foo Comment

:hi Foo
Foo  xxx links to Comment
@airblade
airblade / prepare-commit-msg
Created November 3, 2014 14:57
Git prepare-commit-msg hook to extract issue number from branch name and append to commit message.
#!/bin/bash
# Adds reference to GitHub issue if available in branch name.
# The issue number should be at the end of the branch name, following
# a hyphen.
# Only proceed if no second parameter is given to the script.
if [ x = x${2} ]; then
branch=$(git symbolic-ref --short HEAD)
if [[ $branch =~ .*-([0-9]+)$ ]]; then