\\ELEVEN33\\

Ruby + Thin + Camping : Serving static files with Thin vs. Camping’s work around.

by xrs on Mar.31, 2009, under Programming

I have been working with camping for a while and I didnt like how it required me to write methods to handle my static files. Stumbling across some things I read about using “Thin” and “Rack” I was able to serve static files through thin server versus using the camping framework. The file I am using has a .ru extension rather than a .rb extension because it is a rack config file.

%w[ rubygems camping active_record camping/db camping/session reststop json active_support net/http rack ].each { |x| require x}

Camping.goes :Operator

#So after the Camping Instantiation I use this little piece of code to let thin handle the static files.
use Rack::Static, :urls => ["/static", "/images", "/css", "/javascripts"], :root => File.expand_path(File.dirname(__FILE__))

#All my Operator Code goes in here#

#Here us the end of my file. To start the Thin + Camping application.

Operator::Models::Base.establish_connection :adapter => ’sqlite3′, :database => ‘operator.db’
Operator::Models::Base.logger = Logger.new(’operator.log’)
run Rack::Adapter::Camping.new(Operator)

now type: thin start -r ./myfile.ru

I hope this helps all who like to go camping but take the “Thin” path to get to where they are going.

Leave a Comment more...

Ruby + Soap4r : Complex headers

by xrs on Mar.31, 2009, under Programming

I was was using Soap4r to talk to a Enterprise Messaging Bus and was able to come up with this to pass complex headers that were required by the Bus. So I am happy with my outcome. However this begs the question. “Why are we still using SOAP?”

require ’soap/header/simplehandler’

n = XSD::NS.new
n.assign(”soap”, “”)

class HeaderHandler < SOAP::Header::SimpleHandler
attr_accessor :value

def initialize(ns,tag)
super(XSD::QName.new(ns, tag))
@value = value
end

def on_simple_outbound
@value
end
End

h =
HeaderHandler.new(”http://service.asurion.com/schemas/MessageHeader/1.0.0“,
“MessageHeader”)
driver.headerhandler << h
h.value = {XSD::QName.new(”http://example.com/schemas/MessageHeader/1.0.0“,
“Context”) => {XSD::QName.new(”http://example.com/schemas/
exampleCanonicalModel/1.0.0″, “Culture”) => “en-US” ,
XSD::QName.new(”http://example.com/schemas/ exampleCanonicalModel/1.0.0″,
“TimeStamp”) => “2009-01-09T17:44:32.6441748Z”, XSD::QName.new(”http://
example.com/schemas/exampleCanonicalModel/1.0.0″, “Principal”) =>
{XSD::QName.new(”http://example.com/schemas/exampleCanonicalModel/1.0.0“,”Sy
stemUsername”) => “clientname”,
XSD::QName.new(”http://example.com/schemas/exampleCanonicalModel/1.0.0“,”Sys
temPassword”) => 55555555},
XSD::QName.new(”http://example.com/schemas/exampleCanonicalModel/1.0.0“,
“LineOfBusiness”) => “Handset”,
XSD::QName.new(”http://example.com/schemas/exampleCanonicalModel/1.0.0“,
“Application”) => “Aggregator”,
XSD::QName.new(”http://example.com/schemas/exampleCanonicalModel/1.0.0“,
“Client”) => “Google”,
XSD::QName.new(”http://example.com/schemas/exampleCanonicalModel/1.0.0“,
“Channel”) => “InStore”}}

###################################### Output of header from wiredump

<soap:Header>
<n1:MessageHeader
xmlns:n1=”http://example.com/schemas/MessageHeader/1.0.0
soap:mustUnderstand=”0″>
<n1:Context
xmlns:n2=”http://example.com/schemas/exampleCanonicalModel/1.0.0“>
<n2:LineOfBusiness>Handset</n2:LineOfBusiness>
<n2:Client>Google</n2:Client>
<n2:Channel>InStore</n2:Channel>
<n2:Application>Aggregator</n2:Application>
<n2:Principal>
<n2:SystemPassword>55555555</n2:SystemPassword>
<n2:SystemUsername>clientname</n2:SystemUsername>
</n2:Principal>
<n2:TimeStamp>2009-01-09T17:44:32.6441748Z</n2:TimeStamp>
<n2:Culture>en-US</n2:Culture>
</n1:Context>
</n1:MessageHeader>
</soap:Header>

Leave a Comment more...

Python + SOAPpy module

by xrs on Jul.14, 2008, under Programming

I have been tinkering around with Python lately and have had a little trouble here and there. I first had a problem with installing the psycopg2 adapter for Postgres integration. come to find out that installing packages from macports is not always the best thing. So a simple “sudo port uninstall psycopg2” and then compile from binary fixed the problem.

