Skip to content

Instantly share code, notes, and snippets.

View airblade's full-sized avatar

Andy Stewart airblade

View GitHub Profile
@airblade
airblade / private.xml
Last active November 30, 2017 10:14
Karabiner (not Karabiner-Elements)
<?xml version="1.0"?>
<root>
<item>
<name>Change Plus-minus key</name>
<appendix>Plusminus to underscore</appendix>
<identifier>private.plusminus_to_underscore_r</identifier>
<autogen>
__KeyToKey__
KeyCode::UK_SECTION, ModifierFlag::SHIFT_R,
==== start log session ====
0.000024 function gitgutter#process_buffer[10]..gitgutter#diff#run_diff[73]..gitgutter#utility#system[1]:
0.000024 cd /Users/cody && (git ls-files --error-unmatch .vimrc && (git -c "diff.autorefreshindex=0" diff --no-ext-diff --no-color -U0 -- .vimrc | grep --color=never -e '^@@ ' || exit 0))
==== start log session ====
0.000042 function gitgutter#process_buffer[10]..gitgutter#diff#run_diff[73]..gitgutter#utility#system[1]:
@airblade
airblade / shuffle.vim
Last active May 13, 2016 11:02
Shuffle a list in VimL
" Shuffles list in place.
function! Shuffle(list)
" Fisher-Yates-Durstenfeld-Knuth
let n = len(a:list)
for i in range(0, n-2)
let j = Random(0, n-i-1)
let e = a:list[i]
let a:list[i] = a:list[i+j]
let a:list[i+j] = e
endfor
@airblade
airblade / private.xml
Created January 6, 2016 15:02
Change § key to # via Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>Change Section key</name>
<appendix>Section to Hash</appendix>
<identifier>private.section_to_hash</identifier>
<autogen>
__KeyToKey__
KeyCode::DANISH_DOLLAR,
@airblade
airblade / copy_attachments.rb
Created November 10, 2015 11:01
Copies S3-stored Paperclip attachments from one AR model to another
# lib/paperclip/copy_attachments.rb
# Copies S3-stored Paperclip attachments from one AR model to another.
#
# This module should be mixed into the target AR model.
if Gem::Version.new(::AWS::VERSION) >= Gem::Version.new(2)
raise NotImplementedError, 'coded for aws-sdk v1'
end
@airblade
airblade / macvim.rb
Created December 11, 2014 14:50
Homebrew formula for MacVim with patches to bring MacVim's patchlevel up to 542.
require 'formula'
# Reference: https://github.com/b4winckler/macvim/wiki/building
class Macvim < Formula
homepage 'http://code.google.com/p/macvim/'
url 'https://github.com/b4winckler/macvim/archive/snapshot-73.tar.gz'
version '7.4-73'
sha1 'b87e37fecb305a99bc268becca39f8854e3ff9f0'
revision 1
@airblade
airblade / brew config
Created December 5, 2014 08:55
macvim failed to patch on 10.8.5
$ brew config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: db60d339c88b4021697d1857c0f4386596fb76e1
Last commit: 22 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit ivybridge
OS X: 10.8.5-x86_64
Xcode: 5.1.1
@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
@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 / sphinxsearch.conf
Created May 28, 2014 10:04
Upstart config for sphinx (sphinxsearch) v2.2.4.
# SphinxSearch Service
description "SphinxSearch Daemon"
author "Andrey Aksyonoff <shodan@sphinxsearch.com>"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]