<?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>Chris Haynie</title>
	<atom:link href="http://chrishaynie.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrishaynie.com</link>
	<description>I&#039;ll fix it when its not broken</description>
	<lastBuildDate>Thu, 26 Aug 2010 23:38:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Clipboard Snippeteering</title>
		<link>http://chrishaynie.com/2010/08/clipboard-snippeteering/</link>
		<comments>http://chrishaynie.com/2010/08/clipboard-snippeteering/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 23:36:48 +0000</pubDate>
		<dc:creator>sax</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://chrishaynie.com/?p=114</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I work in IT and frequently you may need to send someone a screenshot. Maybe its the configuration screen you&#8217;re looking at or the output of a command.  As many of you know this procedure usually involves hitting print-screen on your keyboard, pasting it into a photo editor like ms-paint, saving it as a jpeg and what&#8230; do you send it over IM with a direct connection? email it to them? I wanted a solution where I can easily take a screenshot of just an area of the screen, or the entire screen if I choose and have it automatically upload the screenshot to a webserver, and allow me to paste the URL to the screenshot instantly.  Ideally, I would have it even put the URL IN my clipboard as well, as it turns out this is all exactly what I accomplished.</p>
<p><a href="http://dl.getdropbox.com/u/3636969/chrishaynie.com/wp-content/uploads/2010/08/66b1c38661258dc3b201c52f0035956b.jpg"><img src="http://dl.getdropbox.com/u/3636969/chrishaynie.com/wp-content/uploads/2010/08/66b1c38661258dc3b201c52f0035956b-300x183.jpg" alt="Screenshot Utility in CompizConfig Settings Manager" title="Screenshot Utility in CompizConfig Settings Manager" width="300" height="183" class="alignright size-medium wp-image-117" /></a></p>
<p>I run Ubuntu on my workstation with compiz. You will need to install compizconfig-settings-manager, xsel, and ImageMagick for this all to work. Below is the script to perform the screenshot auto-magic, when combined with the compiz screenshot plugin.  I press the windows key on my keyboard and then click+drag I have an instant screenshot.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">FNAME</span>=<span style="color: #ff0000;">&quot;/home/chrisha/Documents/snippets/<span style="color: #007800;">$(date +%s|md5sum|awk '{print $1}')</span>.jpg&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert <span style="color: #660033;">-bordercolor</span> white <span style="color: #660033;">-border</span> <span style="color: #000000;">5</span> $<span style="color: #000000;">1</span> $<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert <span style="color: #660033;">-bordercolor</span> black <span style="color: #660033;">-border</span> <span style="color: #000000;">1</span> $<span style="color: #000000;">1</span> $<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert <span style="color: #660033;">-quality</span> <span style="color: #000000;">75</span> $<span style="color: #000000;">1</span> <span style="color: #007800;">$FNAME</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #007800;">$FNAME</span> slice:public_html<span style="color: #000000; font-weight: bold;">/</span>dev.chrishaynie.com<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>snippets<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> http:<span style="color: #000000; font-weight: bold;">//</span>slice.chrishaynie.com<span style="color: #000000; font-weight: bold;">/</span>snippets<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$FNAME</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">|</span>xsel <span style="color: #660033;">-i</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">1</span></pre></div></div>

