<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7930503742612524451</id><updated>2011-04-21T18:29:09.013-07:00</updated><category term='wiimote'/><category term='gaming'/><title type='text'>Dave's Programming Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://davepeake.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://davepeake.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dave Peake</name><uri>http://www.blogger.com/profile/07992796011959709147</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7930503742612524451.post-3865667523841004046</id><published>2009-01-11T22:20:00.000-08:00</published><updated>2009-01-11T22:24:06.455-08:00</updated><title type='text'>Sending Commands to a Detached Screen Session</title><content type='html'>A quick note about sending commands to a detached &lt;a href="http://en.wikipedia.org/wiki/GNU_Screen"&gt;screen&lt;/a&gt; session, good for using in start up scripts:&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&gt; screen -dmS [session name]&lt;br /&gt;&gt; screen -S [session name] -p 0 -X stuff [command^M]&lt;br /&gt;&lt;br /&gt;where:&lt;br /&gt;-d -m , means detach the session immediately, but fork off a new process, like a standard screen incarnation&lt;br /&gt;-S sets a more human readable / sensible name for the screen session&lt;br /&gt;&lt;br /&gt;-p 0 sets the targetted window within the screen session to be 0, neccessary if you haven't attached and detached from the session yet.&lt;br /&gt;&lt;br /&gt;-X stuff sends the command to the nominated screen session. Not sure what the "stuff" part does.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7930503742612524451-3865667523841004046?l=davepeake.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://davepeake.blogspot.com/feeds/3865667523841004046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7930503742612524451&amp;postID=3865667523841004046' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default/3865667523841004046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default/3865667523841004046'/><link rel='alternate' type='text/html' href='http://davepeake.blogspot.com/2009/01/sending-commands-to-detached-screen.html' title='Sending Commands to a Detached Screen Session'/><author><name>Dave Peake</name><uri>http://www.blogger.com/profile/07992796011959709147</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7930503742612524451.post-4061461917954255282</id><published>2008-12-30T20:13:00.000-08:00</published><updated>2009-01-01T20:05:01.607-08:00</updated><title type='text'>Using Python Urllib2 to retrieve quotes from bash.org</title><content type='html'>&lt;!-- Generator: GNU source-highlight 2.4 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --&gt;This is a simple (read &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;brain dead&lt;/span&gt;) script I wrote to pull down specified quotes from &lt;a href="http://bash.org/"&gt;bash.org&lt;/a&gt; (the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;IRC&lt;/span&gt; Quote Database). The script is below and should be fairly self &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;explanatory&lt;/span&gt;. The only caveat is that you may not want to replace the web specific characters if you plan on using this to put random quotes onto a web page.&lt;br /&gt;&lt;pre&gt;&lt;tt&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;'''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;bashquote&lt;/span&gt;.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;py&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;A simple python script to retrieve quotes from the&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;IRC&lt;/span&gt; quote database, www.bash.org.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;'''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 128);"&gt;import&lt;/span&gt;&lt;/b&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;urllib&lt;/span&gt;2&lt;br /&gt;&lt;br /&gt;bash&lt;span style="color: rgb(0, 153, 0);"&gt;_&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;str&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;'http://www.bash.org/?'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;rand&lt;span style="color: rgb(0, 153, 0);"&gt;_&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;str&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;'http://www.bash.org/?random'&lt;/span&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;findstr&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;'&lt;p class="qt"&gt;'&lt;/span&gt;&lt;br /&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;endstr&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;'&lt;/p&gt;'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;def&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;get_quote&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;num&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    '''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    Returns the specified quote from bash.org&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    '''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;buff &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;join&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;urllib&lt;/span&gt;2&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;urlopen&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;bash&lt;span style="color: rgb(0, 153, 0);"&gt;_&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;str&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;str&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;num&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)).&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;readlines&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;())&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;# Check to see if the quote was rejected&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;/b&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;buff&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;find&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'Quote #'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;str&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;num&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)+&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;' was rejected'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;-&lt;/span&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;/b&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;''&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;/b&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;buff&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;find&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'Quote #'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;str&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;num&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)+&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;' does not exist'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;-&lt;/span&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;/b&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;''&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;st &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; buff&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;find&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;findstr&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;en &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; st &lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt; buff&lt;span style="color: rgb(153, 0, 0);"&gt;[&lt;/span&gt;st&lt;span style="color: rgb(153, 0, 0);"&gt;:].&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;find&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;endstr&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;quote &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; buff&lt;span style="color: rgb(153, 0, 0);"&gt;[&lt;/span&gt;st&lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;len&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_27"&gt;findstr&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;en&lt;span style="color: rgb(153, 0, 0);"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;dodgy_char_swap&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;quote&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;def&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;get_random&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_28"&gt;posrating&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(153, 51, 153);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    '''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    Returns a random quote from bash.org&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;Posrating&lt;/span&gt; = 1: Only select from quotes with rating &amp;gt; 0&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;              = 0: Select from all quotes.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    '''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;/b&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;posrating&lt;/span&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;!=&lt;/span&gt; &lt;span style="color: rgb(153, 51, 153);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;:&lt;/span&gt;&lt;br /&gt;    buff &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;join&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;urllib&lt;/span&gt;2&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;urlopen&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;rand&lt;span style="color: rgb(0, 153, 0);"&gt;_&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;str&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'1'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;).&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;readlines&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;())&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;:&lt;/span&gt;&lt;br /&gt;    buff &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;""&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;join&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;urllib&lt;/span&gt;2&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;urlopen&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;rand&lt;span style="color: rgb(0, 153, 0);"&gt;_&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_37"&gt;str&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;).&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_38"&gt;readlines&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;())&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;st &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; buff&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;find&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_39"&gt;findstr&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;en &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; st &lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt; buff&lt;span style="color: rgb(153, 0, 0);"&gt;[&lt;/span&gt;st&lt;span style="color: rgb(153, 0, 0);"&gt;:].&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;find&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_40"&gt;endstr&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;quote &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; buff&lt;span style="color: rgb(153, 0, 0);"&gt;[&lt;/span&gt;st&lt;span style="color: rgb(153, 0, 0);"&gt;+&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_41"&gt;len&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_42"&gt;findstr&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;en&lt;span style="color: rgb(153, 0, 0);"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;dodgy_char_swap&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;quote&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;def&lt;/span&gt;&lt;/b&gt; &lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;dodgy_char_swap&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;quote&lt;span style="color: rgb(153, 0, 0);"&gt;):&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    '''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    Swaps out some dodgy characters, using the replace&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    method of the string class.&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;    '''&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;quote &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; quote&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;replace&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'&lt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_44"&gt;br&gt;&lt;/span&gt;'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;''&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; &lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;# line break&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;quote &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; quote&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;replace&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'&amp;amp;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_45"&gt;lt&lt;/span&gt;;'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'&lt;'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; &lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;# less than&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;quote &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; quote&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;replace&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'&amp;gt;'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'&gt;'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; &lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;# greater than&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;quote &lt;span style="color: rgb(153, 0, 0);"&gt;=&lt;/span&gt; quote&lt;span style="color: rgb(153, 0, 0);"&gt;.&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;replace&lt;/span&gt;&lt;/b&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'\r\n'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;'\n'&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;)&lt;/span&gt; &lt;i&gt;&lt;span style="color: rgb(154, 25, 0);"&gt;# line feed&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;/b&gt; quote&lt;br /&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7930503742612524451-4061461917954255282?l=davepeake.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://davepeake.blogspot.com/feeds/4061461917954255282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7930503742612524451&amp;postID=4061461917954255282' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default/4061461917954255282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default/4061461917954255282'/><link rel='alternate' type='text/html' href='http://davepeake.blogspot.com/2008/12/using-python-urllib2-to-retrieve-quotes.html' title='Using Python Urllib2 to retrieve quotes from bash.org'/><author><name>Dave Peake</name><uri>http://www.blogger.com/profile/07992796011959709147</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7930503742612524451.post-7902143268387318350</id><published>2008-10-26T18:21:00.000-07:00</published><updated>2008-10-26T18:59:26.624-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wiimote'/><category scheme='http://www.blogger.com/atom/ns#' term='gaming'/><title type='text'>Using a Wiimote and GlovePIE to control Neverball on Windows</title><content type='html'>This is only for Windows at the moment, I have yet to try this on Linux&lt;br /&gt;&lt;br /&gt;You will need:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A &lt;a href="http://en.wikipedia.org/wiki/Wiimote"&gt;Wiimote&lt;/a&gt; and a &lt;a href="http://en.wikipedia.org/wiki/Bluetooth"&gt;bluetooth &lt;/a&gt;connection on your computer. I used the Toshiba  BT stack with my Dell D430.&lt;a href="http://en.wikipedia.org/wiki/Wiimote"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Neverball (official page &lt;a href="http://icculus.org/neverball/"&gt;here&lt;/a&gt;, I downloaded it from &lt;a href="http://files.filefront.com/Neverball+v140+Windows+Zip/;6346280;/fileinfo.html"&gt;here&lt;/a&gt; since the links on the offical page were broken for me.)&lt;/li&gt;&lt;li&gt;&lt;a href="http://carl.kenner.googlepages.com/glovepie"&gt;GlovePIE&lt;/a&gt; which is glue software for connecting the Wiimote to various input devices like keyboards, mice and joypads.&lt;a href="http://carl.kenner.googlepages.com/glovepie"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.geocities.com/deonvdw/PPJoy.htm"&gt;PPJoy&lt;/a&gt;, a program which allows the creation of virtual joysticks which GlovePIE can control.&lt;/li&gt;&lt;/ol&gt;The first thing to do is to pair your Wiimote with the bluetooth stack on your computer. To put your Wiimote into discovery mode, press the 1+2 buttons on the controller, until the player number LEDs all start flashing. Run your bluetooth software, and search for a new device. It should find a Human Interface Device (HID) with a name which contains "Nintendo". Pair it with this device. On my computer no pairing code was needed, but if it requests one, try "0000".&lt;br /&gt;&lt;br /&gt;Now we have our Wiimote talking to the computer, we need to install the software to make the Wiimote talk to Neverball.&lt;br /&gt;&lt;br /&gt;First install PPJoy, making sure to continue when Windows complains that the drivers aren't signed. PPJoy was originally designed to allow Parallel Port joysticks to be used under windows, but we are going to be using it's virtual joystick functionality to make the operating system think it has a joystick installed while we emulate the joypad with GlovePIE.&lt;br /&gt;&lt;br /&gt;After the PPJoy has been installed run the PPJoy control panel and add a virtual joystick with 8 axes, 32 buttons and 2 POV hats (for Neverball we only need a few of these, but it will be good to make them all available to GlovePIE for later extensions). After the joystick has been created, be sure to go to "Game Controllers" in the control panel and make the new joystick your default. Neverball automatically uses the default controller (though it is possible to change through a settings file)&lt;br /&gt;&lt;br /&gt;Now we can install and run GlovePIE. GlovePIE is a fantastic program for interfacing many different inputs to many different outputs. If you have time it is a powerful program, a lot of the basics of GlovePIE are outlined &lt;a href="http://www.wiili.org/index.php/GlovePIE"&gt;here&lt;/a&gt;. For now though we will just use a script which can be found &lt;a href="http://www.wiili.org/index.php?title=GlovePIE:Neverball&amp;amp;redirect=no"&gt;here&lt;/a&gt;. Download and open the script in GlovePIE. Hit run and you should see the debug panel contain something like: "X: -0.13 ; Z: 0.04". These number correspond to the roll and pitch of your Wiimote. You can change the calibration numbers in the first two lines to compensate for any offsets. They debug window should read 0 for each axis when the Wiimote is place on a flat, level surface.&lt;br /&gt;&lt;br /&gt;So now we have the Wiimote talking to the Bluetooth stack which is talking to GlovePIE which in turn is talking to the joypad through PPJoy. Now we just need to run Neverball. I have read reports of Neverball working out of the box with joypads, but in order for me to get it to recognise the joypad I had to change a line in the Neverball configuration file.&lt;br /&gt;&lt;br /&gt;The file is found in "[Neverball Installation Directory]/data/.neverball/neverballrc". The line we want to change is:&lt;br /&gt;&lt;br /&gt;joystick 0&lt;br /&gt;&lt;br /&gt;which we change to&lt;br /&gt;&lt;br /&gt;joystick 1&lt;br /&gt;&lt;br /&gt;Now save the file, and open up Neverball.&lt;br /&gt;&lt;br /&gt;The Wiimote should be mapped so that the axes rotate the board, while the B button is "mouse click" and the A button is ESC. The D-pad is also mapped as the arrow keys. The camera can be rotated using  - and +.&lt;br /&gt;&lt;br /&gt;Here is an example of someone (not me) using a Wiimote with Neverball.&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Ng46W_8UKDg&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;embed src="http://www.youtube.com/v/Ng46W_8UKDg&amp;amp;hl=en&amp;amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7930503742612524451-7902143268387318350?l=davepeake.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://davepeake.blogspot.com/feeds/7902143268387318350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7930503742612524451&amp;postID=7902143268387318350' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default/7902143268387318350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7930503742612524451/posts/default/7902143268387318350'/><link rel='alternate' type='text/html' href='http://davepeake.blogspot.com/2008/10/using-wiimote-and-glovepie-to-control.html' title='Using a Wiimote and GlovePIE to control Neverball on Windows'/><author><name>Dave Peake</name><uri>http://www.blogger.com/profile/07992796011959709147</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
