<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Jmcvetta's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 07:21:35 GMT</pubDate>
    <description>DZone Snippets: Jmcvetta's Code Snippets</description>
    <item>
      <title>WWAN Dialer</title>
      <link>http://snippets.dzone.com/posts/show/5484</link>
      <description>This script dials the built-in Verizon WWAN (mobile broadband) modem on my Thinkpad T61.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;#&lt;br /&gt;# Dial the WWAN&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;hang_up () {&lt;br /&gt;    echo &lt;br /&gt;    echo 'WWAN deactivated'&lt;br /&gt;    echo&lt;br /&gt;    exit&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;trap "hang_up" 2&lt;br /&gt;&lt;br /&gt;echo 'Activating WWAN'&lt;br /&gt;sudo modprobe -r airprime usbserial&lt;br /&gt;sudo modprobe usbserial vendor=0x1199 product=0x0220&lt;br /&gt;sudo modprobe airprime&lt;br /&gt;sleep 0.5&lt;br /&gt;sudo wvdial&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 11 May 2008 18:21:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5484</guid>
      <author>jmcvetta (Jason McVetta)</author>
    </item>
    <item>
      <title>add a folder to PATH, but not if it is already in PATH</title>
      <link>http://snippets.dzone.com/posts/show/4821</link>
      <description>Often times one uses a single .profile or .bashrc across several hosts.  These hosts may be differently configured, with varying directory locations, and different initial PATH values from /etc/profile.  In situations like this, setting PATH the traditional way -- "PATH=$PATH:/path/to/some/stuff" -- can result in a cumbersomely long PATH that includes inaccessible or duplicate folders.  &lt;br /&gt;&lt;br /&gt;The snippet below nicely handles this problem.  It has been tested on Solaris and Linux.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;AddPath ()&lt;br /&gt;# Add argument to $PATH if:&lt;br /&gt;# - it is not already present&lt;br /&gt;# - it is a directory&lt;br /&gt;# - we have execute permission on it&lt;br /&gt;#&lt;br /&gt;# This snippet is public domain; you may use it freely.  Death to copyright, patents, &lt;br /&gt;# and all other forms of intellectual monopoly.  &lt;br /&gt;#&lt;br /&gt;{&lt;br /&gt;  _folder=$1&lt;br /&gt;  echo " $PATH " | sed 's/:/ /g' | grep " $_folder " &gt; /dev/null&lt;br /&gt;  [ $? -ne 0 ] &amp;&amp; [ -d $_folder ] &amp;&amp; [ -x $_folder ] &amp;&amp; PATH=$PATH:$_folder&lt;br /&gt;  export PATH&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# Add some common paths:&lt;br /&gt;AddPath /usr/bin&lt;br /&gt;AddPath /usr/local/bin&lt;br /&gt;AddPath /opt/somepackage/bin&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 28 Nov 2007 18:38:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4821</guid>
      <author>jmcvetta (Jason McVetta)</author>
    </item>
  </channel>
</rss>
