Jay McGavren's Journal

How a Head First author spends his days off

View on GitHub
2009-08-19

Logan put together a pretty impressive container for Jemini (note the rename for Google-ability) demos. Just pick from a menu to load a state. Showing a description? One line. Offering running updates on a variable’s value? One line.

class AudibleState < Gemini::BaseState

  def create_ui
    text "Click in different places in the window to emit a sound at different pitches and volumes."
    watch('Pitch') { @pitch }
    watch('Volume') { @volume }
  end

  def load
    
    set_manager :sound, create(:SoundManager)

    audible = create :GameObject, :Audible, :ReceivesEvents
    
    audible.load_sound :boom, "boom.wav"
    
    load_keymap :MouseKeymap
    
    audible.handle_event :mouse_pressed do |message|
      @pitch = message.value.pointer.x / 100.0
      @volume = message.value.pointer.y / 100.0
      audible.emit_sound :boom, @volume, @pitch
    end
    
  end
end

Read more...
2009-08-19

:)

Aquarius lyrics Artist: Boards of Canada

yeah thats right

ORANGE

yeah thats right

ORANGE

giggle

one ORANGE (Just Fantasize) two three

Read more...
2009-08-15

MIDIator...

Well, that was easy. Heard about MIDIator (a MIDI event generator for Ruby) on a Confreaks talk, and since I already had MIDI Patchbay and SimpleSynth installed from prior attempts to get things working, I gave it a shot.

Here’s some code that hooks it into a Rinda tuplespace:

require 'rinda/rinda'
require 'rubygems'
require 'midiator'

MY_URI = ARGV[0] || "druby://127.0.0.1:9999"
DRb.start_service
space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))

midi = MIDIator::Interface.new
midi.autodetect_driver

loop do
  key, value = space.take([/Integer/, Integer])
  midi.play value, 0.01
end

And here’s what it sounds like in action. I’m sure a better/more skilled controller would make it sound less, uh, horrible. :) Boy, it sure processes those events fast…

Read more...
2009-08-08

Ooh, purty...

mouse_client.rb:

require 'rubygems'
require 'wx'
require 'rinda/rinda'

MY_URI = "druby://127.0.0.1:9999"
TIME_TO_LIVE = 10

class MouseClient  [800, 600],
      :title => "Click and Drag"
    )
    frame.evt_close {exit}
    frame.evt_motion {|event| on_mouse_motion(event)}
    frame.evt_left_down {|event| on_mouse_press(event)}
    frame.evt_left_up {|event| on_mouse_release(event)}
    frame.show
  end

  def on_mouse_motion(event)
    return unless event.dragging
    space.write ["Integer:x", event.x], TIME_TO_LIVE
    space.write ["Integer:y", event.y], TIME_TO_LIVE
  end

  def on_mouse_press(event); end
  def on_mouse_release(event); end

end

client = MouseClient.new

DRb.start_service
client.space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))
client.main_loop

string_length_agent.rb:

require 'rinda/rinda'
MY_URI = ARGV[0] || "druby://127.0.0.1:9999"
DRb.start_service
space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))

def scale(value)
  @largest_seen = value if @largest_seen == nil or value > @largest_seen
  value.to_f / @largest_seen
end

loop do
  key, value = space.take([/Integer/, nil])
  puts "#{key}: #{'|' * (scale(value) * 68.0)}"
end

The result:

Read more...
2009-08-04

Heh...

In my Google search results (I go by “nephariuz” in various online forums)…

nepharious :: ruby, rails, consulting We build web applications faster and for less using rapid application prototyping and development with the Ruby on Rails framework. www.nepharious.com/

Read more...
2009-07-28

Video podcasts on MythTV with MythNetTV

MythNetTV is an early but effective MythTV extension that downloads podcasts and adds them to your recordings list, just like the free downloads feature on TiVo (except you can subscribe to anything you want, provided the format’s supported).

These commands will install and configure the app (be sure to substitute the path you want videos saved to):

sudo apt-get install mythnettv
mkdir /your/dir/here
mythnettv --datadir=/your/dir/here

Subscribe to some geeky shows:

