Permalink
Browse files

more bin utils

  • Loading branch information...
1 parent 4d7b69f commit 77c28184cfe42ce9e94835f49d3c72cb6bc3376f @rishid committed Nov 7, 2011
Showing with 167 additions and 0 deletions.
  1. +10 −0 bin/backup
  2. +19 −0 bin/colordump
  3. +8 −0 bin/hide
  4. +3 −0 bin/latest-ack
  5. +6 −0 bin/trunc
  6. +56 −0 bin/webseq
  7. +30 −0 emacs.d/ibuffer.el
  8. +8 −0 emacs.d/indent.el
  9. +27 −0 emacs.d/init-color-theme.el
View
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ $# = 0 ] ; then
+ echo "usage: backup FILE ..."
+ echo "copy FILE(s) to FILE.bak"
+else
+ for f in "$@" ; do
+ cp -p "$f" "$f.bak"
+ done
+fi
View
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Usage: colordump
+# Dump 256 ansi colors to the terminal.
+
+printf "How each ANSI color is displayed on your terminal:\n\n"
+
+i=0
+row=0
+while [ $i -lt 255 ];
+do
+ newrow=$(expr $i / 10)
+ test $newrow -ne $row && printf "\n"
+ row=$newrow
+ printf "\e[%dm %03d \e[0m" $i $i
+ i=$(expr $i + 1)
+done
+
+printf '\n\n e.g., "\\e[41mTEXT\\e[0m" '
+printf "\e[41m(for TEXT like this)\e[0m\n"
View
@@ -0,0 +1,8 @@
+#!/bin/sh
+# hide file by putting a dot in front
+# usage: hide FILE [FILE]...
+set -e
+for f in "$@"
+do
+ mv -v "$f" $(dirname "$f")/.$(basename "$f")
+done
View
@@ -0,0 +1,3 @@
+#!/bin/sh -e
+curl http://betterthangrep.com/ack-standalone > ~/bin/ack
+chmod +x ~/bin/ack
View
@@ -0,0 +1,6 @@
+#!/bin/sh
+# usage: trunc FILE...
+# truncate files
+for f in "$@" ; do
+ cat < /dev/null > "$f"
+done
View
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+## Usage: webseq [-s|--style=<style>] <file>
+## Generate a sequence diagram from text in <file> using the
+## websequencediagrams.com API and write the result as a PNG
+## to standard output. If <file> is '-' or no <file> is specified,
+## read diagram description text from standard input.
+##
+## Use the --style argument to generate diagrams in any of the
+## following styles: default, earth, modern-blue, mscgen, omegapple,
+## qsd, rose, roundgreen, or napkin. The modern-blue style is used
+## by default.
+##
+## Example:
+## webseq --style=napkin awesome.seq > awesome.png
+require 'net/http'
+require 'uri'
+require 'open-uri'
+
+style = 'modern-blue'
+text = nil
+
+loop do
+ case ARGV[0]
+ when /--help/
+ puts File.read(__FILE__).grep(/^##/).map { |line| line[3...-1] }.join("\n")
+ exit 0
+ when /^--style=(.*)/
+ style = $1
+ ARGV.shift
+ next
+ when '--style', '-s'
+ style = ARGV[1]
+ 2.times { ARGV.shift }
+ next
+ else
+ text =
+ if ARGV[0] && $stdin.tty?
+ if File.exist?(ARGV[0])
+ File.read(ARGV[0])
+ else
+ open(ARGV[0], 'Accept' => 'text/plain').read
+ end
+ else
+ readlines.join
+ end
+ break
+ end
+end
+
+url = URI.parse('http://www.websequencediagrams.com/index.php')
+response = Net::HTTP.post_form(url, 'style' => style, 'message' => text)
+
+if response.body =~ /img: "(.+)"/
+ connection = open("http://www.websequencediagrams.com/#$1")
+ $stdout.write(connection.read)
+end
View
@@ -0,0 +1,30 @@
+;;; ibuffer.el --- Some helpful Ibuffer code
+;;
+
+(setq ibuffer-saved-filter-groups
+ (quote (("default"
+ ("perl" (mode . cperl-mode))
+ ("docs" (mode . pod-mode))
+ ("config" (name . "\\.conf$"))
+ ("gnus" (or
+ (mode . message-mode)
+ (mode . bbdb-mode)
+ (mode . mail-mode)
+ (mode . gnus-group-mode)
+ (mode . gnus-summary-mode)
+ (mode . gnus-article-mode)
+ (name . "^\\.bbdb$")
+ (name . "^\\.newsrc-dribble")))
+ ("emacs" (or
+ (name . "^\\*scratch\\*$")
+ (name . "^\\*Messages\\*$")
+ (mode . emacs-lisp-mode)))
+ ("dired" (mode . dired-mode))
+ ("erc" (mode . erc-mode))))))
+
+(add-hook 'ibuffer-mode-hook
+ (lambda ()
+ (ibuffer-switch-to-saved-filter-groups "default")))
+
+(provide 'ibuffer)
+;;; ibuffer.el ends here
View
@@ -0,0 +1,8 @@
+; spaces, not tabs
+(setq indent-tabs-mode nil)
+(setq-default indent-tabs-mode nil)
+
+; 4 spaces
+(setq default-tab-width 4)
+(setq tab-width 4)
+(setq backward-delete-char-untabify 4)
@@ -0,0 +1,27 @@
+;;; init-color-theme.el --- Define some custom functions
+;;
+
+;; use color theme...
+;(when (require 'color-theme)
+;(eval-after-load "color-theme"
+; '(progn
+; (color-theme-initialize)
+; (color-theme-almost-monokai))))
+
+(autoload 'color-theme-almost-monokai "color-theme-almost-monokai" nil t)
+(setq color-theme-is-global nil)
+
+;; this is for normal startup
+(when (eq (window-system) 'x)
+ (color-theme-almost-monokai))
+
+;; this is for creating new emacsclient frames
+(add-hook
+ 'after-make-frame-functions
+ (lambda (frame)
+ (when (eq (window-system frame) 'x)
+ (select-frame frame)
+ (color-theme-almost-monokai))))
+
+(provide 'init-color-theme)
+;;; init-color-theme.el ends here

0 comments on commit 77c2818

Please sign in to comment.