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:
# 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 |
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:
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:
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:
;; 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) |