<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: unix code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 06:16:21 GMT</pubDate>
    <description>DZone Snippets: unix code</description>
    <item>
      <title>Inspect a website like a string in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5745</link>
      <description>Put the following function into your ~/.bash_login (or alternatives).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;unset -f inspect_url&lt;br /&gt;&lt;br /&gt;function inspect_url() { &lt;br /&gt;   /usr/bin/curl -L -s --max-time 10 "${@}" | ruby -n -e 'p $_.to_s'&lt;br /&gt;   return 0&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;inspect_url http://www.ruby-forum.com&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 09 Jul 2008 21:13:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5745</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Compile &amp; install Nginx web server</title>
      <link>http://snippets.dzone.com/posts/show/5668</link>
      <description>Requirement on Mac OS X: &lt;a href="http://developer.apple.com/tools/xcode/index.html"&gt;Xcode&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# See:&lt;br /&gt;# - http://en.wikipedia.org/wiki/Nginx&lt;br /&gt;# - http://wiki.codemongers.com/NginxGettingStarted&lt;br /&gt;# - http://wiki.codemongers.com/NginxInstallOptions&lt;br /&gt;# - http://wiki.codemongers.com/NginxCommandLine&lt;br /&gt;# - http://wiki.codemongers.com/NginxConfiguration&lt;br /&gt;&lt;br /&gt;export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"&lt;br /&gt;&lt;br /&gt;mkdir -p ~/Desktop/Nginx&lt;br /&gt;cd ~/Desktop/Nginx&lt;br /&gt;&lt;br /&gt;curl -L -O http://sysoev.ru/nginx/nginx-0.7.2.tar.gz&lt;br /&gt;tar -xzf nginx-0.7.2.tar.gz&lt;br /&gt;&lt;br /&gt;curl -L -O http://downloads.sourceforge.net/pcre/pcre-7.7.tar.gz&lt;br /&gt;tar -xzf pcre-7.7.tar.gz&lt;br /&gt;&lt;br /&gt;cd ~/Desktop/Nginx/nginx-0.7.2&lt;br /&gt;./configure --help&lt;br /&gt;./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin --with-debug --with-http_ssl_module --with-pcre=../pcre-7.7&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;which nginx&lt;br /&gt;otool -L /usr/local/sbin/nginx&lt;br /&gt;open /usr/local/nginx&lt;br /&gt;open -e /usr/local/nginx/conf/nginx.conf&lt;br /&gt;&lt;br /&gt;nginx -v&lt;br /&gt;nginx -V&lt;br /&gt;sudo nginx   # start server&lt;br /&gt;sudo nginx -t&lt;br /&gt;&lt;br /&gt;open http://localhost:80&lt;br /&gt;open http://localhost:80/50x.html&lt;br /&gt;&lt;br /&gt;sudo nano /usr/local/nginx/conf/nginx.conf   # editing ... server {  listen  8080; ... &lt;br /&gt;&lt;br /&gt;# reload configuration&lt;br /&gt;sudo kill -HUP `cat /usr/local/nginx/logs/nginx.pid`  &lt;br /&gt;&lt;br /&gt;# stop server&lt;br /&gt;sudo kill -15 $(ps -auxxx | egrep "[n]ginx.*master" | awk '{ print $2 }') 2&gt;/dev/null&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 18 Jun 2008 20:03:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5668</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Shell script to make lists of certain file types in a web site file system</title>
      <link>http://snippets.dzone.com/posts/show/5564</link>
      <description>mkdir file_lists&lt;br /&gt;find . -name '*.pdf' -o -name '*.PDF' &gt; ./file_lists/all_pdf_files.txt &lt;br /&gt;find . -name '*.pdf' -o -name '*.PDF' -mtime +365 &gt; ./file_lists/pdf_files_mtime_gt_1yr.txt&lt;br /&gt;&lt;br /&gt;find . -name '*.jpg' -o -name '*.JPG' -o -name '*.gif'  -o -name '*.GIF' -o -name '*.png' -o -name '*.PNG' &gt; ./file_lists/all_image_files.txt &lt;br /&gt;&lt;br /&gt;find . -name '*.log' -o -name '*.LOG' &gt; ./file_lists/all_log_files.txt&lt;br /&gt;&lt;br /&gt;find . -name '*.css' -o -name '*.CSS' -o -name '*.js'  -o -name '*.JS' &gt; ./file_lists/all_design_assets_files.txt &lt;br /&gt;&lt;br /&gt;find . -name '*.ram' -o -name '*.RAM' -o -name '*.aif'  -o -name '*.AIF' -o -name '*.mp3' -o -name '*.MP3' &gt; ./file_lists/all_audio_files.txt&lt;br /&gt;find . -name '*.ram' -o -name '*.RAM' -o -name '*.aif'  -o -name '*.AIF' -o -name '*.mp3' -o -name '*.MP3' -mtime +365 &gt; ./file_lists/audio_files_mtime_gt_1yr.txt &lt;br /&gt;&lt;br /&gt;find . -name '*.html' -o -name '*.HTML' -o -name '*.htm'  -o -name '*.HTM' &gt; ./file_lists/all_html_files.txt &lt;br /&gt;find . -name '*.html' -o -name '*.HTML' -o -name '*.htm'  -o -name '*.HTM' -mtime +365 &gt; ./file_lists/html_files_mtime_gt_1yr.txt</description>
      <pubDate>Sat, 31 May 2008 20:00:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5564</guid>
      <author>johnloy (John Loy)</author>
    </item>
    <item>
      <title>Inplace substitutions</title>
      <link>http://snippets.dzone.com/posts/show/5551</link>
      <description>Place all occurrences of "old value" with "new value" in all txt files.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ruby -p -i -e '$_.gsub!("old value", "new value")' *.txt&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 28 May 2008 07:52:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5551</guid>
      <author>remvee (Remco van 't Veer)</author>
    </item>
    <item>
      <title>One-line web server in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5424</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;br /&gt;# From: http://www.ntecs.de/blog/articles/2008/02/09/the-worlds-smallest-webserver&lt;br /&gt;# Author: Michael Neumann&lt;br /&gt;# ... point your browser to http://localhost:3125/etc/motd&lt;br /&gt;&lt;br /&gt;ruby -rsocket -e 's=TCPServer.new(5**5);loop{_=s.accept;_&lt;&lt;"HTTP/1.0 200 OK\r\n\r\n#{File.read(_.gets.split[1])rescue nil}";_.close}'&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 23 Apr 2008 13:22:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5424</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>process email files like unix find</title>
      <link>http://snippets.dzone.com/posts/show/5248</link>
      <description>I call this program whitelist. It lets you run a command on a bunch of files depending on whether the file is an email and has a from address in a whitelist.&lt;br /&gt;&lt;br /&gt;It's useful for maintaining whitelisted mailboxes and analysing mailboxes. With a few more tests it might be a generically useful tool.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/python&lt;br /&gt;# Copyright (C) 2008 by Tapsell-Ferrier Limited&lt;br /&gt;&lt;br /&gt;# This program is free software; you can redistribute it and/or modify&lt;br /&gt;# it under the terms of the GNU General Public License as published by&lt;br /&gt;# the Free Software Foundation; either version 2, or (at your option)&lt;br /&gt;# any later version.&lt;br /&gt;&lt;br /&gt;# This program is distributed in the hope that it will be useful,&lt;br /&gt;# but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;# GNU General Public License for more details.&lt;br /&gt;&lt;br /&gt;# You should have received a copy of the GNU General Public License&lt;br /&gt;# along with this program; see the file COPYING.  If not, write to the&lt;br /&gt;# Free Software Foundation, Inc.,   51 Franklin Street, Fifth Floor,&lt;br /&gt;# Boston, MA  02110-1301  USA&lt;br /&gt;&lt;br /&gt;import commands&lt;br /&gt;import email.Parser&lt;br /&gt;import sys&lt;br /&gt;import re&lt;br /&gt;import getopt&lt;br /&gt;import os&lt;br /&gt;import os.path&lt;br /&gt;&lt;br /&gt;try:&lt;br /&gt;    from email.utils import parseaddr&lt;br /&gt;except:&lt;br /&gt;    from rfc822 import parseaddr&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def help():&lt;br /&gt;    print """whitelist.py -h&lt;br /&gt;whitelist.py [-v] [-f whitelist filename] command ; filelist [-]&lt;br /&gt;&lt;br /&gt;Execute the specified command (which must be shell escaped if calling&lt;br /&gt;from shell) on all the files in the filelist or, if - is present in&lt;br /&gt;the filelist, read from stdin (like xargs) whenever the file is an&lt;br /&gt;email that contains a from address specified in the whitelist.&lt;br /&gt;&lt;br /&gt;Like xargs, or find, the command can include {} as a replacement token&lt;br /&gt;for the matched filename.&lt;br /&gt;&lt;br /&gt;The command can also be a header reference, for example:&lt;br /&gt;&lt;br /&gt;  $FROM&lt;br /&gt;&lt;br /&gt;will print the specified mails From address.&lt;br /&gt;&lt;br /&gt;Options:&lt;br /&gt;&lt;br /&gt; -v   specifies that the test is to be negated, executing the action if&lt;br /&gt;      the file does NOT contain a from address in the whiltelist.&lt;br /&gt;&lt;br /&gt; -f   specifies a whitelist, the default is $HOME/.addresses&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;&lt;br /&gt; whitelist.py -f .wlist wc \{} \: maildir/cur/*&lt;br /&gt;&lt;br /&gt;runs wc on each file in maildir/cur with a FROM address matching&lt;br /&gt;something in the whitelist; or:&lt;br /&gt;&lt;br /&gt; find maildir/INBOX/cur -type f | whitelist.py -v mv \{} mailbox/TRASH/cur \; -&lt;br /&gt;&lt;br /&gt;mv's all files in the INBOX with FROMs not matching the whitelist into&lt;br /&gt;a TRASH folder.&lt;br /&gt;&lt;br /&gt;  find maildir/Greylist/new -type f | whitelist.py -v $TO \; -&lt;br /&gt;&lt;br /&gt;displays the TO address of all messages where the from didn't match&lt;br /&gt;the whitelist.&lt;br /&gt;"""&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def read_whitelisted(filename):&lt;br /&gt;    fd = open(filename)&lt;br /&gt;    data = fd.read()&lt;br /&gt;    fd.close()&lt;br /&gt;    return data.split()&lt;br /&gt;&lt;br /&gt;def get_msg(filename):&lt;br /&gt;    fd = open(filename)&lt;br /&gt;    try:&lt;br /&gt;        msg = email.Parser.HeaderParser().parse(fd, True)&lt;br /&gt;        return msg&lt;br /&gt;    finally:&lt;br /&gt;        fd.close()&lt;br /&gt;&lt;br /&gt;action_re = re.compile("\{}")&lt;br /&gt;&lt;br /&gt;def handle(filenames_fn, action, whitelist, negate=False):&lt;br /&gt;    for filename in filenames_fn():&lt;br /&gt;        msg = get_msg(filename)&lt;br /&gt;        realname, addr = parseaddr(msg["from"])&lt;br /&gt;        result = addr in whitelist&lt;br /&gt;&lt;br /&gt;        if negate:&lt;br /&gt;            result = not result&lt;br /&gt;&lt;br /&gt;        if result:&lt;br /&gt;            try:&lt;br /&gt;                m = re.match("\$(.+)", action)&lt;br /&gt;                result = msg[m.group(1)]&lt;br /&gt;            except Exception:&lt;br /&gt;                cmd_str = action_re.sub(filename, action)&lt;br /&gt;                os.system(cmd_str)&lt;br /&gt;            else:&lt;br /&gt;                print result&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def main(args):&lt;br /&gt;    negate = False&lt;br /&gt;    whitelist_filename = os.path.join(os.environ["HOME"], ".addresses")&lt;br /&gt;    opts, args = getopt.getopt(args, "hv")&lt;br /&gt;    for o,a in opts:&lt;br /&gt;        if o == "-h":&lt;br /&gt;            help()&lt;br /&gt;            sys.exit(0)&lt;br /&gt;&lt;br /&gt;        elif o == "-v":&lt;br /&gt;            negate = True&lt;br /&gt;&lt;br /&gt;        elif o == "-f":&lt;br /&gt;            whitelist_filename = a&lt;br /&gt;&lt;br /&gt;    if not os.access(whitelist_filename, os.F_OK):&lt;br /&gt;        print &gt;&gt;sys.stderr, "whitelist.py   -  no whitelist filename\n"&lt;br /&gt;        help()&lt;br /&gt;        sys.exit(1)&lt;br /&gt;&lt;br /&gt;    cmdstr = " ".join(args)&lt;br /&gt;    m = re.match("(.*) ;([ ]*.*)", cmdstr)&lt;br /&gt;    if not m:&lt;br /&gt;        sys.exit(1)&lt;br /&gt;&lt;br /&gt;    cmd = m.group(1)&lt;br /&gt;    files = m.group(2).strip().split(" ")&lt;br /&gt;&lt;br /&gt;    def ffn():&lt;br /&gt;        for f in files:&lt;br /&gt;            if f == "-":&lt;br /&gt;                for innerf in sys.stdin:&lt;br /&gt;                    yield innerf.strip()&lt;br /&gt;            else:&lt;br /&gt;                yield f&lt;br /&gt;        return&lt;br /&gt;&lt;br /&gt;    whitelist = read_whitelisted(whitelist_filename)&lt;br /&gt;    handle(ffn, cmd, whitelist, negate)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if __name__ == "__main__":&lt;br /&gt;    main(sys.argv[1:])&lt;br /&gt;&lt;br /&gt;# End&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 18 Mar 2008 16:54:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5248</guid>
      <author>nicferrier (Nic Ferrier)</author>
    </item>
    <item>
      <title>Morse decode using sed</title>
      <link>http://snippets.dzone.com/posts/show/5144</link>
      <description>This is a short &lt;a href="http://en.wikipedia.org/wiki/Morse_code"&gt;Morse code&lt;/a&gt; decoder written as a shellscript using &lt;a href="http://en.wikipedia.org/wiki/Sed"&gt;sed&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The Morse coded text should be in $text, and should be written with spaces between the letters.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;echo $text\  | tr . 0 | sed -e {s/0----\ /1/g} -e {s/00---\ /2/g} -e {s/000--\ /3/g} -e {s/000-\ /4/g} -e {s/00000\ /5/g} -e {s/-0000\ /6/g} -e {s/--000\ /7/g} -e {s/---00\ /8/g} -e {s/----0\ /9/g} -e {s/-----\ /0/g} \&lt;br /&gt;	| sed -e {s/-0-0\ /c/g} -e {s/-000\ /b/g} -e {s/00-0\ /f/g} -e {s/0000\ /h/g} -e {s/0---\ /j/g} -e {s/0-00\ /l/g} -e {s/0--0\ /p/g} -e {s/--0-\ /q/g} -e {s/000-\ /v/g} -e {s/-00-\ /x/g} -e {s/-0--\ /y/g} -e {s/--00\ /z/g} \&lt;br /&gt;	| sed -e {s/0--\ /w/g} -e {s/-00\ /d/g} -e {s/--0\ /g/g} -e {s/-0-\ /k/g} -e {s/---\ /o/g} -e {s/0-0\ /r/g} -e {s/000\ /s/g} -e {s/00-\ /u/g} \&lt;br /&gt;	| sed -e {s/0-\ /a/g} -e {s/00\ /i/g} -e {s/--\ /m/g} -e {s/-0\ /n/g} \&lt;br /&gt;	| sed -e {s/0\ /e/g} -e {s/-\ /t/g}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 15 Feb 2008 13:54:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5144</guid>
      <author>scvalex (Alexandru Scvortov)</author>
    </item>
    <item>
      <title>Untill keypressed / conio.h</title>
      <link>http://snippets.dzone.com/posts/show/5030</link>
      <description>Turbo Pascal and conio.h allowed immediate character reading, without wainting for enter. Following code does the same under unix terminals:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;termios.h&gt;&lt;br /&gt;&lt;br /&gt;char getch(void) {&lt;br /&gt;        char buf = 0;&lt;br /&gt;        struct termios old = {0};&lt;br /&gt;        if (tcgetattr(0, &amp;old) &lt; 0)&lt;br /&gt;                perror("tcsetattr()");&lt;br /&gt;        old.c_lflag &amp;= ~ICANON;&lt;br /&gt;        old.c_lflag &amp;= ~ECHO;&lt;br /&gt;        old.c_cc[VMIN] = 1;&lt;br /&gt;        old.c_cc[VTIME] = 0;&lt;br /&gt;        if (tcsetattr(0, TCSANOW, &amp;old) &lt; 0)&lt;br /&gt;                perror("tcsetattr ICANON");&lt;br /&gt;        if (read(0, &amp;buf, 1) &lt; 0)&lt;br /&gt;                perror ("read()");&lt;br /&gt;        old.c_lflag |= ICANON;&lt;br /&gt;        old.c_lflag |= ECHO;&lt;br /&gt;        if (tcsetattr(0, TCSADRAIN, &amp;old) &lt; 0)&lt;br /&gt;                perror ("tcsetattr ~ICANON");&lt;br /&gt;        return (buf);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;        char key;&lt;br /&gt;        printf("Press 'x' to exit...\n");&lt;br /&gt;        while((key=getch()) &amp;&amp; (key != 'x'))&lt;br /&gt;                printf ("you pressed %c\n", key);&lt;br /&gt;        return(0);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 23 Jan 2008 03:29:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5030</guid>
      <author>ptr128 (Mariusz)</author>
    </item>
    <item>
      <title>Unix Console Styler</title>
      <link>http://snippets.dzone.com/posts/show/4822</link>
      <description>This modue can be used to apply many style on Unix* terminals&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# Unix Console Style&lt;br /&gt;# You can use this module to apply a style on the terminal&lt;br /&gt;#&lt;br /&gt;# &lt;b&gt;DON'T WORK ON WINDOWS (Only on *nix Terminal)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;module UnixConsoleStyler&lt;br /&gt;  class StyleNotFoundException &lt; Exception; end&lt;br /&gt;  &lt;br /&gt;  # Availables Styles&lt;br /&gt;  STYLE = {&lt;br /&gt;      :default    =&gt;    "\033[0m",&lt;br /&gt;    	# styles&lt;br /&gt;    	:bold       =&gt;    "\033[1m",&lt;br /&gt;    	:underline  =&gt;    "\033[4m",&lt;br /&gt;    	:blink      =&gt;    "\033[5m",&lt;br /&gt;    	:reverse    =&gt;    "\033[7m",&lt;br /&gt;    	:concealed  =&gt;    "\033[8m",&lt;br /&gt;    	# font colors&lt;br /&gt;    	:black      =&gt;    "\033[30m", &lt;br /&gt;    	:red        =&gt;    "\033[31m",&lt;br /&gt;    	:green      =&gt;    "\033[32m",&lt;br /&gt;    	:yellow     =&gt;    "\033[33m",&lt;br /&gt;    	:blue       =&gt;    "\033[34m",&lt;br /&gt;    	:magenta    =&gt;    "\033[35m",&lt;br /&gt;    	:cyan       =&gt;    "\033[36m",&lt;br /&gt;    	:white      =&gt;    "\033[37m",&lt;br /&gt;    	# background colors&lt;br /&gt;    	:on_black   =&gt;    "\033[40m", &lt;br /&gt;    	:on_red     =&gt;    "\033[41m",&lt;br /&gt;    	:on_green   =&gt;    "\033[42m",&lt;br /&gt;    	:on_yellow  =&gt;    "\033[43m",&lt;br /&gt;    	:on_blue    =&gt;    "\033[44m",&lt;br /&gt;    	:on_magenta =&gt;    "\033[45m",&lt;br /&gt;    	:on_cyan    =&gt;    "\033[46m",&lt;br /&gt;    	:on_white   =&gt;    "\033[47m" }&lt;br /&gt;  &lt;br /&gt;  # Methods to use if you want to apply a style&lt;br /&gt;  def UnixConsoleStyler::apply_style(style)&lt;br /&gt;    if STYLE.has_key? style&lt;br /&gt;      STDOUT.write STYLE[style]&lt;br /&gt;    else&lt;br /&gt;      raise StyleNotFoundException, "Style #{style} not found"&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 28 Nov 2007 19:21:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4822</guid>
      <author>kedare (Mathieu Poussin)</author>
    </item>
    <item>
      <title>Unix shell script providing Ruby on Rails enhanced String methods</title>
      <link>http://snippets.dzone.com/posts/show/4793</link>
      <description>Assuming you have Rails installed as a gem, the following Unix shell script (which I named String, but you can name anything you want when you save the following into a file) allows you to call Ruby String methods (including, importantly, the methods that the Rails ActiveSupport extensions add) on an arbitrary number of arguments, and it will print out the results, e.g.,&lt;br /&gt;&lt;br /&gt;$ String camelize snake_case_example another_snake_case_example&lt;br /&gt;&lt;br /&gt;The output is:&lt;br /&gt;&lt;br /&gt;SnakeCaseExample&lt;br /&gt;AnotherSnakeCaseExample&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;&lt;br /&gt;if ARGV.size &gt; 1 then&lt;br /&gt;  gem 'activesupport'&lt;br /&gt;  require 'active_support/core_ext/string/inflections'&lt;br /&gt;&lt;br /&gt;  class String&lt;br /&gt;    include ActiveSupport::CoreExtensions::String::Inflections&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  command = ARGV.shift&lt;br /&gt;  ARGV.each { |argument|&lt;br /&gt;    puts argument.send( command )&lt;br /&gt;  }&lt;br /&gt;else&lt;br /&gt;  # Print usage information&lt;br /&gt;  puts "Usage: #{File.basename( __FILE__ )} &lt;command&gt; &lt;argument_1&gt; [&lt;argument_2&gt; ...]"&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 18 Nov 2007 04:49:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4793</guid>
      <author>HotFusionMan (Al Chou)</author>
    </item>
  </channel>
</rss>
