Sanity Checking my new Arduino Uno Board
Quick sanity check of my new Arduino board using a LED Bar Graph.
Here is the sketch I will be using.
int led1 = 8; int led2 = 9; int counter = 0;void setup() {
// initialize the digital pin as an output. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT);
}void loop() {
if (counter & 1) { digitalWrite(led1, HIGH); } else { digitalWrite(led1, LOW); }
Bashing about the command line
Doodle's Geek Monkey by Alastair Montgomery
Using Ruby to send commands over SSH
Doing a lot of work on remote Linux servers lately, lots of login in over SSH running commands logging out.
So wrote this simple script to use Ruby to send a single command or a file of commands to a Linux server over SSH. Needs some error trapping etc but functional at the moment.
It requires the Ruby Gem net-ssh installed.
#!/usr/bin/ruby
require 'rubygems'
require 'net/ssh'
require 'optparse'
opts = OptionParser.new
opts.on("-h HOSTNAME", "--hostname NAME", String, "Hostname of Server") { |v| @hostname = v }
opts.on("-u SSH USERNAME", "--username SSH USERNAME", String, "SSH Username of Server") { |v| @username = v }
opts.on("-p SSH PASSWORD", "--password SSH PASSWORD", String, "SSH Password of Server") { |v| @password = v }
opts.on("-c SHELL_COMMAND", "--command SHELL_COMMAND", String, "Shell Command to Execute") { |v| @cmd = v }
opts.on("-f FILE_COMMAND", "--command FILE_COMMAND", String, "File containing shell Commands to Execute") { |v| @fileCmd = v }
begin
opts.parse!(ARGV)
rescue OptionParser::ParseError => e
puts e
end
raise OptionParser::MissingArgument, "Hostname [-h]" if @hostname.nil?
raise OptionParser::MissingArgument, "SSH Username [-u]" if @username.nil?
raise OptionParser::MissingArgument, "SSH Password [-p]" if @password.nil?
raise OptionParser::MissingArgument, "Command to Execute [-c/-f]" if @cmd.nil? and @fileCmd.nil?
begin
ssh = Net::SSH.start(@hostname, @username, :password => @password)
if @cmd != nil then
ssh.exec!(@cmd) do |ch, stream, data|
if stream == :stderr
puts "ERROR: #{data}"
else
puts data
end
end
else
puts "Processing file #{@fileCmd}"
file = File.new(@fileCmd, "r")
file.each {|line|
ssh.exec!(line) do |ch, stream, data|
if stream == :stderr
puts "ERROR: #{data}"
else
puts data
end
end
}
file.close
end
ssh.close
rescue Exception => e
puts "Unable to connect to #{@hostname} using #{@username}/#{@password}"
puts e
end
Doodle's Geek Monkey by Alastair Montgomery
3d Printing the future
Note: 1 of this post’s 7 links are now broken — mostly dead 2008–2013 feed-syndication infrastructure (FeedBurner, Gawker, AOL’s old blog network, Pheedo, Yahoo Pipes). Left as originally published.
First boot
http://instagr.am/p/MOCHVnN-hg/
First boot of my Raspberry Pi.
Feel like I'm ten again sat in front of the TV with my Acorn Electron
Raspberry Pi SD Card problems
Was going to fire up my Raspberry Pi for the first time yesterday but had issues creating boot SD card for it on Windows 7. As you can see here from my post at the Pi Forum.
Looks like it was either problems with my desktop or the SD Card reader I was using as it was getting write errors when using the two Windows methods of creating the boot image.
Hopefully I can get the SD card reformat with GParted so I can try again, most annoying that I tripped up at the first hurdle.
Doodle's Geek Monkey by Alastair Montgomery
Cloud Gaming
Not only does it work fine with the wired desktop and wifi laptop at home, I've also played some games on my Motorola Atrix, although I'd need a bluetooth controller to make full use of it on the phone.
http://www.onlive.co.uk/
Doodle's Geek Monkey by Alastair Montgomery
Raspberry Pi unwrapped
It finally arrived, my Raspberry Pi, lots of geeky fun awaits.
Can't believe how small it is :)
Problems running Firefox 5 from watir-webdriver on Mac OS 10.5
To my horror there is a bug in Firefox 4 and 5 which causes problems when attempting to start Firefox from the command line (basically what watir-webdriver does).
Thankfully with the help of Jarib Bakken I was able to use the workaround detailed on this blog post.
The work around is to strip the x86_64 part from firefox-bin using ditto:
cd /Applications/Firefox.app/Contents/MacOS
mv firefox-bin firefox-bin.original
ditto --arch i386 firefox-bin.original firefox-bin
This will solve the problem until we can upgrade to a later version of Mac Os.
Doodle's Geek Monkey by Alastair Montgomery
Ruby and RSS
Note: 1 of this post’s 4 links are now broken — mostly dead 2008–2013 feed-syndication infrastructure (FeedBurner, Gawker, AOL’s old blog network, Pheedo, Yahoo Pipes). Left as originally published.
Accessing an RSS Feed is as simple as the following code snippet.
require "rss"
rss_feed = "http://meekgonkey.blogspot.com/feeds/posts/default?alt=rss"
rss_content = ""
open(rss_feed) { |f|
rss_content = f.read
}
puts "Bytes read #{rss_content.length} from feed"
rss = RSS::Parser.parse(rss_content,false)
puts "Title: #{rss.channel.title}"
puts "RSS URL: #{rss.channel.link}"
puts "Total entries: #{rss.items.size}"
rss.items.each { |item|
puts item.title
puts item.link
puts item.date
puts "---"
}
Which when run produces something along the lines of;
Bytes read 115009 from feed
Title: Geek Monkey
RSS URL: http://meekgonkey.blogspot.com/
Total entries: 25
Twitter from Ruby
http://meekgonkey.blogspot.com/2011/07/twitter-from-ruby.html
Thu, 21 Jul 2011 13:20:00 +0100
---
Github
http://meekgonkey.blogspot.com/2011/07/github.html
Mon, 18 Jul 2011 13:59:00 +0100
---
Google Plus
http://meekgonkey.blogspot.com/2011/07/google-plus.html
Fri, 01 Jul 2011 10:50:00 +0100
---
WATIR makes a tester's life easier.
http://meekgonkey.blogspot.com/2011/06/watir-makes-testers-life-easier.html
Wed, 29 Jun 2011 14:36:00 +0100
---
Setting browser size and position with watir-webdriver
http://meekgonkey.blogspot.com/2011/06/setting-browser-size-and-position-with.html
Thu, 23 Jun 2011 09:22:00 +0100
---
Doodle's Geek Monkey by Alastair Montgomery
