Skip to content

Instantly share code, notes, and snippets.

View jasonm23's full-sized avatar

Jason Milkins jasonm23

View GitHub Profile
(defun operate-on-point-or-region (fn)
"Get the current unspaced string at point, or the current region, if selected, and replace it with the return value of fn - an ordinary defun."
(let (pos1 pos2 meat)
(if (and transient-mark-mode mark-active)
(setq pos1 (region-beginning)
pos2 (region-end))
(setq pos1 (car (bounds-of-thing-at-point 'symbol))
pos2 (cdr (bounds-of-thing-at-point 'symbol))))
(setq meat (funcall fn (buffer-substring-no-properties pos1 pos2)))
(delete-region pos1 pos2)
@jasonm23
jasonm23 / compact.rb
Last active August 29, 2015 14:02
Recursive hash compact
# Recursive hash compact
def compact hash
p = ->(k,v){ (v.kind_of?(Hash) and v.keys.length > 0) ? (v.delete_if(&p);false) : (v.nil? or (v.kind_of?(Hash) and v.keys.length == 0)) }
hash.delete_if(&p)
end
class NestedAttributesForStrategy
def association(runner)
runner.run
end
def result(evaluation)
evaluation.object.tap do |instance|
evaluation.notify(:after_build, instance)
return attributes(instance)
end
#!/usr/bin/env ruby
require 'rubygems'
require 'digitalocean'
require 'yaml'
if ARGV.length < 2
puts "Usage:\n"
puts " do-dns-update domain subdomain\n\n"
exit
end
@jasonm23
jasonm23 / git-ignore
Last active August 29, 2015 14:02 — forked from anonymous/git-ignore
Use to quickly add patterns to .gitignore
#!/bin/sh
# Install:
#
# copy to /usr/local/bin
#
# Usage:
#
# git ignore [[pattern] [pattern] [...]]
#

CoffeeScript Developer Questionnaire

1. What will x be?

x = 0
x = 4 if a?

2. What will y be?

y = [10..1]

My modified fork of agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

Compatibility

function killjobs(){
for pid in $(jobs -p | cut -c8-13)
do
kill $pid
done
}

argentum

argentum-keyboard

argentum-trackpad

argentum-mouse

aurum

aurum-keyboard

aurum-trackpad

aurum-mouse

iridium

iridium-keyboard