Lojic Technologies

Archive for the ‘science’ Category

Precision Quadrotor Flying

leave a comment »

Wow – pretty amazing! HT Michael Hale via RT ๐Ÿ™‚

Written by Brian Adkins

May 28, 2010 at 11:09 am

Posted in amazing, robotics, science, technology, video

Tagged with ,

Retrieve Sunrise, Sunset & Twilight Info in Ruby

with 5 comments

Sunrise, Sunset & Twilight

TwilightI was curious about the exact time of sunrise & sunset at my location, so I found this US Naval Observatory site. In the process, I learned a more precise definition of twilight. I wanted to be able to automate the process of retrieving the information, so my first attempt was to simply put the query parameters used in the form in the URL as an HTTP GET request, but the server wouldn’t accept that, so I needed to issue an HTTP POST request.

Ruby Code

Ruby is a great language for this sort of task, so I put together the following simple program:

require 'net/http'

YOUR_ID    = ''    # A unique ID per comment above
YOUR_CITY  = ''    # The name of your city
YOUR_STATE = ''    # Two letter state abbreviation

now   = Time.now
month = now.month
day   = now.day + 1 # Tomorrow
year  = now.year

Net::HTTP.start('aa.usno.navy.mil') do |query|
  response = query.post('/cgi-bin/aa_pap.pl',
    "FFX=1&ID=#{YOUR_ID}&xxy=#{year}&xxm=#{month}&xxd=#{day}&st=#{YOUR_STATE}&place=#{YOUR_CITY}&ZZZ=END")
  if response.body =~ /Begin civil twilight[^0-9]*(d+:d{2} [ap].m.).*Sunrise[^0-9]*(d+:d{2} [ap].m.).*Sunset[^0-9]*(d+:d{2} [ap].m.).*End civil twilight[^0-9]*(d+:d{2} [ap].m.)/m
    puts "#{month}/#{day}/#{year}"
    puts "Begin Twilight: #{$1}"
    puts "Sunrise       : #{$2}"
    puts "Sunset        : #{$3}"
    puts "End Twilight  : #{$4}"
  end
end

You just need to edit the three constants that begin with YOUR_. The id used on the Navy web form is ‘AA’, but they have a comment in the HTML that requests you use a unique id of your own up to 8 characters to help them with tracking. You can find a more complete version of the code in my github profile.

Emacs Goodness

After writing the above Ruby script, I made it executable, ‘chmod +x sunrise.rb’, and placed it in my path so I could write a simple Emacs function to invoke it.

(defun bja-sunrise ()
  "Display sunrise, sunset & twilight information."
  (interactive)
  (shell-command "sunrise.rb"))

Imagine my surprise when I invoked the Emacs apropos help ‘C-h a’ to see my newly defined function and discovered that Emacs, naturally, already has several commands to display sunrise/sunset information!

calendar-mouse-sunrise/sunset
Show sunrise/sunset times for mouse-selected date.
calendar-sunrise-sunset
Local time of sunrise and sunset for date under cursor.
sunrise-sunset
Local time of sunrise and sunset for today. Accurate to a few seconds.

It doesn’t, however, display twilight information, so my simple function still has a purpose in life. Emacs is awesome ๐Ÿ™‚

Written by Brian Adkins

March 11, 2009 at 12:41 am

Dolphin Bubble Rings

leave a comment »

My uncle passed on a link he received from my cousin to an amazing video showing dolphins cleverly making sophisticated bubble rings and manipulating them in interesting ways:

Written by Brian Adkins

January 22, 2008 at 9:25 am

Posted in science, video

Tagged with , ,

Crayon Physics

with one comment

I found this video of a “crayon physics” game on Robert Scoble’s site – very cool!

Written by Brian Adkins

December 1, 2007 at 11:08 am

Posted in amazing, science, video

Tagged with ,

Best seats to survive a plane crash.

leave a comment »

Plane wreck

MYTH: It Doesn’t Matter Where You Sit

“It’s like a lottery to pick your seat.”
-Nora Marshall, passenger survival expert, National Transportation Safety Board

“One seat is as safe as the other.”
-Boeing Web site

“It’s an age-old question. There’s just no way to say.”
-Federal Aviation Administration spokesman

“There is no safest seat.”
-airsafe.com

REALITY: It’s Safer In the Back.

The funny thing about all those expert opinions: They’re not really based on hard data about actual airline accidents. A look at real-world crash stats, however, suggests that the farther back you sit, the better your odds of survival. Passengers near the tail of a plane are about 40 percent more likely to survive a crash than those in the first few rows up front.

Popular Mechanics article

Written by Brian Adkins

July 21, 2007 at 1:29 pm

Posted in science

Tagged with , ,

Oregon Man Flies 193 Miles In Lawn Chair

leave a comment »

I learned about this lawn chair flight from Matt Promise’s blog.

Balloons suspend Kent Couch in a lawn chair as he floats in the skies near Bend, Ore., Saturday, July 7, 2007. Couch, on his way to Idaho, carried a global positioning system device, a two-way radio, a digital camcorder and a cell phone. He also had instruments to measure his altitude and speed and about four plastic bags holding five gallons of water each to act as a ballast, he could turn a spigot, release water and rise.

Couch is the latest American to emulate Larry Walters รขโ‚ฌโ€ who in 1982 rose three miles above Los Angeles in a lawn chair lifted by balloons. Walters had surprised an airline pilot, who radioed the control tower that he had just passed a guy in a lawn chair.

Here is an article on Fox News.

Written by Brian Adkins

July 11, 2007 at 10:33 am

Posted in amazing, science

Tagged with ,

Spider Car

with 2 comments

Three months to design, six months to build, $15,000 in parts…

Written by Brian Adkins

June 19, 2007 at 8:21 am

Posted in amazing, science, video

Tagged with