<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Fak3r's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 03:27:44 GMT</pubDate>
    <description>DZone Snippets: Fak3r's Code Snippets</description>
    <item>
      <title>Populate titlebar in any term</title>
      <link>http://snippets.dzone.com/posts/show/4175</link>
      <description>Populate your titlebar in any term with some useful info such as uname -a, architecture, if you're ROOT or not, etc.  In Linux:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;HOST_NAME=`hostname -f`&lt;br /&gt;if [ `id -u` = 0 ]; then&lt;br /&gt;OPT=&#8221;`uname` (`uname -a | cut -f12 -d&#8217; &#8216; -`) - ROOT USER&#8221;&lt;br /&gt;else&lt;br /&gt;OPT=&#8221;`uname` (`uname -a | cut -f12 -d&#8217; &#8216; -`)&#8221;&lt;br /&gt;fi&lt;br /&gt;REPLACE=&#8221;${HOST_NAME} - ${OPT}&#8221;&lt;br /&gt;echo -n -e &#8220;\033]0; $REPLACE \007 &#8220;&lt;br /&gt;echo &#8220;${REPLACE}&#8221;&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then run this script, and your termtitle will be something like the following:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Servername (Linux / x86_64).&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;For Solaris it needs to be done a bit differently:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/local/bin/bash&lt;br /&gt;HOST_NAME=`uname -a | cut -f2 -d&#8217; &#8216; -`&lt;br /&gt;OPT=&#8221;(`uname -a | cut -f1 -d&#8217; &#8216; -` / `uname -a | cut -f6 -d&#8217; &#8216;`)&#8221;&lt;br /&gt;REPLACE=&#8221;${HOST_NAME} - ${OPT}&#8221;&lt;br /&gt;echo -n -e &#8220;\033]0; $REPLACE \007 &#8220;&lt;br /&gt;echo &#8220;${REPLACE}&#8221;&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Add/remove things from the OPT= line to customize.  To test it, just issue the command on the commandline without the ()'s to see what it'll look like.</description>
      <pubDate>Wed, 20 Jun 2007 18:28:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4175</guid>
      <author>fak3r (fak3r)</author>
    </item>
    <item>
      <title>Remove comments from a file</title>
      <link>http://snippets.dzone.com/posts/show/4174</link>
      <description>Remove all comment lines from a file.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sed -e '/^#/d' $1 | more&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;or to output it to a new file&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sed -e '/^#/d' $1 &gt; $1.nocomments&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 18:24:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4174</guid>
      <author>fak3r (fak3r)</author>
    </item>
    <item>
      <title>Simple mySQL backup script for cron</title>
      <link>http://snippets.dzone.com/posts/show/4172</link>
      <description>Simple mySQL backup script for cron - backs up all databases, saves the last 4 copies.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;# modify the following to suit your environment&lt;br /&gt;export DB_BACKUP="/backup/mysql_backup"&lt;br /&gt;export DB_USER="root"&lt;br /&gt;export DB_PASSWD="********"&lt;br /&gt;&lt;br /&gt;# title and version&lt;br /&gt;echo ""&lt;br /&gt;echo "mySQL_backup"&lt;br /&gt;echo "----------------------"&lt;br /&gt;echo "* Rotating backups..."&lt;br /&gt;rm -rf $DB_BACKUP/04&lt;br /&gt;mv $DB_BACKUP/03 $DB_BACKUP/04&lt;br /&gt;mv $DB_BACKUP/02 $DB_BACKUP/03&lt;br /&gt;mv $DB_BACKUP/01 $DB_BACKUP/02&lt;br /&gt;mkdir $DB_BACKUP/01 &lt;br /&gt;&lt;br /&gt;echo "* Creating new backup..."&lt;br /&gt;mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases | bzip2 &gt; $DB_BACKUP/01/mysql-`date +%Y-%m-%d`.bz2&lt;br /&gt;echo "----------------------"&lt;br /&gt;echo "Done"&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 15:01:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4172</guid>
      <author>fak3r (fak3r)</author>
    </item>
  </channel>
</rss>
