On gaming, programming, everything!
RSS icon Home icon
  • How Rice Works

    Posted on February 23rd, 2010 Jason No comments

    Rice is one impressive piece of software. I highly doubt I could have written this from scratch (and for that I give Paul Brannan huge accolades for his work) but after working with and on this library for at least a year I probably could. Now that lead maintainership has been passed on to me, I’d like to take some time to explain exactly how Rice works, how one can dive in and help develop this library, and what my plans are for the near future as I work to make Rice and the rb++ suite; a full and proper replacement for SWIG when wrapping C++ libraries into Ruby (if you’re wrapping a pure C library, I highly recommend Ruby-FFI, though Rice will work).

    So with that, I’m putting together this post to help clarify exactly how the various parts of Rice work together, how the entire process flows and more importantly helping anyone who’s wanting to learn and work on Rice with a solid starting point (or at least officially crooked). After reading this, anyone should be able to understand the various classes in Rice, and have an idea on where certain functionality lives when looking to add features, or address any bugs. So with that, we’ll start at the top.

    Read the rest of this entry »

  • Adobe Flash 9 & 10 Security Requirements

    Posted on June 3rd, 2009 Jason No comments

    For those of us messing and working in Flash, the transition from Flash 8 through to Flash 10 have been rife with some major changes in the security model that allows a local Flash application to communicate with the outside world. Adobe, knowing that these are big changes, had its developers write pages, pages, and pages of documentation describing the where what how and why of these updates.

    Problem is, it’s very hard to find the simple How-Tos for common situations in all this text. I spent many days scouring and tinkering to figure out the security solution to my application: a flash-based video viewer that would connect into a server and display Motion-JPEG frames that get streamed in.

    Hopefully I’ll help save someone else the same hours of research and playing with this problem. My solution is such:

    You first need up a simple service on the server you want to connect into that serves the crossdomain.xml content that defines your security policies.

    I use a modified version of the service found here: http://www.lightsphere.com/dev/articles/flash_socket_policy.html. It’s updated to be a full Daemon process, so you need Proc::Daemon and Proc::PID::File installed.

    Please note:

    <site-control permitted-cross-domain-policies=”all”/>

    is the required addition to make this script work with Flash 10. Also, if you are worried about corporate firewalls blocking ports < 1000, simply change $port to something bigger, and add the following to your Flash client:

    And you're good to go!

  • Embedding IRB into your Ruby application

    Posted on April 2nd, 2009 Jason 1 comment

    A feature I realized would be very helpful to have in rb++ is a debugging console. Basically, I wanted the ability to drop into an irb session and have available to me the internals of rb++ and rbgccxml, all set up for the sources I’ve specified for the given extension.

    Turns out, this is a lot harder to figure out than it would initially seem. The irb code is quite complex and nothing there is documented in any way shape or form. Also, searches around the Internet came back with results that were some six years old, and while helpful, did not pertain to my particular case.

    Then I remembered that ruby-debug does exactly what I’m looking for. A quick glance in that code got me the code snippet I needed.

    require 'irb'
     
    module IRB # :nodoc:
      def self.start_session(binding)
        unless @__initialized
          args = ARGV
          ARGV.replace(ARGV.dup)
          IRB.setup(nil)
          ARGV.replace(args)
          @__initialized = true
        end
     
        workspace = WorkSpace.new(binding)
     
        irb = Irb.new(workspace)
     
        @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
        @CONF[:MAIN_CONTEXT] = irb.context
     
        catch(:IRB_EXIT) do
          irb.eval_input
        end
      end
    end

    And it’s use is quite simple. When you want to drop into an irb session, you simply do

    IRB.start_session(binding)

    and you will have a code prompt with all data available at your finger-tips.

    See the related rb++ commit

    You use this feature in rb++ as follows:


    ruby your_extension_file.rb console

    From there, start playing around with the parsed source tree using either @parser or self.namespace to get started.

  • There are two hard problems in Computer Science…

    Posted on March 21st, 2009 Jason 1 comment

    Cache invalidation and naming things, and the latter is most definitely not a Computer Science-only problem. I have no idea what to name this blog, so for now, it’s going to remain un-named until either a good suggestion comes along, or inspiration hits me.