<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://jrfom.com/wp-atom.php">
	<title type="text">Room Full of Mirrors</title>
	<subtitle type="text">... and all I could see was me</subtitle>

	<updated>2012-02-01T16:53:57Z</updated>

	<link rel="alternate" type="text/html" href="http://jrfom.com" />
	<id>http://jrfom.com/feed/</id>
	

	<generator uri="http://wordpress.org/" version="3.3.1">WordPress</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/jrfom/cCSs" /><feedburner:info uri="jrfom/ccss" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
		<author>
			<name>James Sumners</name>
					</author>
		<title type="html"><![CDATA[Oracle, Daylight Saving Time, And Unix Timestamps]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jrfom/cCSs/~3/sCkBGQ9VY0c/" />
		<id>http://jrfom.com/?p=312</id>
		<updated>2012-02-01T16:53:57Z</updated>
		<published>2012-02-01T15:59:59Z</published>
		<category scheme="http://jrfom.com" term="Code" /><category scheme="http://jrfom.com" term="Oracle" /><category scheme="http://jrfom.com" term="PLSQL" /><category scheme="http://jrfom.com" term="Technology" />		<summary type="html"><![CDATA[If ever there was a combination to make you hate developing web applications against an Oracle database, it&#8217;s the one defined in the title of this post. Let&#8217;s see: Unix timestamps are used in a lot of web applications because they&#8217;re easy to work with Oracle doesn&#8217;t have any native functions for working with Unix [...]]]></summary>
		<content type="html" xml:base="http://jrfom.com/2012/02/01/oracle-daylight-saving-time-and-unix-timestamps/">&lt;p&gt;If ever there was a combination to make you hate developing web applications against an Oracle database, it&amp;#8217;s the one defined in the title of this post. Let&amp;#8217;s see:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Unix timestamps are used in a lot of web applications because they&amp;#8217;re easy to work with&lt;/li&gt;
&lt;li&gt;Oracle doesn&amp;#8217;t have any native functions for working with Unix timestamps&lt;/li&gt;
&lt;li&gt;You have no way of knowing when a bored government will change the dates that DST starts and ends&lt;/li&gt;
&lt;li&gt;You shouldn&amp;#8217;t include a timezone in a Unix timestamp&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After much searching, and piecing together of different solutions to slightly different problems, I have written the following three functions that should cover all of your Unix timestamp handling needs within an Oracle database:&lt;/p&gt;
&lt;pre class="brush:sql"&gt;CREATE OR REPLACE
  FUNCTION unix_time
    RETURN INTEGER
  AS
    ut INTEGER     := 0;
    tz VARCHAR2(8) := '';
  BEGIN
    /**
     * This function is for getting the current number of seconds since
     * 01 January 1970 in UTC, i.e. a Unix timestamp.
     *
     * @author James Sumners
     * @date 01 February 2012
     *
     * @return integer
     */

    -- Get the current timezone abbreviation (stupid DST)
    SELECT
      extract(timezone_abbr FROM CURRENT_TIMESTAMP)
    INTO
      tz
    FROM
      dual;

    -- Get the Unix timestamp
    SELECT
      (new_time(sysdate, tz, 'GMT') - to_date('01-JAN-1970', 'DD-MM-YYYY')) * (
      86400)
    INTO
      ut
    FROM
      dual;

    RETURN ut;
END unix_time;&lt;/pre&gt;
&lt;pre class="brush:sql"&gt;CREATE OR REPLACE
  FUNCTION unix_time_to_date(
      unix_time IN INTEGER,
      local_tz  IN INTEGER DEFAULT 0
    )
    RETURN DATE
  AS
    converted_date DATE;
    tz VARCHAR2(8) := '';
  BEGIN
    /**
     * This function is used to convert a Unix timestamp (UTC) into an Oracle DATE. The converted DATE will
     * be in UTC unless the optional local_tz parameter is provided.
     *
     * @author James Sumners
     * @date 01 February 2012
     *
     * @param unix_time The Unix timestamp to convert
     * @param local_tz 0 = UTC, 1 = Local database time zone
     *
     * @return date
     */
    SELECT
      to_date('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + numtodsinterval(
      unix_time, 'SECOND')
    INTO
      converted_date
    FROM
      dual;

    IF local_tz &amp;lt;&amp;gt; 0 THEN
      -- Get the current timezone abbreviation (stupid DST)
      SELECT
        extract(timezone_abbr FROM CURRENT_TIMESTAMP)
      INTO
        tz
      FROM
        dual;
      -- Convert the GMT time to the current local timezone
      converted_date := new_time(converted_date, 'GMT', tz);
    END IF;

    RETURN converted_date;
END unix_time_to_date;&lt;/pre&gt;
&lt;pre class="brush:sql"&gt;CREATE OR REPLACE
  FUNCTION unix_time_from_date(
      in_date IN DATE
    )
    RETURN INTEGER
  AS
    ut INTEGER     := 0;
    tz VARCHAR2(8) := '';
  BEGIN
    /**
     * This function is used to convert an Oracle DATE (local timezone) to a Unix timestamp (UTC).
     *
     * @author James Sumners
     * @date 01 February 2012
     *
     * @param in_date An Oracle DATE to convert. It is assumed that this date will be in the local timezone.
     *
     * @return integer
     */

    -- Get the local timezone from the passed in date
    SELECT
      extract(timezone_abbr FROM CAST(in_date AS TIMESTAMP
    WITH
      local TIME zone))
    INTO
      tz
    FROM
      dual;

    -- Get the Unix timestamp
    SELECT
      (new_time(in_date, tz, 'GMT') - to_date('01-JAN-1970', 'DD-MM-YYYY')) * (
      86400)
    INTO
      ut
    FROM
      dual;

    RETURN ut;
END unix_time_from_date;&lt;/pre&gt;
&lt;div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"&gt;&lt;g:plusone size="small" count="1" href="http://jrfom.com/2012/02/01/oracle-daylight-saving-time-and-unix-timestamps/"&gt;&lt;/g:plusone&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jrfom/cCSs/~4/sCkBGQ9VY0c" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jrfom.com/2012/02/01/oracle-daylight-saving-time-and-unix-timestamps/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jrfom.com/2012/02/01/oracle-daylight-saving-time-and-unix-timestamps/feed/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jrfom.com/2012/02/01/oracle-daylight-saving-time-and-unix-timestamps/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>James Sumners</name>
					</author>
		<title type="html"><![CDATA[&#8220;Expected identifier, string or number&#8221;]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jrfom/cCSs/~3/fccW3oZXkpM/" />
		<id>http://jrfom.com/?p=306</id>
		<updated>2011-12-08T19:03:14Z</updated>
		<published>2011-12-08T19:03:14Z</published>
		<category scheme="http://jrfom.com" term="Code" /><category scheme="http://jrfom.com" term="JavaScript" /><category scheme="http://jrfom.com" term="Technology" />		<summary type="html"><![CDATA[Thanks, IE. I just spent pretty much all day tracking down the cause of this error. Conventional wisdom regarding this error is that you have a snippet of JavaScript like (where the comma trailing &#8220;42&#8243; is the error): var myObj = { a: "a string", b: 42, } I didn&#8217;t. But IE 8 was still [...]]]></summary>
		<content type="html" xml:base="http://jrfom.com/2011/12/08/expected-identifier-string-or-number/">&lt;p&gt;Thanks, IE.&lt;/p&gt;
&lt;p&gt;I just spent pretty much all day tracking down the cause of this error. Conventional wisdom regarding this error is that you have a snippet of JavaScript like (where the comma trailing &amp;#8220;42&amp;#8243; is the error):&lt;/p&gt;
&lt;pre class="brush:js"&gt;var myObj = {
    a: "a string",
    b: 42,
}&lt;/pre&gt;
&lt;p&gt;I didn&amp;#8217;t. But IE 8 was still throwing up this error message and its developer tools were pointing me at a line of HTML that contained nothing more than &amp;#8220;&amp;lt;div&amp;gt;&amp;#8221;. WTF, right? So after much confusion, and narrowing of code, I found the line IE was really barfing on. Consider the following object:&lt;/p&gt;
&lt;pre class="brush:js"&gt;var myObj = {
    default: "ie blows",
    b: 42
}&lt;/pre&gt;
&lt;p&gt;Can you guess the problem? IE does not like keywords being used as the name of an object property. If you really want to use a keyword, like the &lt;a href="http://www.jquery.com/"&gt;jQuery&lt;/a&gt; plugin I&amp;#8217;m using does, then write your object with JSON style syntax:&lt;/p&gt;
&lt;pre class="brush:js"&gt;var myObj = {
    "default": "ie blows",
    "b": 42
}&lt;/pre&gt;
&lt;div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"&gt;&lt;g:plusone size="small" count="1" href="http://jrfom.com/2011/12/08/expected-identifier-string-or-number/"&gt;&lt;/g:plusone&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jrfom/cCSs/~4/fccW3oZXkpM" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jrfom.com/2011/12/08/expected-identifier-string-or-number/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jrfom.com/2011/12/08/expected-identifier-string-or-number/feed/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jrfom.com/2011/12/08/expected-identifier-string-or-number/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>James Sumners</name>
					</author>
		<title type="html"><![CDATA[Create A Daemon Out Of Any Program]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jrfom/cCSs/~3/cSLBct7A5Dc/" />
		<id>http://jrfom.com/?p=303</id>
		<updated>2011-11-04T17:12:40Z</updated>
		<published>2011-11-04T17:12:40Z</published>
		<category scheme="http://jrfom.com" term="Uncategorized" />		<summary type="html"><![CDATA[I find myself having to write a script that does this sort of thing every time I have a need. I finally got fed up enough with that to write a generic script that can be used with any interactive program. The script can be found on my BitBucket site under the Scripts repository; the [...]]]></summary>
		<content type="html" xml:base="http://jrfom.com/2011/11/04/create-a-daemon-out-of-any-program/">&lt;p&gt;I find myself having to write a script that does this sort of thing every time I have a need. I finally got fed up enough with that to write a generic script that can be used with any interactive program. The script can be found on my &lt;a href="http://bitbucket.org/jsumners"&gt;BitBucket site&lt;/a&gt; under the &lt;a href="https://bitbucket.org/jsumners/scripts/"&gt;Scripts repository&lt;/a&gt;; the script is named &lt;a href="https://bitbucket.org/jsumners/scripts/src/466fd6468cd6/screen_daemon.sh"&gt;screen_daemon.sh&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The script, as should be obvious, relies on the &lt;a href="http://en.wikipedia.org/wiki/GNU_Screen"&gt;screen utility&lt;/a&gt; to manage the &amp;#8220;daemon.&amp;#8221; Screen specifically supports this type of thing with the &amp;#8220;-Dm&amp;#8221; switch combination. This switch combination starts screen in detached mode but doesn&amp;#8217;t &amp;#8220;fork a new process&amp;#8221; (`man screen`). This means that screen starts whatever program you pass in and quits as soon as that program terminates. Thus, you can safely assume that the process id (pid) of the screen session is the pid of your daemon. On lines 82 &amp;#8211; 84 of screen_daemon.sh I provide an example that takes advantage of this fact for programs that don&amp;#8217;t write their own pid file.&lt;/p&gt;
&lt;p&gt;If you create a daemon using this script, you can add a &lt;a href="http://en.wikipedia.org/wiki/Cron"&gt;cronjob&lt;/a&gt; that runs your daemon script at regular interval, say every five minutes, to keep the daemon running. If the daemon is already running, the script will simply exit. If the script determines that an instance is not running, or has crashed in some way, it will start a new instance.&lt;/p&gt;
&lt;div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"&gt;&lt;g:plusone size="small" count="1" href="http://jrfom.com/2011/11/04/create-a-daemon-out-of-any-program/"&gt;&lt;/g:plusone&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jrfom/cCSs/~4/cSLBct7A5Dc" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jrfom.com/2011/11/04/create-a-daemon-out-of-any-program/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jrfom.com/2011/11/04/create-a-daemon-out-of-any-program/feed/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jrfom.com/2011/11/04/create-a-daemon-out-of-any-program/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>James Sumners</name>
					</author>
		<title type="html"><![CDATA[~/.ssh/config]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jrfom/cCSs/~3/m0zZKiw6Zf0/" />
		<id>http://jrfom.com/?p=298</id>
		<updated>2011-09-28T19:59:07Z</updated>
		<published>2011-09-28T19:59:07Z</published>
		<category scheme="http://jrfom.com" term="Uncategorized" />		<summary type="html"><![CDATA[~/.ssh/config is a file I have not had occasion to use until today. Evidently not many other people use it very often either, because finding the information I needed was more difficult than it should have been. Thus, this post is meant to make it easier to find. I am currently hosting a private Minecraft [...]]]></summary>
		<content type="html" xml:base="http://jrfom.com/2011/09/28/sshconfig/">&lt;p&gt;&lt;code&gt;~/.ssh/config&lt;/code&gt; is a file I have not had occasion to use until today. Evidently not many other people use it very often either, because finding the information I needed was more difficult than it should have been. Thus, this post is meant to make it easier to find.&lt;/p&gt;
&lt;p&gt;I am currently hosting a private &lt;a href="http://minecraft.net/"&gt;Minecraft&lt;/a&gt; server through &lt;a href="http://redstonehost.com/"&gt;redstonehost.com&lt;/a&gt; for a few friends. My hosting plan is a &lt;a href="http://en.wikipedia.org/wiki/Virtual_private_server"&gt;VPS&lt;/a&gt; specifically designed for easy Minecraft server administration. It being a VPS, I have direct &lt;a href="http://en.wikipedia.org/wiki/Secure_Shell"&gt;SSH&lt;/a&gt; access to the server. The SSH account is pre-configured by RedstoneHost to a specific user that manages your Minecraft server. The password for this user is configured by you via your RedstoneHost user control panel. The password I configured is a complex, auto-generated, password.&lt;/p&gt;
&lt;p&gt;Given that my password for the VPS is complex, I would rather use an SSH key file for authentication when I need to login. However, I &lt;strong&gt;do not&lt;/strong&gt; want to use the same key that I use for other systems. This is where the need for the &lt;code&gt;~/.ssh/config&lt;/code&gt; file comes into play.&lt;/p&gt;
&lt;p&gt;When you do &lt;samp&gt;`ssh james@example.com`&lt;/samp&gt; the remote system sends a packet back telling your local SSH client what forms of authentication it will accept. If the remote server accepts key files, and you have your key configured with the remote host, it will attempt to validate your identity based on the keys installed in your &lt;code&gt;~/.ssh/&lt;/code&gt; directory. Except, it doesn&amp;#8217;t validate against just &lt;em&gt;any&lt;/em&gt; key files in the directory. SSH2 specifically checks agains &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt; and &lt;code&gt;~/.ssh/id_dsa&lt;/code&gt; before giving up on key file authentication and moving on to the next method. Thus, if you want to use a key file &lt;code&gt;~/.ssh/example_com_dsa&lt;/code&gt; you would need to do &lt;samp&gt;`ssh -i ~/.ssh/example_com_dsa james@example.com`&lt;/samp&gt;. This is definitely more typing than anyone wants to do just to connect to a host.&lt;/p&gt;
&lt;p&gt;To solve this problem, you can add the following to your &lt;code&gt;~/.ssh/config&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class="brush:shell"&gt;Host example.com
    User james
    IdentityFile %d/.ssh/example_com_dsa&lt;/pre&gt;
&lt;p&gt;Now every time you do &lt;samp&gt;`ssh example.com`&lt;/samp&gt; you will be connecting to &lt;code&gt;example.com&lt;/code&gt; as if you had done &lt;samp&gt;`ssh -i ~/.ssh/example_com_dsa james@example.com`&lt;/samp&gt; instead.&lt;/p&gt;
&lt;p&gt;For more information on what options are available to you in the config file, read through &lt;a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config"&gt;the manpage&lt;/a&gt;. For some more examples of how the config file can be helpful to you, look through &lt;a href="http://thread.gmane.org/gmane.org.user-groups.ale/79939/focus=84773"&gt;this ALE thread&lt;/a&gt; (&lt;a href="http://ale.org/"&gt;Atlanta Linux Enthusiasts&lt;/a&gt;).&lt;/p&gt;
&lt;div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"&gt;&lt;g:plusone size="small" count="1" href="http://jrfom.com/2011/09/28/sshconfig/"&gt;&lt;/g:plusone&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jrfom/cCSs/~4/m0zZKiw6Zf0" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jrfom.com/2011/09/28/sshconfig/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jrfom.com/2011/09/28/sshconfig/feed/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jrfom.com/2011/09/28/sshconfig/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>James Sumners</name>
					</author>
		<title type="html"><![CDATA[Sonar 2011 Remix Competition And My Re-emerging Hobby]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jrfom/cCSs/~3/jjSbNS3HEwc/" />
		<id>http://jrfom.com/?p=285</id>
		<updated>2011-07-13T19:35:20Z</updated>
		<published>2011-07-13T19:34:06Z</published>
		<category scheme="http://jrfom.com" term="Uncategorized" />		<summary type="html"><![CDATA[I have entered the Sonar 2011 remix competition by Loopmasters with a track I&#8217;m calling Sonacid. It&#8217;s got a Wink style acid house vibe. This is my first public release since getting started with Ableton Live four months ago. Which brings me to the second part of this post&#8217;s title. Before I truly committed myself [...]]]></summary>
		<content type="html" xml:base="http://jrfom.com/2011/07/13/sonar-2011-remix-competition-and-my-re-emerging-hobby/">&lt;p&gt;I have entered the &lt;a href="http://www.loopmasters.com/sonar_remix"&gt;Sonar 2011 remix competition&lt;/a&gt; by Loopmasters with a track I&amp;#8217;m calling &lt;a href="http://soundcloud.com/jsumners/sonacid-sonar-remix"&gt;Sonacid&lt;/a&gt;. It&amp;#8217;s got a &lt;a href="http://www.discogs.com/artist/Josh+Wink"&gt;Wink&lt;/a&gt; style acid house vibe. This is my first public release since getting started with &lt;a href="http://www.ableton.com/live-8"&gt;Ableton Live&lt;/a&gt; four months ago.&lt;/p&gt;
&lt;p&gt;Which brings me to the second part of this post&amp;#8217;s title. Before I truly committed myself to completing my degree, I spent a lot of time with music. After I completed my degree, I dabbled with music occasionally. I created some rather decent arrangements with Garage Band, but nothing I would consider totally original and worthy of getting published. Everything has changed in the past four months.&lt;/p&gt;
&lt;p&gt;Ableton Live has brought back the desire in me to create original music. Music has once again become my primary hobby, and I have worked in Live almost every single day over the past four months. I have created several new tracks, a couple of which are fully complete, and I continue to learn and have fun with Live. But since Live isn&amp;#8217;t some amatuer hour free tracker, I have opted not to release any of this material for free. My plan is to release my work via the &lt;a href="https://www.facebook.com/pages/UltraPhonix-Recordings/176622692363041"&gt;UltraPhonix Recordings&lt;/a&gt; (UPR) label. In fact, my first release was scheduled to be sometime this month, but extenuating circumstances has delayed that plan.&lt;/p&gt;
&lt;p&gt;So, until then, please enjoy a taste of my upcoming work with Sonacid. I am not making it available for download, hence it only being available for streaming on &lt;a href="http://soundcloud.com/"&gt;SoundCloud&lt;/a&gt;, just yet. After the competition results are posted, I might enable downloading of the track. But I might also wait and see if UPR would like to release it.&lt;/p&gt;
&lt;div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"&gt;&lt;g:plusone size="small" count="1" href="http://jrfom.com/2011/07/13/sonar-2011-remix-competition-and-my-re-emerging-hobby/"&gt;&lt;/g:plusone&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jrfom/cCSs/~4/jjSbNS3HEwc" height="1" width="1"/&gt;</content>
		<link rel="replies" type="text/html" href="http://jrfom.com/2011/07/13/sonar-2011-remix-competition-and-my-re-emerging-hobby/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://jrfom.com/2011/07/13/sonar-2011-remix-competition-and-my-re-emerging-hobby/feed/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://jrfom.com/2011/07/13/sonar-2011-remix-competition-and-my-re-emerging-hobby/</feedburner:origLink></entry>
	</feed>