<p>Now then, lets say you want to send a large block of text &#8211; maybe its a snippet of code, maybe its the output of a command. Taking a screenshot of text isn&#8217;t verfy efficient, which we can agree. Traditional solutions have been just pasting it into the chat window and spamming the receiver, using sites like pastebin.com, but now your text is publicly available, maybe you&#8217;re wanting to send a snippet of some proprietary code or personal conversation.</p>
<p>My buddy Tim over at http://h1tman.com/ advanced my above screenshot auto-upload to include text excerpts, which get uploaded as plain-text.  You bind his script to a keyboard shortcut and from there, you select the text, hit the keyboard shortcut and you&#8217;re off and running. You can read his full howto in depth here http://www.h1tman.com/2010/08/clipboard-hacks-social-copypasta</p>
<p>Now we get to the good part, I&#8217;ve combined both my original &#8220;screenshotuploader&#8221; with Tim&#8217;s &#8220;textshot&#8221; into what I&#8217;m going to call snippets. Use the same script in the screenshot plugin and in your keyboard shortcut for textshots, use the same url and same folder to store them all, in one combined script below.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">DIR</span>=<span style="color: #ff0000;">&quot;/home/chrisha/Documents/snippets/&quot;</span>
<span style="color: #007800;">HOST</span>=<span style="color: #ff0000;">&quot;slice.chrishaynie.com&quot;</span>
<span style="color: #007800;">HASH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date +%s|md5sum|awk '{print $1}')</span>&quot;</span>
<span style="color: #007800;">FNAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DIR</span><span style="color: #007800;">$HASH</span>&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">FNAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$FNAME</span>.txt&quot;</span>
	xsel<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #007800;">$FNAME</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">FNAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$FNAME</span>.jpg&quot;</span>
	<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert <span style="color: #660033;">-bordercolor</span> white <span style="color: #660033;">-border</span> <span style="color: #000000;">5</span> $<span style="color: #000000;">1</span> $<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert <span style="color: #660033;">-bordercolor</span> black <span style="color: #660033;">-border</span> <span style="color: #000000;">1</span> $<span style="color: #000000;">1</span> $<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert <span style="color: #660033;">-quality</span> <span style="color: #000000;">75</span> $<span style="color: #000000;">1</span> <span style="color: #007800;">$FNAME</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #007800;">$FNAME</span> <span style="color: #007800;">$HOST</span>:public_html<span style="color: #000000; font-weight: bold;">/</span>dev.chrishaynie.com<span style="color: #000000; font-weight: bold;">/</span>html<span style="color: #000000; font-weight: bold;">/</span>snippets<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> http:<span style="color: #000000; font-weight: bold;">//</span>slice.chrishaynie.com<span style="color: #000000; font-weight: bold;">/</span>snippets<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$FNAME</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">|</span>xsel <span style="color: #660033;">-i</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishaynie.com/2010/08/clipboard-snippeteering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome OS</title>
		<link>http://chrishaynie.com/2009/11/chrome-os/</link>
		<comments>http://chrishaynie.com/2009/11/chrome-os/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 17:42:33 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://chrishaynie.com/?p=102</guid>
		<description><![CDATA[I&#8217;ve been playing with google&#8217;s Chromium-OS lately, following the instructions here I was able to get it booted off my eee-pc Netbook. In order to build it I first created a virtual machine on and installed a fresh copy of &#8230; <a href="http://chrishaynie.com/2009/11/chrome-os/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with google&#8217;s Chromium-OS lately, following the instructions <a href="http://sites.google.com/a/chromium.org/dev/chromium-os/building-chromium-os/build-instructions">here</a> I was able to get it booted off my eee-pc Netbook. In order to build it I first created a virtual machine on and installed a fresh copy of Ubuntu 9.10 (Karmic).</p>
<p><a href="http://dl.getdropbox.com/u/3636969/chrishaynie.com/wp-content/uploads/2009/11/chrome_os_eeepc.jpg"><img class="alignnone size-medium wp-image-104" title="chrome_os_eeepc" src="http://dl.getdropbox.com/u/3636969/chrishaynie.com/wp-content/uploads/2009/11/chrome_os_eeepc-225x300.jpg" alt="chrome_os_eeepc" width="225" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://chrishaynie.com/2009/11/chrome-os/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python Threading</title>
		<link>http://chrishaynie.com/2009/06/python-threading/</link>
		<comments>http://chrishaynie.com/2009/06/python-threading/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 21:14:31 +0000</pubDate>
		<dc:creator>sax</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://chrishaynie.com/?p=94</guid>
		<description><![CDATA[In order to speed up some of my scripts I&#8217;ve implemented threading using python. Some scripts now run in 1/10th the time they used to as a result.  Here I will try to illustrate some of the key points, hopefully &#8230; <a href="http://chrishaynie.com/2009/06/python-threading/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In order to speed up some of my scripts I&#8217;ve implemented threading using python. Some scripts now run in 1/10th the time they used to as a result.  Here I will try to illustrate some of the key points, hopefully it will be useful to anyone.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">threading</span> <span style="color: #ff7700;font-weight:bold;">import</span> Thread
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> MyThread<span style="color: black;">&#40;</span>Thread<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,server,<span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
        Thread.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">server</span> = server
        <span style="color: #008000;">self</span>.<span style="color: #dc143c;">cmd</span> = <span style="color: #dc143c;">cmd</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">status</span> = -<span style="color: #ff4500;">1</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> run<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        proc = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ssh %s %s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">server</span>,<span style="color: #008000;">self</span>.<span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>,
                       shell=<span style="color: #008000;">True</span>,
                       stdin=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span>,
                       stdout=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span>,
                       stderr=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">STDOUT</span>,
                       <span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">stdout</span>, <span style="color: #008000;">self</span>.<span style="color: black;">stderr</span> = proc.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
servers = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'shell1.example.net'</span>,<span style="color: #483d8b;">'ssh2.mhost.com'</span>,<span style="color: #483d8b;">'examplebox.net'</span><span style="color: black;">&#93;</span>
command = <span style="color: #483d8b;">'uptime'</span>
cmdlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> srv <span style="color: #ff7700;font-weight:bold;">in</span> servers:
    run = MyThread<span style="color: black;">&#40;</span>srv,command<span style="color: black;">&#41;</span>
    cmdlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>run<span style="color: black;">&#41;</span>
    run.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> cmdlist:
    c.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;### %s:n%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>c.<span style="color: black;">server</span>,c.<span style="color: black;">stdout</span><span style="color: black;">&#41;</span>,
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;## Done&quot;</span></pre></div></div>

<p>In my example we loop through servers[] and for each server[] we run the specified command on them, in their own thread! 3 servers in the above example, not a big deal, what if you have 20 servers? 40 servers? huge speed improvement.</p>
<p>The script can be easily extended to say&#8230; read the servers list in from a configuration file, or accept the &#8216;command&#8217; from the command line arguments, (argv[1:]) etc.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrishaynie.com/2009/06/python-threading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bluetooth Proximity Lock for Macbook</title>
		<link>http://chrishaynie.com/2008/11/bluetooth-proximity-lock-for-macbook/</link>
		<comments>http://chrishaynie.com/2008/11/bluetooth-proximity-lock-for-macbook/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 00:34:43 +0000</pubDate>
		<dc:creator>sax</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.chrishaynie.com/?p=26</guid>
		<description><![CDATA[I wanted to have my macbook automatically lock and unlock based on if I am in the room or not automatically. Best way to do that I figured would be bluetooth, since I always have my phone on me, and &#8230; <a href="http://chrishaynie.com/2008/11/bluetooth-proximity-lock-for-macbook/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wanted to have my macbook automatically lock and unlock based on if I am in the room or not automatically. Best way to do that I figured would be bluetooth, since I always have my phone on me, and it has bluetooth. From there I proceeded to google.</p>
<p><a title="http://web.mac.com/jhollington/technocrat/The_Technocrat/Entries/2007/3/18_Bluetooth_Proximity_Detection_on_OS_X.html" href="http://web.mac.com/jhollington/technocrat/The_Technocrat/Entries/2007/3/18_Bluetooth_Proximity_Detection_on_OS_X.html">http://web.mac.com/jhollington/technocrat/The_Technocrat/Entries/2007/3/18_Bluetooth_Proximity_Detection_on_OS_X.html</a></p>
<p>Pointed me to</p>
<p><a title="http://www.apple.com/downloads/macosx/system_disk_utilities/proximity.html" href="http://www.apple.com/downloads/macosx/system_disk_utilities/proximity.html">http://www.apple.com/downloads/macosx/system_disk_utilities/proximity.html</a></p>
<p>he also includes a script to automate syncing your phone book and such too</p>
<p>Another utility in my searching, is called JackSMS</p>
<p><a title="http://www.macupdate.com/info.php/id/21860" href="http://www.macupdate.com/info.php/id/21860">http://www.macupdate.com/info.php/id/21860</a></p>
<p>JackSMS does some cool stuff like, say someone tries to access your laptop while you&#8217;re not there &#8211; the built in isight camera will take their picture and email it then, so I wanted to use JackSMS as well.</p>
<p>Proximity allows you to set scripts for when you arrive or when you leave, so here are the applescripts I used:</p>
<p>lock.scpt:</p>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;">﻿<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;JackSMS&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> lock screen <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span></pre></div></div>

<p>unlock.scpt:</p>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;">﻿<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;JackSMS&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> lock screen <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span></pre></div></div>

<p>courtesy of: <a title="http://www.macosxhints.com/article.php?story=2006061914363693" href="http://www.macosxhints.com/article.php?story=2006061914363693">http://www.macosxhints.com/article.php?story=2006061914363693</a></p>
<p>update: a better proximity script, copied below, courtesy of:<br />
<a title="http://pixelignition.net/better-proximity-applescript" href="http://pixelignition.net/better-proximity-applescript"> http://pixelignition.net/better-proximity-applescript</a><br />
lock.scpt:<br />
<a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1760214964'), this, 'Show &#9660;', 'Hide &#9650;');">Show &#9660;</a></p>
<div id='SID1760214964' style='display:none;'>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">global</span> okflag
<span style="color: #ff0033; font-weight: bold;">set</span> okflag <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span>
<span style="color: #ff0033; font-weight: bold;">set</span> front_app <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">path to</span> frontmost <span style="color: #0066ff;">application</span> <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span><span style="color: #000000;">&#41;</span> <span style="color: #808080; font-style: italic;">-- So we can switch back to this after running the fade</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- check if iTunes is running</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> process <span style="color: #009900;">&quot;iTunes&quot;</span> <span style="color: #0066ff;">exists</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> okflag <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span> <span style="color: #808080; font-style: italic;">--iTunes is running</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
&nbsp;
<span style="color: #ff0033; font-weight: bold;">if</span> okflag <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #0066ff;">true</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">try</span>
                <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> currentvolume <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> sound volume
                        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>player state <span style="color: #ff0033; font-weight: bold;">is</span> playing<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                                <span style="color: #ff0033; font-weight: bold;">repeat</span>
                                        <span style="color: #808080; font-style: italic;">--Fade down</span>
                                        <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> currentvolume <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">0</span> <span style="color: #0066ff;">by</span> <span style="color: #000000;">-</span><span style="color: #000000;">1</span> <span style="color: #808080; font-style: italic;">--try by -4 on slower Macs</span>
                                                <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> sound volume <span style="color: #ff0033; font-weight: bold;">to</span> i
                                                delay <span style="color: #000000;">0.01</span> <span style="color: #808080; font-style: italic;">-- Adjust this to change fadeout duration (delete this line on slower Macs)</span>
                                        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
                                        pause
                                        <span style="color: #808080; font-style: italic;">--Restore original volume</span>
                                        <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> sound volume <span style="color: #ff0033; font-weight: bold;">to</span> currentvolume
                                        <span style="color: #ff0033; font-weight: bold;">exit</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
                                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
                                <span style="color: #ff0033; font-weight: bold;">set</span> comment <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Proximity Paused&quot;</span>
                        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
                <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> front_app
                        <span style="color: #0066ff;">activate</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
                <span style="color: #0066ff;">beep</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;JackSMS&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> jack status <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;on&quot;</span>
delay <span style="color: #000000;">1</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;DeskShade&quot;</span>
        lock
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">run</span></pre></div></div>

</div>
<p>unlock.scpt:<br />
<a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1467790486'), this, 'Show &#9660;', 'Hide &#9650;');">Show &#9660;</a></p>
<div id='SID1467790486' style='display:none;'>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;ScreenSaverEngine&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quit</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;DeskShade&quot;</span>
        unlock
        <span style="color: #0066ff;">quit</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;JackSMS&quot;</span>
        <span style="color: #0066ff;">quit</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">global</span> okflag
<span style="color: #ff0033; font-weight: bold;">set</span> okflag <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span>
<span style="color: #ff0033; font-weight: bold;">set</span> front_app <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">path to</span> frontmost <span style="color: #0066ff;">application</span> <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span><span style="color: #000000;">&#41;</span> <span style="color: #808080; font-style: italic;">-- So we can switch back to this after running the fade</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-- check if iTunes is running</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> process <span style="color: #009900;">&quot;iTunes&quot;</span> <span style="color: #0066ff;">exists</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> okflag <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span> <span style="color: #808080; font-style: italic;">--iTunes is running</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">if</span> okflag <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #0066ff;">true</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">try</span>
                <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> currentvolume <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> sound volume
                        <span style="color: #ff0033; font-weight: bold;">if</span> comment <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Proximity Paused&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                                <span style="color: #ff0033; font-weight: bold;">set</span> comment <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
                                play
                                <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> j <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">0</span> <span style="color: #ff0033; font-weight: bold;">to</span> currentvolume <span style="color: #0066ff;">by</span> <span style="color: #000000;">2</span> <span style="color: #808080; font-style: italic;">--try by 4 on slower Macs</span>
                                        <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> sound volume <span style="color: #ff0033; font-weight: bold;">to</span> j
                                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
                        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
                <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> front_app
                        <span style="color: #0066ff;">activate</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
                <span style="color: #0066ff;">beep</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span></pre></div></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://chrishaynie.com/2008/11/bluetooth-proximity-lock-for-macbook/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jimmy</title>
		<link>http://chrishaynie.com/2008/11/jimmy/</link>
		<comments>http://chrishaynie.com/2008/11/jimmy/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 06:25:29 +0000</pubDate>
		<dc:creator>sax</dc:creator>
				<category><![CDATA[Humour]]></category>
		<category><![CDATA[joke]]></category>
		<category><![CDATA[wit]]></category>

		<guid isPermaLink="false">http://linode.chrishaynie.com/blog/?p=10</guid>
		<description><![CDATA[So he said &#8220;She tried to call earlier, but was at dinner and didn&#8217;t have service.&#8221; So I said, &#8220;Oh, so it was a Buffet?&#8221;]]></description>
			<content:encoded><![CDATA[<p>So he said &#8220;She tried to call earlier, but was at dinner and didn&#8217;t have service.&#8221;</p>
<p>So I said, &#8220;Oh, so it was a Buffet?&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://chrishaynie.com/2008/11/jimmy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code test</title>
		<link>http://chrishaynie.com/2008/11/code-test/</link>
		<comments>http://chrishaynie.com/2008/11/code-test/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 05:55:47 +0000</pubDate>
		<dc:creator>sax</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://linode.chrishaynie.com/blog/?p=3</guid>
		<description><![CDATA[Test public class Hello &#123; public static void main&#40;String&#91;&#93; args&#41; &#123; System.out.println&#40;&#34;Hello World!&#34;&#41;; &#125; &#125; class Example def example&#40;arg1&#41; return &#34;Hello: &#34; + arg1.to_s end end]]></description>
			<content:encoded><![CDATA[<p>Test</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Hello <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello World!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Example
  <span style="color:#9966CC; font-weight:bold;">def</span> example<span style="color:#006600; font-weight:bold;">&#40;</span>arg1<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;Hello: &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> arg1.<span style="color:#9900CC;">to_s</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://chrishaynie.com/2008/11/code-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
