Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Milkins jasonm23

View GitHub Profile
View operate-on-word-at-point-or-region.el
(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 Aug 29, 2015
Recursive hash compact
View compact.rb
# 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
View nested_attributes_for_strategy.rb
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
View do-dns-update.rb
#!/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 Aug 29, 2015 — forked from anonymous/git-ignore
Use to quickly add patterns to .gitignore
View git-ignore
#!/bin/sh
# Install:
#
# copy to /usr/local/bin
#
# Usage:
#
# git ignore [[pattern] [pattern] [...]]
#
View .phoenix.litcoffee
View Questions.CoffeScript.md

CoffeeScript Developer Questionnaire

1. What will x be?

x = 0
x = 4 if a?

2. What will y be?

y = [10..1]
View README.md

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

View hosts.md

argentum

argentum-keyboard

argentum-trackpad

argentum-mouse

aurum

aurum-keyboard

aurum-trackpad

aurum-mouse

iridium

iridium-keyboard

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