mythnettv subscribe "http://revision3.com/pixelperfect/feed/Xvid-Small" "PixelPerfect"
mythnettv subscribe "http://www3.youtube.com/rss/global/top_rated.rss" "YouTubeTopRated"
mythnettv subscribe "http://revision3.com/trs/feed/Xvid-Small" "TotallyRadShow"
mythnettv subscribe "http://applebytepodcast.cnettv.com/" "CnetAppleByte"
mythnettv subscribe "http://buzzreportpodcast.cnettv.com/" "CnetBuzzReport"
mythnettv subscribe "http://cnetnewspodcast.cnettv.com/" "CnetNewsDaily"
mythnettv subscribe "http://firstlookpodcast.cnettv.com/" "CnetFirstLook"
mythnettv subscribe "http://hackspodcast.cnettv.com/" "CnetHacks"
mythnettv subscribe "http://howtopodcast.cnettv.com/" "CnetHowTo"
mythnettv subscribe "http://realdealvideopodcast.cnettv.com/" "CnetRealDeal"
mythnettv subscribe "http://revision3.com/coop/feed/Xvid-Small" "Co-Op"
mythnettv subscribe "http://www.onnetworks.com/feeds/1460/video/rss.xml?target=site" "PlayValue"

Get show lists for all subscriptions, then download 10 shows:

mythnettv update
mythnettv download 10

List the next 10 shows that will be downloaded:

mythnettv nextdownload 10

Download 1 show from the given subscription:

mythnettv download 1 CnetNewsDaily

List subscriptions:

mythnettv list

More info on these commands and others:

man mythnettv

Read more...
2009-07-27

My preferred sites...

As recommended by Google Preferred Site Search (now in Labs). These were probably gleaned from my search history, and yup, they look about right.

api.rubyonrails.org

code.google.com

giantrobots.thoughtbot.com

github.com

groups.google.com

linuxforums.org

linuxquestions.org

macosxhints.com

mythtv.org

railscasts.com

ruby-doc.org

ubuntuforums.org

Read more...
2009-07-18

DevHouse, low-tech...

Wanted something to run on the projector during Phoenix DevHouse that would give everyone a shared playground. It had to be simple enough to not interfere with people, though, and I didn’t want people to have to download clients or a bunch of other software…

I’d heard about netcat before, but it was only a few days ago that I stumbled across another article on it, including setting it up as a server/listener. Thought it would be perfect for the job, and it was - as a client. The listener didn’t let people connect concurrently in either TCP or UDP modes, so I simply grabbed a socket example from the Programming Ruby book and fired it up, then posted directions on connecting. Here’s the result…

Read more...
2009-07-13

Quick setup for Linux games under MythTV/MythGame...

These commands will install some quality games that can be played full-screen:

sudo apt-get install a7xpg
sudo apt-get install gunroar
sudo apt-get install kobodeluxe
sudo apt-get install parsec47
sudo apt-get install rrootage
sudo apt-get install sdl-ball
sudo apt-get install titanion
sudo apt-get install torus-trooper
sudo apt-get install tumiki-fighters

This command will add a “Native” games entry under the Games menu. You’ll be prompted for your MythTV DB password, which is likely stored in “/etc/mythtv/mysql.txt”.

mysql --database=mythconverg -u mythtv -p -e "INSERT INTO gameplayers (playername, gametype, commandline, rompath, extensions) VALUES ('Native', 'Other', '', '$HOME/bin/games', '');"

Then fill $HOME/bin/games “ROM directory” with scripts that launch each respective game. (These are set up for a control pad and 1024x768 resolution, so they may need tweaking.)

~/bin/games/titanion
#!/bin/sh
titanion -fullscreen -res 1024 768

~/bin/games/gunroar
#!/bin/sh
gunroar -fullscreen -res 1024 768 -enableaxis5

~/bin/games/rrootage
#!/bin/sh
rrootage -fullscreen -lowres

~/bin/games/parsec47
#!/bin/sh
parsec47 -fullscreen -lowres

~/bin/games/torus-trooper
#!/bin/sh
torus-trooper -fullscreen -res 1024 768

~/bin/games/a7xpg
#!/bin/sh
a7xpg -fullscreen -lowres

~/bin/games/sdl-ball
#!/bin/sh
sdl-ball

~/bin/games/kobo-deluxe
#!/bin/sh
kobodl -fullscreen -width 1024 -height 768 -joystick -nomusic

~/bin/games/tumiki-fighters
#!/bin/sh
tumiki-fighters -fullscreen -res 1024 768

Be sure to make the scripts executable, or they won’t launch:

chmod ugo+x ~/bin/games/*

In mythfrontend, go into game setup and scan for new games. Each script you set up should then appear under the “Native” entry in the games menu - just pick one and fire away.

Questions/suggestions? Post ‘em in the comments!

Read more...
2009-07-13

cowsay :)

jay@dandelion:~
$ sudo port install cowsay
Password:
--->  Fetching cowsay
...
jay@dandelion:~
$ cheat lipsum | cowsay



Read more...
Copyright © Jay McGavren.