<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sfpeter.com</title>
	<atom:link href="http://www.sfpeter.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sfpeter.com</link>
	<description>must have blog.</description>
	<lastBuildDate>Tue, 15 May 2012 18:14:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to win the Mega Millions lottery</title>
		<link>http://www.sfpeter.com/2012/05/how-to-win-the-mega-millions-lottery/</link>
		<comments>http://www.sfpeter.com/2012/05/how-to-win-the-mega-millions-lottery/#comments</comments>
		<pubDate>Tue, 15 May 2012 18:14:45 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/?p=54</guid>
		<description><![CDATA[I&#8217;ve ignored my blog for several years so it&#8217;s time for a blog revival&#8230; I&#8217;m planning on sharing some of<a href="http://www.sfpeter.com/2012/05/how-to-win-the-mega-millions-lottery/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve ignored my blog for several years so it&#8217;s time for a blog revival&#8230; I&#8217;m planning on sharing some of the recent lessons I&#8217;ve learned in Ruby on Rails development. For today, let&#8217;s keep it simple. Here&#8217;s my Ruby one-liner that will help you win the Mega Millions lottery:</p>
<pre class="brush:ruby">
a=[];until(a.length==5);n=1+rand(56);a&lt;&lt;n if(!a.include?(n));end;puts "your numbers are #{a.sort*','} and Mega Ball #{1+rand(46)}"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2012/05/how-to-win-the-mega-millions-lottery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixel Peeper</title>
		<link>http://www.sfpeter.com/2009/02/pixel-peeper/</link>
		<comments>http://www.sfpeter.com/2009/02/pixel-peeper/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 08:53:56 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[photography]]></category>
		<category><![CDATA[sites]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2009/02/18/pixel-peeper/</guid>
		<description><![CDATA[If you&#8217;re like me and somewhat serious about photography, you probably research your lenses and cameras before you buy them.<a href="http://www.sfpeter.com/2009/02/pixel-peeper/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me and somewhat serious about photography, you probably research your lenses and cameras before you buy them. While I&#8217;m eagerly waiting for my new Panasonic LX3 to arrive, I was browsing around a bit to see what other LX3 owners have been able to produce with that camera. Not so surprisingly, I found a lot of great photos. But I also found a cool website that I wasn&#8217;t aware of until now: <a href="http://www.pixel-peeper.com/" title="Pixel Peeper" target="_blank">pixel-peeper.com</a>. It uses the Flickr API to let you search for photos made by pretty much any kind of camera or lens.<br />
Have a look and judge picture quality for yourself. Of course it&#8217;s true that a $6000 lens also typically has a better photographer behind it so comparing its photos to other random photos taken with a $100 piece of glass probably isn&#8217;t entirely fair. But it&#8217;s fun comparing anyhow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2009/02/pixel-peeper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running the Glassfish updatetool on a remote server</title>
		<link>http://www.sfpeter.com/2008/09/glassfish-updatetool-on-remote-server/</link>
		<comments>http://www.sfpeter.com/2008/09/glassfish-updatetool-on-remote-server/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 08:25:01 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2008/09/11/glassfish-updatetool-on-remote-server/</guid>
		<description><![CDATA[I&#8217;ve been playing around with JRuby on Rails and Glassfish and really like the simplicity of deploying simple WAR files<a href="http://www.sfpeter.com/2008/09/glassfish-updatetool-on-remote-server/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with JRuby on Rails and Glassfish and really like the simplicity of deploying simple WAR files to a Glassfish server. Messing around with Apache configurations and managing a bunch of mongrel processes is just not my favorite pastime, plus I like to have the option of running other J2EE webapps on the same server, and interface my RoR app with existing Java libraries.</p>
<p>I ran into some problems trying to get the updatetool for Glassfish working on my VPS (at Rimuhosting) though. The updatetool is a Java Swing app and I&#8217;ve never run any GUI apps on this remote host before. It doesn&#8217;t have Gnome or KDE running so VNC was not an option. The trick is mostly just to set up your systems for running remote X11 applications over a SSH tunnel. Here&#8217;s how I got it to work&#8230;. I should say this server runs Ubuntu Hardy and locally I&#8217;m on Mac OS X so the X11 install from the Mac OS installation disks was the easy part.</p>
<p>Here&#8217;s what I had to do on the remote host:</p>
<p><span id="more-32"></span> open /etc/ssh/sshd_config and make sure you set</p>
<pre class="brush:bash">
  X11Forwarding yes</pre>
<p>in /etc/ssh/ssh_config  check that you have the following settings:</p>
<pre class="brush:bash">
  ForwardAgent yes
  ForwardX11 yes</pre>
<p>there are a few other dependencies that you may not have yet on a clean Ubuntu install. I was getting very confusing java link errors in my stacktraces until I&#8217;d installed all of them. So grab these with:</p>
<pre class="brush:bash">
  sudo apt-get install xauth libxp-java libxtst-dev libxi-dev</pre>
<p>at this point, log out and log back in with</p>
<pre class="brush:bash">
  ssh -X  yourname@yourhost</pre>
<p>The -X option is important here : it&#8217;s telling the server that you&#8217;re going to want to run a X11 application over this SSH tunnel.<br />
On my system I got the following message after logging back in:</p>
<pre class="brush:bash">
  /usr/bin/X11/xauth:  creating new authority file /root/.Xauthority</pre>
<p>that&#8217;s all. I was now able to run the Glassfish updatetool simply by calling</p>
<pre class="brush:bash">
  /var/www/glassfish/updatecenter/bin/updatetool</pre>
<p>and the application came up nicely on my Mac desktop. These steps will probably work to run just about any Java Swing application on a remote Ubuntu/Debian server.</p>
<p>I hope this helps some people&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2008/09/glassfish-updatetool-on-remote-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>new Trendnet TV-IP400W controller for Zoneminder 1.23.x</title>
		<link>http://www.sfpeter.com/2008/07/new-trendnet-tv-ip400w-controller-for-zoneminder-123x/</link>
		<comments>http://www.sfpeter.com/2008/07/new-trendnet-tv-ip400w-controller-for-zoneminder-123x/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 08:10:02 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Home Automation]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2008/07/31/new-trendnet-tv-ip400w-controller-for-zoneminder-123x/</guid>
		<description><![CDATA[I&#8217;ve finally gotten around to rewriting my old Trendnet PTZ controller for Zoneminder 1.22.x to support the new API for<a href="http://www.sfpeter.com/2008/07/new-trendnet-tv-ip400w-controller-for-zoneminder-123x/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally gotten around to rewriting my old Trendnet PTZ controller for Zoneminder 1.22.x to support the new API for Zoneminder 1.23.x. It includes all the old features (moving the camera in horizontally, vertically, diagonally, and going to preset and home position) as well as a new bonus feature: move the camera simply by clicking a point in the live video that you want the camera to recenter on. This is not extremely accurate, but good enough for most uses, and faster than having to click an arrow 20 times.</p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=sfpetercom-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=B000COC7T6&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="width: 120px; height: 240px" marginwidth="0" marginheight="0" align="right" frameborder="0" scrolling="no"></iframe></p>
<p>Here&#8217;s the basic steps on how to get this Trendnet TV-IP400 / IV-IP400W driver to work in ZoneMinder: <span id="more-31"></span></p>
<ul>
<li>Make sure you have indeed version 1.23.x. You can see this in the title of the main  console window. If you are still using version 1.22.x, either <a href="http://www.zoneminder.com/downloads.html" target="_blank">upgrade</a> your ZoneMinder or <a href="http://www.sfpeter.com/2007/08/14/controlling-the-trendnet-tv-ip400w-camera-with-zoneminder/">use my old driver</a>.</li>
</ul>
<ul></ul>
<ul>
<li><a href="http://www.sfpeter.com/files/trendnet_new/TVIP400.pm" onclick="javascript: pageTracker._trackPageview('/trendnet/newdriver');" target="_blank">Download the driver file</a> here, and store it in the right directory. For me (having compiled Zoneminder from source on ubuntu) that location is /usr/local/perl/5.8.8/ZoneMinder/control.  If that location doesn&#8217;t exist on your system, you can do a search for another camera driver such as Visca.pm and store the TVIP400.pm file in the same location.</li>
</ul>
<ul>
<li>Create a new camera for your TV-IP400 if you haven&#8217;t already done so. The source tab looks something like this:</li>
</ul>
<p><img src="http://www.sfpeter.com/files/trendnet_new/source_tab.png" height="445" width="440" /><br />
Make sure you change the IP address and port number if necessary. You will need to make sure that access control is turned off by the way.</p>
<p>If you had enabled the  ZM_OPT_CONTROL setting in the system options screen, you will also see a control tab in the camera config window.  This tab should look like this:</p>
<p><img src="http://www.sfpeter.com/files/trendnet_new/control_tab.png" height="445" width="440" /></p>
<p>Again, make sure you set the correct IP address (the same as what you set in the source tab). You won&#8217;t have a TV-IP400 option yet in the Control Type dropdown, so click on &#8216;edit&#8217; there and let&#8217;s create one.</p>
<p>In the Control Capabilities window, click &#8216;Add New Control&#8217;. Then set the settings in the Main and Move tabs as follows:</p>
<p><img src="http://www.sfpeter.com/files/trendnet_new/main_tab.png" height="561" width="440" /></p>
<p><img src="http://www.sfpeter.com/files/trendnet_new/move_tab.png" height="561" width="440" /></p>
<p>In the Pan tab, only check the &#8216;Can Pan&#8217; option and leave the rest blank.<br />
In the Tilt tab, only check the &#8216;Can Tilt&#8217; option.</p>
<p>All options in the Zoom, Focus, White and Iris tabs can be left blank since none of these features are supported.</p>
<p>The Presets tab should be set as follows:</p>
<p><img src="http://www.sfpeter.com/files/trendnet_new/presets_tab.png" height="561" width="440" /></p>
<p>Though you can&#8217;t actually set presets through ZoneMinder, you can move the camera to presets that you&#8217;ve configured through the Trendnet web interface. I&#8217;m only using 5 presets but I believe you could access all 24 presets that the Trendnet supports.</p>
<p>That&#8217;s all! Save the configuration, and give your new controllable camera a spin in ZoneMinder. Let me know how you like it.</p>
<p><em>Thanks to Armando Oritz for his help in testing this driver. </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2008/07/new-trendnet-tv-ip400w-controller-for-zoneminder-123x/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>jQuery plugin for communication between browser windows</title>
		<link>http://www.sfpeter.com/2008/03/communication-between-browser-windows-with-jquery-my-new-plugin/</link>
		<comments>http://www.sfpeter.com/2008/03/communication-between-browser-windows-with-jquery-my-new-plugin/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 06:49:08 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-with-jquery-my-new-plugin/</guid>
		<description><![CDATA[Ajax is great for sending data back and forth between a browser window and the server, but when it comes<a href="http://www.sfpeter.com/2008/03/communication-between-browser-windows-with-jquery-my-new-plugin/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><em>Ajax is great for sending data back and forth between a browser window and the server, but when it comes to communication between two browser windows, there are few libraries that can help you out there. </em></p>
<p>I&#8217;ve been working with jQuery for over a year now and have always wanted to give something back to the user community by releasing my own plugin. Unfortunately it seemed like every type of generic functionality I might ever need had already been developed by others. Until last night.</p>
<p>I was working on a webapp in which my main browser window had to open a popup window, and the user would then perform an action in this window. Upon completion of that action the main (parent) browser window needed to be notified.<br />
Though parent and child window can easily access eachother&#8217;s DOM, a common way to get a value from one window to another is by setting a value on a hidden input field of a form in the other window. This requires you to add form markup to your page, which is clunky. A second issue is that if you have several types of events or data to send to the other window, you&#8217;ll need to add an input field for each type. And a third issue I ran into is that &#8216;change&#8217; events do not seem to fire for an input field if that field was updated by another window. &#8216;change&#8217; or custom events using jQuery didn&#8217;t work either this way. &#8216;click&#8217; events on links or buttons do work, but they would need to be hidden, otherwise the user could click on them too. I got it all working but this all started to look like an ugly hack, cluttering my pages with messy javascript and markup code.</p>
<p><span id="more-27"></span> Long story short, this is where my new skills of creating jQuery plugins came to the rescue.  This could all be put into a nice little plugin that would hide all the messy details of adding a form to your page and using hidden form elements to transfer data back and forth between windows. Even better, my new plugin makes it very easy to use multiple callback handlers, so you can define your own events that you can send from one browser window to the other. And events can be sent both ways in almost the same fashion. To my delight, it worked flawlessly in all browsers I&#8217;ve tried (FF, safari on Mac, and FF and IE7 on Windows).</p>
<p>Here&#8217;s how to use it:</p>
<p>In any page that needs to receive window events, make sure to call the initialization function upon page load:</p>
<pre class="brush:js">
$.initWindowMsg();</pre>
<p>The parent window can open a child window the good old way:</p>
<pre class="brush:js">
childWin = window.open('child.html', 'mychildwindow');</pre>
<p>and then send it an event with data:</p>
<pre class="brush:js">
$.triggerWindowEvent(childWin, "myevent", "some data");</pre>
<p>The child window can register a callback handler for this event as follows:</p>
<pre class="brush:js">
$.windowMsg("myevent",  function(message) {
    // do  something  with message from parent
});</pre>
<p>The child window can send a message back to the parent with:</p>
<pre class="brush:js">
$.triggerParentEvent("parentevent", "message to parent");</pre>
<p>The parent can register a handler for this event in the same way:</p>
<pre class="brush:js">
$.windowMsg("parentevent",  function(message) {
    // do  something  with message from child
});</pre>
<p>That&#8217;s all.</p>
<p><a href="/files/windowmsg/parent.html" onclick="javascript:urchinTracker('/windowmsg/demo');" target="_blank">You can see a simple demo here</a>. (make sure your popup blocker is turned off).</p>
<p><a href="/files/windowmsg/windowmsg.zip" onclick="javascript:urchinTracker('/windowmsg/download')">Download the plugin and demo files</a><br />
One thing to keep in mind is that it is of course a requirement that one of the windows opened the other, and that neither window has navigated to any other pages. Once they&#8217;ve lost the reference to eachother, there&#8217;s no reconnecting. The triggerWindowEvent and triggerParentEvent functions return a boolean which indicates if the event could be sent or not. I could pretty easily add a function that could check if the parent or child window is still there actually&#8230; will add that in the first update of the plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2008/03/communication-between-browser-windows-with-jquery-my-new-plugin/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Ruby controller for the Trendnet TV-IP400W PTZ camera</title>
		<link>http://www.sfpeter.com/2008/02/ruby-controller-for-the-trendnet-ip-400w-ptz-camera/</link>
		<comments>http://www.sfpeter.com/2008/02/ruby-controller-for-the-trendnet-ip-400w-ptz-camera/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 08:16:10 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Home Automation]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2008/02/29/ruby-controller-for-the-trendnet-ip-400w-ptz-camera/</guid>
		<description><![CDATA[I thought I’d follow up on my post of a little while ago about the drivers for the Trendnet TV-IP400W<a href="http://www.sfpeter.com/2008/02/ruby-controller-for-the-trendnet-ip-400w-ptz-camera/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I thought I’d follow up on my post of a little while ago about the drivers for the Trendnet TV-IP400W Pan-Tilt-Zoom camera. I wrote a ruby driver for this thing, which makes it trivial to control the camera from any Ruby application. It’s just a single Ruby file, and though I’ve entertained the thought of figuring out how to pour it into a gem and publish it to the plugin repository, I’d probably only do that if there are a significant amount of people interested in using it and/or contributing to it.</p>
<p><iframe src="http://rcm.amazon.com/e/cm?t=sfpetercom-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=B000COC7T6&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="width: 120px; height: 240px" marginwidth="0" marginheight="0" align="right" frameborder="0" scrolling="no"></iframe></p>
<p>As with the old Perl driver for Zoneminder (which I’ve been told doesn’t work anymore with the latest version of ZM, since the interfaces for the PTZ drivers have completely changed), this driver only controls the pan and tilt functions of the camera. Actually, you can also put it in swing mode and store or access preset positions, but none of the available functions actually do anything with the video stream. The video can simply be accessed at:</p>
<p>http://yourcam/image.jpg to grab a single frame of the current camera view<br />
http://yourcam/video.cgi to get the mjpeg stream from the camera</p>
<p>There&#8217;s no real zoom control since the cam only has a digital zoom, which I believe is implemented in the client software only (so there&#8217;s no way to actually have it stream a zoomed image to your client).</p>
<p><span id="more-26"></span>Okay, onto the example script now. The code below demonstrates how to use all the features of the camera driver.</p>
<pre class="brush:ruby">
require 'Ip400.rb'

# substitute your host IP address or name and port number here.
# If you have turned off access control, you can simply use:
# ptz = Ip400.new("192.168.0.140")
# if your camera is accessible at a port other than 80, simply
# specify the address like this: "192.168.0.140:90"
ptz = Ip400.new("192.168.0.140", "ruby", "ybur")

# go to the home position
ptz.home
sleep 3

# pan right 3 steps
ptz.pan(3, Ip400::RIGHT)
sleep 3

# pan left 5 steps
ptz.pan(5, Ip400::LEFT)
sleep 3

# tilt up 3 steps
ptz.tilt(3, Ip400::UP)
sleep 3

# tilt down 3 steps
ptz.tilt(3, Ip400::DOWN)
sleep 3

# pan and tilt at the same time
ptz.move(4, Ip400::RIGHT, 2, Ip400::DOWN)
sleep 3

# go to 1 of the 24 preset positions
ptz.goto_preset(1)
sleep 3

# visit all preset positions with about 5 second intervals
ptz.swing_preset
sleep 20
ptz.stop_swing # stop the swing mode again

# go into continuous scan mode (scan left and right with 1 second intervals)
ptz.swing_scan
sleep 10
ptz.stop_swing  # don't forget this!

# get the current absolute position of the camera
pos = ptz.abs_position
# store this position at preset 15
ptz.set_preset(pos['pan'], pos['tilt'], "myposition", 15)</pre>
<p>These examples should get even a Ruby novice going pretty quickly, and the Ip400.rb driver class can be used in or outside of a Rails app. The camera you&#8217;re controlling can be in a different room or even in a different country.<br />
I’m releasing it under the MIT license so it’s open for further hacking. If you end up using this code anywhere I’d love to hear from you, and I’ll release it as a real Ruby plugin if enough people show interest.</p>
<p>Have fun!</p>
<p><a href="http://www.sfpeter.com/files/trendnet/ip400.zip" onclick="urchinTracker('/downloadRubyDriver');">Download the above example file and the IP400.rb file</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2008/02/ruby-controller-for-the-trendnet-ip-400w-ptz-camera/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A day in the SF eastbay</title>
		<link>http://www.sfpeter.com/2008/02/a-day-in-the-sf-eastbay/</link>
		<comments>http://www.sfpeter.com/2008/02/a-day-in-the-sf-eastbay/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 21:56:40 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[sites]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2008/02/15/a-day-in-the-sf-eastbay/</guid>
		<description><![CDATA[I love outdoor webcams, because they can give you an instant and live view of what the weather and/or a<a href="http://www.sfpeter.com/2008/02/a-day-in-the-sf-eastbay/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I love outdoor webcams, because they can give you an instant and live view of what the weather and/or a location looks like in places all around the world. Two sites that are great for exploring these live views all around the world are  <a href="http://www.earthcam.com/" target="_blank">earthcam</a> and <a href="http://www.cammap.net" target="_blank">cammap.net</a> (though the latter appears to show only US based cams).  They are simple services that simply put a database of webcams around the world on top of interactive maps. It&#8217;s the kind of site I&#8217;ve always wanted to build myself&#8230; It&#8217;s been done now but that&#8217;s ok because I plenty of ideas for other types of web sites left.<br />
As I was browing our local webcams I came across an interesting one though&#8230; The <a href="http://sv.berkeley.edu/view/" target="_blank">Lawrence Hall of Science</a> in Berkeley has a fixed cam pointed towards the bay of San Francisco, and records a snapshot of the view every minute of every day. Every day they automatically generate a little movie out of that, which you can view online. I&#8217;ve embedded the video here too, so what you&#8217;re seeing here is what yesterday looked like over here. Depending on what day you look at this video, you may catch some of our fantastic sunsets over the bay, the beautiful fog rolling in or out, or all kinds of other weather patterns moving over the East Bay. For the real weather enthousiast, check out the <a href="http://sv.berkeley.edu/view/" target="_blank">timelaps movie archive</a> with some of the most stunning days caught on video.</p>
<p><a href="http://sv.berkeley.edu/view/timelapse/yesterdayview.avi" target="_blank"><img src="http://sv.berkeley.edu/view/images/newview.jpg" /></a><br />
<i>The above image of the view from the East Bay hills is at most a couple of minutes old (unless the camera is down). Click to view yesterday&#8217;s timelapse movie.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2008/02/a-day-in-the-sf-eastbay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://sv.berkeley.edu/view/timelapse/yesterdayview.avi" length="13736974" type="video/x-msvideo" />
<enclosure url="http://sv.berkeley.edu/view/timelapse/yesterdayview.mp4" length="13316860" type="video/mp4" />
		</item>
		<item>
		<title>Saint Nicholas in the Netherlands</title>
		<link>http://www.sfpeter.com/2007/11/saint-nicholas-in-the-netherlands/</link>
		<comments>http://www.sfpeter.com/2007/11/saint-nicholas-in-the-netherlands/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 23:51:48 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Dutch expat]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2007/11/15/saint-nicholas-in-the-netherlands/</guid>
		<description><![CDATA[It&#8217;s that time of year again&#8230; Saint Nicholas (aka Sinterklaas) has arrived (or is about to arrive) in the Netherlands,<a href="http://www.sfpeter.com/2007/11/saint-nicholas-in-the-netherlands/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s that time of year again&#8230; Saint Nicholas (aka Sinterklaas) has arrived (or is about to arrive) in the Netherlands, on his boat from Spain. He will be riding his white horse around Holland,  getting ready to celebrate his birthday on December 5th and hand out presents to the kids. Actually his birthday is on December 6th but many decades or so ago he must have decided that the 5th would be a better day to celebrate it. Anyway, it&#8217;s complicated. In the US I have always had a hard time explaining the tradition of Sinterklaas without being laughed at, or without people bringing up the (to them) obvious references to slavery in the Saint Nicholas tradition. Granted, I wouldn&#8217;t paint my face black, dress up like a Black Pete (Zwarte Piet) and go wander around Oakland like that, as people who are less aware of the Dutch tradition might  misinterpret what they&#8217;re seeing.</p>
<p>I came across a hilarious essay by David Sedaris on youtube that (fairly accurately) describes the Saint Nicholas tradition in Holland. You can view it right here &#8211; highly recommended. (it&#8217;s in 3 parts, make sure to watch all three of them&#8230;)</p>
<p><object width="470" height="406"><param name="movie" value="http://www.youtube.com/p/217900EA4317FD4E" /><param name="wmode" value="transparent" /><embed src="http://www.youtube.com/p/217900EA4317FD4E" type="application/x-shockwave-flash" width="470" height="406" wmode="transparent"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2007/11/saint-nicholas-in-the-netherlands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiva.org</title>
		<link>http://www.sfpeter.com/2007/10/kivaorg/</link>
		<comments>http://www.sfpeter.com/2007/10/kivaorg/#comments</comments>
		<pubDate>Sun, 21 Oct 2007 02:23:02 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[sites]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2007/10/20/kivaorg/</guid>
		<description><![CDATA[Ever since I spent a year travelling South East Asia in 1999, I&#8217;ve wanted to do something to help people<a href="http://www.sfpeter.com/2007/10/kivaorg/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.kiva.org/images/logoLeafy3.gif" align="left" height="90" hspace="5" width="170" />Ever since I spent a year travelling South East Asia in 1999, I&#8217;ve wanted to do something to help people in poor countries. I&#8217;ve met so many individuals and small business owners that were just struggling to get by, many of them working 7 days a week for just a few dollars per day. I hope that at one point in my life I&#8217;ll be able to travel back to some of these places and do some volunteer work and/or help out a local community financially. I&#8217;ve donated to organizations like the Red Cross that do incredible work helping out people in need all over the world. But my latest excitement in the world of good-karma-organizations is Kiva.org. Kiva works with microfinance institutions in many developing countries to allow anyone to make an interest free loan to small business owners.  These are not actually donations &#8211; as a Kiva user you lend money, in any amount that you&#8217;re comfortable with. The borrower will typically use the money to buy additional inventory, make certain repairs or otherwise expand his/her business. The vast majority of loans are paid back over time though, which allows lenders to help out even more people. Bill Clinton has been speaking about this organization and all the recent press about Kiva has resulted in the fact that there are actually more lenders than borrowers at the moment. This is great for Kiva of course&#8230; I hope they can set up relationships with more microfinance institutions so we can all help more people in more places.  So I am now partially financing the business of a pig farmer in Cambodia, and a door to door sales woman in Peru. Please do go check it out: <a href="http://www.kiva.org" target="_blank">www.kiva.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2007/10/kivaorg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Trendnet TV-IP400 / TV-IP400W protocol</title>
		<link>http://www.sfpeter.com/2007/08/19/</link>
		<comments>http://www.sfpeter.com/2007/08/19/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 07:47:25 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Home Automation]]></category>

		<guid isPermaLink="false">http://www.sfpeter.com/2007/08/20/19/</guid>
		<description><![CDATA[The Trendnet TV-IP400 is a fun little camera that will work great for home surveillance, as a controllable web cam,<a href="http://www.sfpeter.com/2007/08/19/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>The Trendnet TV-IP400 is a fun little camera that will work great for home surveillance, as a controllable web cam, etc. The only problem is that the software that comes with it really sucks. I reverse engineered the protocol that is used to control the camera, and wrote a ZoneMinder driver for it&#8230; <a href="http://www.sfpeter.com/2007/08/14/controlling-the-trendnet-tv-ip400w-camera-with-zoneminder/">go here</a> for more information. This follow up describes the control protocol that I reverse engineered, and contains most information that you&#8217;ll need if you want to write your own driver. I&#8217;m assuming that you are familiar with HTTP requests and that you know how to send GET and POST requests to an IP address.</p>
<p>Feel free to use the information in this page in any way you want. I make no guarantees as to its accuracy or completeness. If you write any software based on this info, please let me know!</p>
<p><span id="more-20"></span>control commands:</p>
<p>The following CGIs are supported.</p>
<p><strong>/PANTILTCONTROL.CGI<br />
</strong><br />
This is the main CGI for camera movement control, and should always be a POST request. The commands are very simple, there&#8217;s one parameter for specifying the direction of movement, and both for horizontal and vertical movement you need to set the degree at which it should move. This degree should be an integer of 1 or higher. (The web control interface never submits values higher than 10, and I haven&#8217;t tested any either).<br />
I don&#8217;t think these commands can be used to do absolute movement.<br />
Theoretically, if you move 3 degrees up and 3 degrees left, then 5 degrees up and 9 degrees right, then 8 degrees down and 6 degrees left, you should be exactly at the point you started &#8211; I&#8217;m not sure how accurately this would work, but you might be pleasantly surprised. (preset positions don&#8217;t seem to wander over time, so moving relative distances might be accurate too).</p>
<p>On to the commands now. To move the camera 1 degree up and 1 left, you should send the following command in the POST body:</p>
<pre>PanSingleMoveDegree=1&amp;TiltSingleMoveDegree=1&amp;PanTiltSingleMove=1</pre>
<p>To send the camera 3 degrees to the right, send the following:</p>
<pre>PanSingleMoveDegree=3&amp;TiltSingleMoveDegree=0&amp;PanTiltSingleMove=5</pre>
<p>I hope you&#8217;re catching on. Here&#8217;s the complete table of movement directions that should be set with the PanTiltSingleMove parameter:</p>
<p>0 up left<br />
1 up<br />
2 up right<br />
3 left<br />
4 home<br />
5 right<br />
6 down left<br />
7 down<br />
8 down right</p>
<p>If you&#8217;re just tilting the camera (vertically), you can leave out the PanSingleMoveDegree parameter. Likewise, if you&#8217;re only panning the camera (horizontally), you can leave out the TiltSingleMoveDegree parameter. If you&#8217;re sending the camera to the Home position, you can leave out both.</p>
<p>Note that there&#8217;s no way to control the zoom! The IP400&#8242;s zoom is digital only. The java/activex interface and windows application all implement the zoom on the client side; the camera itself doesn&#8217;t know how to do this. So if you need the zoom (or the suggestion of a zoom), you&#8217;ll have to implement this yourself by cropping and resize the center of the video stream.</p>
<p>SWING MODES:</p>
<p>There are two swing modes that can be activated simply by passing the PanTiltSwingMode parameter and value to PANTILTCONTROL.CGI. The first scan mode will simply scan the room horizontally by panning it one step in every approx 1 second intervals until it reaches it&#8217;s left or right limit, then reverse direction. The swing mode will simply scan all preset positions and hold each position for a few seconds. I don&#8217;t think there&#8217;s any way to change the interval time for either swing mode, at least the decompiled camera java applet didn&#8217;t reveal any such options to me.</p>
<p>values for swing mode:</p>
<p>0 stop<br />
1 horizontal scan, move every second<br />
2 scan all preset positions</p>
<p>example:<br />
to put the camera into horizontal scan mode, send:</p>
<pre>PanTiltSwingMode=2</pre>
<p>PRESET POSITIONS:</p>
<p>To move to a preset position, send the following command:</p>
<pre>PanTiltPresetPositionMove=3</pre>
<p>substitute 3 for the position number that you want to move to. The camera supports 25 preset positions, 0 to 24.</p>
<p>To clear a position, send:</p>
<pre>ClearPosition=12</pre>
<p>this would clear position 12 (which is the 13th preset)</p>
<p>To set a preset position:</p>
<p>send the following command.</p>
<pre>PanTiltHorizontal=a&amp;PanTiltVertical=b&amp;SetName=myPosition&amp;SetPosition=12</pre>
<p>Where a and b would be the absolute values for the horizonal resp. vertical positions. There is some numbers juggling going on in the java applet of the webcam control application, and I haven&#8217;t made any attempts yet to reverse engineer this. All movement (except for movement to preset positions) is relative with this camera, and I am not sure that an absolute position can be calculated accurately from relative movements. As far as I know there&#8217;s only one way to get the current absolute position, which is actually through the mjpeg cgi, see below.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<strong>/IOCONTROL.CGI</strong></p>
<p>It appears that this CGI can be called to trigger the camera to upload or email a current camera snapshot. I only know this from decompiling the xplug class, and haven&#8217;t played around with it at at all.<br />
The parameter string should look like this (or at least that&#8217;s how the java applet sends it)</p>
<pre>Trigger1=0&amp;Trigger2=1&amp;ImageUpload=0&amp;ImageEmail=1</pre>
<p>where values of all 4 parameters should be either 0 or 1. You should call the CGI with the POST method, however, if you use the GET method (eg by simply entering the CGI url in your browser), it will answer with the current values of these parameters, like this:</p>
<pre>Trigger1=0&amp;Trigger2=0&amp;ImageUpload=0&amp;ImageEmail=0&amp;CurrentTime=2007-08-16 15:27:34</pre>
<p>(There&#8217;s no point in trying to set those properties in the GET request (with something like /IOCONTROL.CGI?ImageUpload=1) as the IP400 seems to ignore those: the camera apparently needs a POST request to receive parameters. )</p>
<p><strong>/MJPEG.CGI<br />
/VIDEO.CGI<br />
</strong><br />
(use GET request)<br />
Both these urls appear to return a MJPEG stream, which is basically just an endless stream of jpeg images with a short header in between. That header data looks like this:</p>
<pre>
--video boundary--Content-length: 10089
Date: 2007-08-16 14:56:19 IO_00000000_PT_136_046
Content-type: image/jpeg</pre>
<p>but the &#8216;Date&#8217; header isn&#8217;t present when using the VIDEO.CGI variant. The interesting thing about this Date header is that the last bit, the PT_136_046 actually indicates the current absolute Pan/Tilt position. The Ruby driver I&#8217;ve written for this camera can grab those coordinates from the stream, which is really only useful when you want to set a preset position.</p>
<p>You should be able to view the stream in a browser simply by using the address http://192.168.0.50/MJPEG.CGI (substitute the correct IP address of course).</p>
<p>Other than the missing Date header in the VIDEO.CGI response, there don&#8217;t seem to be any differences between these two streams. If you find any, please let me know.</p>
<p>By the way, the exact request that Trendnet&#8217;s xplug java applet sends to get the video stream is:</p>
<pre>GET /MJPEG.CGI HTTP/1.0\\r\\n
User-Agent: user\\r\\n
Authorization: Basic abcdefgrn\\r\\n</pre>
<p>where the authentication token is optional (but needed when you have user access control enabled in the camera). This token abcdefg should be the base64 encoded string of &#8216;username:password&#8217; as is standard for http basic authentication. It&#8217;s probably best if your request look exactly the same, and do make sure you end those headers with double carriage return and line feed, as illustrated.</p>
<p><strong>/IMAGE.JPG</strong></p>
<p>simply returns a jpeg of the current camera view, which is handy if you want to save a snapshot or display on clients that can&#8217;t handle streaming video.</p>
<p>If you need to grab a bunch of frames, want to convert the stream to another format or do any other magic with your camera view, I recommend you look at ffmpeg and imagemagick.</p>
<p>Here&#8217;s an example of how to save the first image from the mjpeg stream to an image:</p>
<pre>ffmpeg -f mjpeg -i http://192.168.0.50/MJPEG.CGI -vframes 1 -an -s 320x240 cam%d.jpg</pre>
<p>It will save multiple jpgs if you increase the vframes value, but if you want to do that it would be better to output to another video format then to output to jpg.</p>
<p>Having written all this: you may not need to know any of this since I&#8217;ve written two drivers, one Ruby and one ZoneMinder driver that can be used on any platform that supports Perl or Ruby. I&#8217;ll post the code for the ruby driver as soon as it&#8217;s ready.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sfpeter.com/2007/08/19/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