Now I am wresteling with the SOAPpy install. It keeps giving me the error when building ”

Traceback (most recent call last):
File “setup.py”, line 8, in <module>
from SOAPpy.version import __version__
File “/Users/xrs/Downloads/SOAPpy-0.12.0/SOAPpy/__init__.py”, line 5, in <module>
from Client      import *
File “/Users/xrs/Downloads/SOAPpy-0.12.0/SOAPpy/Client.py”, line 46
from __future__ import nested_scopes
SyntaxError: from __future__ imports must occur at the beginning of the file

“. So after some reading and banging my head on the keyboard i found this handy article.

http://www.python.org/dev/peps/pep-0236/

Upon reading I found that in Python 2.5 wants all nested_scopes to be called at the beginning of the file and that only certain statements can be ahead of the import statement. So “yeah”, this is something a experienced Python programmer would have figured out in a couple of minutes. Oh well, just like with any other language you have to do some walking around in circles before you realize the end to the loop is to read the manual.

1 Comment more...

Flex Builder + Ubuntu

by xrs on Jun.24, 2008, under Linux, Programming

So recently Adobe released its Flex Builder for Linux. After learning this the first thing that popped in my head is awesome I can figure out how to unsuccessfully install something after 10 tries again. So after fiddleing with Flex Builder for about 30 minutes I got it installed. Heres what I had to do.

First check your system for the necessities needed for  the Flex Builder Eclipse Plugin to work

Linux Header (linux-headers-2.6.24-19-generic)

sudo apt-get install linux-headers-2.6.24-16-generic

Eclipse Classic 3.3.2

wget http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.3.2-200802211800/eclipse-SDK-3.3.2-linux-gtk.tar.gz

tar xzvf eclipse-SDK-3.3.2-linux-gtk.tar.gz

this should give you a directory called eclipse. I moved mine to my home directory.

mv ./eclipse /home/<username>/

(this will come in handy during the installation process.)

Java JRE 1.5

I had to use 1.5 otherwise Flex Builder would not install

–minimum install

sudo apt-get install sun-java5-jre

– what I did

sudo apt-get install sun-java5-jre sun-java5-plugin sun-java5-bin sun-java5-fonts

after installing java you have to tell Ubuntu what version of Java you want to use

sudo update-alternatives –config java

There are 4 alternatives which provide `java’.

Selection    Alternative
———————————————–
1    /usr/bin/gij-4.2
+        2    /usr/lib/jvm/java-gcj/jre/bin/java
3    /usr/lib/jvm/java-6-sun/jre/bin/java
*         4    /usr/lib/jvm/java-1.5.0-sun/jre/bin/java

Press enter to keep the default[*], or type selection number:

select java-1.5.0, in my case #4

Next Download the flex builder.

wget http://download.macromedia.com/pub/labs/flex/flexbuilder_linux/flexbuilder_linux_install_a3_033108.bin

The INSTALL file will tell you to make the bin file executable (chmod +x) but I didn’t feel like it. So I just did the following

sh ./flexbuilder_linux_install_a3_033108.bin

and so the adobe installer begins.

The installer will ask you where you want to put “Adobe_Flex_Builder_Linux” directory

/home/<username>/Adobe_Flex_Builder_Linux

ehhhh why not.

Next the installer will ask you to select you current eclipse directory. (remember from earlier?)

/home/<username>/eclipse

after hitting next it should install the flex builder without any errors. If you do get errors I would sugget “sudo su -” then running the .bin file again. Pay attention to the paths of the Adobe_Flex_Builder_Linux directory creation.

Well I hope this helps those out there who love Ubuntu, but sometimes get exhausted with always having to configure 5 other things before they can use the program they want.

3 Comments more...

little knight

by xrs on Mar.14, 2008, under Illustrations

Blogged with the Flock Browser

Leave a Comment more...

Chicken Little

by xrs on Mar.05, 2008, under Illustrations

My little boy in his halloween costume….

Blogged with the Flock Browser

1 Comment more...

Super Songer Family

by xrs on Mar.05, 2008, under Illustrations

So this is a little glimpse of what really goes on in my head while everyone else is talking about something important.

Super Songer Family

Leave a Comment more...

Canadian Mouse

by xrs on Mar.05, 2008, under Illustrations

This Drawing was inspired by a character that Katie’s seven year old cousin imagined.
Canadian Mouse

Leave a Comment more...

Lion

by xrs on Mar.05, 2008, under Illustrations

Aslan
This is a picture I drew while I was reading the Cronicles of Narnia about a year ago.

1 Comment more...

Stick it to me.

by xrs on Oct.09, 2007, under Illustrations

Just wait there are more stick characters and wars to come…….Pistol Whip Jim

1 Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...