Skip to content

Instantly share code, notes, and snippets.

View mattsears's full-sized avatar
👋
Hello friend

Matt Sears mattsears

👋
Hello friend
View GitHub Profile
# A handy way to display lists from collection
def list(stuff, options = {}, &block)
return content_tag(:p, "None") if stuff.nil? || stuff.empty?
content_tag(:ul, stuff.map { |thingie| content_tag(:li, yield(thingie)) }, options)
end
# Bash Completions for SSH known_hosts and config hosts
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
complete -W "$(echo `cat ~/.ssh/config | cut -f1,2 -d ' ' | sed -e 's/Host[^s+]//g; s/^ *//; s/ *$//; /#.*/d' -e '/^$/d' | uniq`;)" ssh
@mattsears
mattsears / README.md
Created August 21, 2011 20:01
Diff.rb: CodeBrawl's "Ruby diffs" entry (http://codebrawl.com/contests/ruby-diffs)

Diff.rb

A simple diff utility written in Ruby. It works with single or multi-line strings and returns an array of hashes that indicates the line number affected and change: added, deleted, or same.

Example:

@mattsears
mattsears / README.md
Created September 5, 2011 07:41
Gittr: A Git key/value store

Gittr.rb

Git as a key-value store! Build with Grit, it supports SET, GET, KEYS, and DELETE operations. In addition, we can also get the change history of key/values.

And since it's Git, we can easily enhance it to include other awesome Git features such as branches, diffs, reverting, and more!

Example:

@mattsears
mattsears / README.md
Created September 19, 2011 13:43
Colr: A color selector tool

Colr.rb

Colr selects colors based on hue calculations. It knows nothing about the image before initialization and works with any valid HTML color: red, green, aqua, brown, etc.

Colr allows you to adjust the tolerance and hue settings so you can select colors from any image!

Example:

@mattsears
mattsears / README.md
Created October 3, 2011 13:16
Todo.rb: A simple command-line TODO manager written in Ruby

Todo.rb

Todo.rb is a simple command-line tool for managing todos. It's minimal, straightforward, and you can use it with your favorite text editor.

Getting Started

Todo.rb doesn't require any third-party gems so you can copy the file anywhere and use it as long as it's executable:

;; This function will open Marked.app and monitor the current markdown document
;; for anything changes. In other words, it will live reload and convert the
;; markdown documment
(defun markdown-preview-file ()
"run Marked on the current file and revert the buffer"
(interactive)
(shell-command
(format "open -a /Applications/Marked.app %s"
(shell-quote-argument (buffer-file-name))))
)
(defun iwb ()
"indent whole buffer"
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))
defmodule Fizzbuzz do
def of(num) do
cond do
rem(num, 15) == 0 -> "FizzBuzz"
rem(num, 5) == 0 -> "Buzz"
rem(num, 3) == 0 -> "Fizz"
true -> num
end
end
end
;;----------------------------------------------------------------------------
;; Autocomplete all the things
;;----------------------------------------------------------------------------
(use-package auto-complete
:init
(progn
(ac-config-default)
(setq ac-ignore-case nil)
(add-to-list 'ac-modes 'ruby-mode)