ArgumentError (wrong number of arguments (2 for 1)): /usr/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/pure/generator.rb:251:in `to_json' /usr/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/pure/generator.rb:251:in `json_transform' /vendor/plugins/juggernaut/lib/juggernaut.rb:105:in `map' /usr/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/pure/generator.rb:245:in `each' /usr/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/pure/generator.rb:245:in `map' /usr/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/pure/generator.rb:245:in `json_transform' /usr/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/pure/generator.rb:218:in `to_json' /vendor/plugins/juggernaut/lib/juggernaut.rb:114:in `send_data' /vendor/plugins/juggernaut/lib/juggernaut.rb:108:in `each' /vendor/plugins/juggernaut/lib/juggernaut.rb:108:in `send_data' /vendor/plugins/juggernaut/lib/juggernaut.rb:50:in `send_to_client_on_channel'
Adding require "json/add/rails" to vendor/plugins/juggernaut/lib/juggernaut.rb solved the problem. This file has a call to to_json.
Wednesday, August 27, 2008
Tip: ArgumentError when using to_json in Rails.
Posted by
Sonal
at
5:14 PM
0
comments
Links to this post
Labels: ArgumentError, json_pure, juggernaut plugin, Ruby on Rails, to_json
Sunday, August 10, 2008
Google Accounts Authentication using Ruby on Rails and Secure Authsub (Gmail contacts API)
I was able to set up the non-secure authentication after reading Tom Hunter's blog post about Google Contacts API authentication. If you use non-secure authentication Google shows a warning to the user about insecure authentication etc. which may not be a good thing. But getting the secure version to work was a pain in the $%&& to say the least. Anyway, after getting some pointers in Google groups, things got rolling.
- Register your app with Google. For secure authentication, you also need to provide an X.509 certificate to Google, which can be uploaded from the same link.
- To generate this certificate read the instructions given by Google and use the openssl command: # Generate the RSA keys and certificate
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -sha1 -subj \
'/C=US/ST=CA/L=Mountain View/CN=www.example.com' -keyout \
myrsakey.pem -out /tmp/myrsacert.pem - The above command will generate 2 files, one in your current directory (myrsaky.pem, which is the private key) and the other in /tmp (myrsacert.pem) which is the certificate to upload. Remember to input your company or website information in the command instead of example.com's. Also remember to upload the 'certificate' and not the 'private_key' file.
- In the code below, callback_url is the link you provide on your Manage Domains form to Google, along with the certificate.
- When someone clicks 'Invite contacts', they get directed to the url of the init action. From there, they are shown the Google login page if they are not logged in to their Google account. After that they are shown the page on which they can choose to authorize you to import their gmail contacts.
- If you place the private key file in config folder of the app, then you can refer to it as shown in the method sign_data.
- Here's the code: (this is my rough draft of the code, so it may not be the most efficient piece of code on earth, but it works for me for now)
class GauthController (greater_than) ApplicationController
require 'uri'
require 'net/http'
require 'net/https'
require 'rexml/document'
def init
callback_url = "http://guitarati.com/gauth/authsub"
next_param = URI.escape(callback_url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
scope_param = "https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F"
secure_param = "1"
session_param = "1"
root_url = "https://www.google.com/accounts/AuthSubRequest"
query_string = "?scope=#{scope_param}&session=#{session_param}&secure=#{secure_param}&next=#{next_param}"
redirect_to root_url + query_string
end
def authsub
token = params[:token] # received the single-use authsub token, exchange for authsub session token
url = "https://www.google.com/accounts/AuthSubSessionToken"
headers = set_headers(url, token)
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
path = '/accounts/AuthSubSessionToken'
resp, data = http.get(path, headers)
if resp.code == "200"
token = ''
data.split.each do str
if not (str =~ /Token=/).nil?
token = str.gsub(/Token=/, '')
end
end
redirect_to "http://guitarati.com/gauth/import?token=#{token}"
else
redirect_to "http://guitarati.com/"
end
end
def import
token = params[:token]
#http = Net::HTTP.new('www.google.com', 80)
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
#path = "/m8/feeds/contacts/default/base?max-results=10000"
path = "/m8/feeds/contacts/default/base"
url = "https://www.google.com" + path
headers = set_headers(url, token)
resp, data = http.get(path, headers)
xml = REXML::Document.new(data)
contacts = []
xml.elements.each('//entry') do entry
person = {}
person['name'] = entry.elements['title'].text
gd_email = entry.elements['gd:email']
person['email'] = gd_email.attributes['address'] if gd_email
contacts << text =""> "#{contacts.inspect}"
end
private
require 'base64'
require 'openssl'
include OpenSSL
include PKey
include Digest
def sign_data(data)
private_key = OpenSSL::PKey::RSA.new(File.read("config/myrsaky.pem"))
sig = private_key.sign(OpenSSL::Digest::SHA1.new, data)
return Base64.b64encode(sig).gsub(/\n/, '')
end
def set_headers(url, token)
time = Time.now.to_i.to_s
nonce = OpenSSL::BN.rand_range(2**64)
data = "GET #{url} #{time} #{nonce}"
sig = sign_data(data)
return {'Authorization' => "AuthSub token=\"#{token}\" sigalg=\"rsa-sha1\" data=\"#{data}\" sig=\"#{sig}\""}
end
end
Friday, August 1, 2008
Installing and using Juggernaut on Windows
NOTE: After I wrote this post, I came across an article which seems pretty useful. Please refer to it for installing Juggernaut on Windows. It is different from the post below mainly in that it tells you to use json_pure instead of json. Here is the link: http://wiki.mintworx.com/index.php/How_to_Setup_juggernaut_on_windows
- Juggernaut requires Rails version of 2.0.2. I haven't tried with any lower version, so I've no idea if there might be some problems using it there.
- Start out: gem install eventmachine
- Then: gem install juggernaut --include-dependencies. Adding include-dependencies will try to install json along with juggernaut. The version of json available for Windows at the time of writing this is 1.1.1. Juggernaut gem has a requirement that the version of json must be >= 1.1.2. So installing the gem along with dependencies does not go through as this requirement puts a spanner in the works. Instead, use this: gem install --ignore-dependencies, which should go through fine. Before/after this, install json on your own.
- While installing json (gem install json) it asks you the version you want to install. Select 1.1.1 (ms-win32).
- Install plugin: ruby script/plugin install http://juggernaut.rubyforge.org/svn/trunk/juggernaut
- So by now, eventmachine, json, juggernaut gem and juggernaut plugin are installed.
- Time to configure the gem. Typing juggernaut -g juggernaut.yml to configure the gem fails with the error about your json version not being >= 1.1.2. To get past this, edit this file (thanks Google desktop!) ...\ruby\lib\ruby\gems\1.8\specifications\juggernaut-0.5.4.gemspec and try configuring again.
s.add_dependency(%q eventmachine, [">= 0.10.0"])
s.add_dependency(%q json, [">= 1.1.2"]) # ---- changed this to 1.1.1
s.add_dependency(%q hoe, [">= 1.5.1"]) #--- changed this to 1.3.1 - Then start juggernaut. juggernaut -c juggernaut.yml
- Look at Juggernaut README and cool RoR chat with Juggernaut for tips and code examples.
Friday, May 2, 2008
My Lyrics are Designed to Effect Positive Changes in the Mind Sets of my Listeners. - Keji Hamilton & the Exousia Band
How and when did you start on your musical journey?
I started my musical career in 1984 with the Egypt 80 band, led by Fela Kuti.
What kind of music do you like to make? How would you describe your music?
I like to compose and arrange Afrobeat music. It is a fusion of African Rhythm / Percussions, and Western Brass and Horns.
Who is your musical inspiration?
God is my musical inspiration.
How do you distinguish yourself from others?
My lyrics are designed to effect positive changes in the mind sets of my listeners.
Tell us more about your album Keji on Guitarati. What is the inspiration behind the album?
The ‘Keji’ album is an effective combination of slow tempo groove and fast-paced upbeat tracks. The songs capture a variety of moods and themes; ranging from the political, through social commentary, to the inspirational.
Do you write your own songs?
Yes. I write and arrange my own songs.
Which is your favorite song from your album? What is the story behind it?
‘Innocent blood’ - It talks about how some in authority have been involved in the unjust killing of innocent citizens.
Are you working on a new album?
Yes.
What is a day like in the life of a musician?
Say my prayers when I wake up…meditate….get inspiration…some exercise….some relaxation….some reading of motivational and inspirational books…
Any parting shot?
Enjoy my music!

Posted by
Sonal
at
11:43 AM
0
comments
Links to this post
Labels: Keji album, spotlight Keji Hamilton and the Exousia Band
A Penny Too Much?
We have received a good number of responses about the 1¢ charge for streaming. Some loving it, some hating it. Some calling it a new direction, others calling it a nonsensical nuisance. Here are some typical questions that we receive (as a FAQ, since everyone love FAQs):
- This is a shocking idea.
Indeed. It's shocking because it is honestly, plainly laid out, not disguised as monthly subscriptions or hiding-the-money-behind-asterisk approach. - Why should we pay 1¢ when other websites are streaming for free?
Well, if you look carefully, free is only an eyewash. Most other websites have only samples for free. For full length, they are either limited in numbers (only 3 full lengths for example) or there are monthly subscriptions, which you would pay upfront even if you do not listen to as many songs. So either you can not preview the full song before you decide to purchase or you are limited in the number of songs you can preview. Look beneath the hood, you will know.
On most websites, downloading the song is the only way to listen to the full length version of the song. At Guitarati, you can sample it for free or listen to the full track for 1¢. And when you download it, you will pay that many cents less. Download it only when it feels right to you. That way, everyone is happy. - We pay with love, not with money.
And we love free too. We are not against it; after all who does not love Linux and Firefox and Ruby on Rails? We too, as you, look forward to the times when the cost of creating music is next to zero and we can enjoy all the music that the world can produce. - It is a new direction.
Thank you, yes it is. It is a balanced approach. You download only when you decide that it is right for you and at the same time, the artists are not entirely at the losing end.
We'd love to hear from you. Your thoughts, comments and ideas help us. Press the red button on our website and you reach us.
Posted by
Sonal
at
11:43 AM
0
comments
Links to this post
Labels: Business Model, free music versus paid, Guitarati, Music, Music Streaming
Sky Gazing Post Rock or Music to the Film in Your Head - Sidewaytown
How did your band Sidewaytown come into being?
Well, actually Sidewaytown is a solo-project I started with in 2006 after the split of my former band Autumnblaze. I felt that I had to do something different - musically and lyrically – to grow as an artist and person.
You mention that you were in the band Autumnblaze earlier. You then moved on to form Sidewaytown. What was your inspiration behind forming this band?
I guess the biggest inspiration behind Sidewaytown was the challenge to start again from zero after the years I spent with Autumnblaze. It was like a second birth cause I had limited myself in some ways before and Sidewaytown was or is the chance to burn all musical borders to build up something completely fresh and stunning.
Your music is very sublime, intense and has a haunting quality. Who is your music inspiration?
I think nowadays most of my inspiration comes from the musical and personal experiences I’ve done in life. I know how what I really like and I know how the music should sound in the end. A big inspiration source are also books and movies. It’s like diving into other worlds and this is the best you can do to wash away the burdens of the ordinary life. And well, it gives inspiration cause your thoughts are free in those moments when you read a book or watch a movie.
How would you describe your music?
I would describe it as sky gazing post rock or music to the film in your head. Warm guitar melodies and vocal harmonies embrace and welcome you, gently caress soul and senses or unload in emotional eruptions.
How do you distinguish yourself from other bands?
I think we definitely have our individual sound. Perhaps it’s a little bit loudmouthed after just one album is released but at the latest with the release of the second CD we will prove it. The other thing is that I don’t look on other bands.
Tell us more about your album "Years in the Wall" on Guitarati. What is the inspiration behind the album?
“Years in the wall” contains a conceptional story of disilliúsion and delusion, hope and love, longing and death, a world where words destroy life. Musically I tried to write songs with a similar basic sound to create a very visual, floating kind of musical landscape. It’s like an ocean the listener has to dive in to catch the pearls at the bottom of the ground.
Do you write your own songs?
Yes, I write all songs and lyrics. That’s also quite special cause I work without pressure from a label or a producer who tries to push me in a certain direction. No, it’s simply pure songwriter stuff in here.
Which is your favorite song from your album(s)? Is there a story behind it?
Hard to say. There some fave songs on the album but if you wanna force me I would say “Don’t visit a dying bastard” cause it contains the best chorus I wrote for a very long time. The story of the song is part of the concept, the protagonist meets his grandfather in a nursing home to confront him with his dark past.
Are you working on a new album?
Yes, I do. I’ve written a bunch of new songs. At the moment I’m thinking about the musical frame for each song. Maybe like an architect who first has to create an image in his head.
What is a day like in the life of a musician?
Standing up in the morning, taking some drugs, sleeping with different women and listening to the loudest music. What did you think? Ok, JOKE. Honestly it’s what everybody does: Trying to do the best out of life. Sometimes you win , sometimes you loose.
Any parting shot for your listeners and fans?
I would like to thank you so much for supporting Sidewaytown. Keep on with it. And if you have some time, visit our websites www.sidewaytown.com and www.myspace.com/sidewaytown to get more information and to watch our sweet videos.


Posted by
Sonal
at
11:32 AM
1 comments
Links to this post
Labels: Markus Baltes music, skygazing post rock, spotlight sidewaytown, years in the wall album
Sunday, April 27, 2008
We Want Our Music to Strike a Common Chord with Others - AngryLaughter
How and when did you start on your musical journey?
It started at a very young age. Not the performing of music, but listening to music. It started with Elvis. My mom bought me one of his records. I used to listen to his songs over and over and do the air guitar thing. I didn’t start playing guitar until much later near the end of high school. Though I was in the school band. Lisa is a classically trained pianist who refuses to stand up while playing. She also still uses printed sheet music for all of our performances. I keep telling her we’re not playing in church, but she still insists. Mark’s been in bands for a long time. They almost won the big battle of the bands competition in Utah. Sam just joined us. We needed a bass player so we handed him a bass and he jumped up on stage with us. And that was the first time he played the instrument.
What kind of music do you like to make? How would you describe your music?
We like to make music that says something but also does more. We want our music to strike a common chord with others. It’s a way that we express things that are deep inside us. Music can bring people together on a very emotional level and if we can help others feel they aren’t alone, we’re happy.
Who is your musical inspiration?
We’re influenced most by the classic rock genre – artists like The Who, Beatles, Neil, Elton. But the music we play ranges from that to alternative to acoustic singer/songwriter with a bit of punk thrown in here and there.
How do you distinguish yourselves from others?
We don’t need to. We’re all homely enough that we stick out in a crowd. Except for Lisa, that is. But seriously, we’re different in our approach to music. We don't have a uniform or specific "look" to our band, nor the music we write. The variety inspires us and rouses our creativity. No one, including us, really knows what kind of sound our next song will have!
Do you write your own songs?
We write our own music. Occasionally, we’ll play a cover. It’s probably a fault when we play out that we don’t have as many covers as some people would like. But when we play music, it’s our insides we want to come out. So we choose our covers carefully and we make them our own.
Tell us more about your album 'One Way Street' on Guitarati. What is the inspiration behind the album?
It’s been in the works for a long time. We had a large collection of songs written over like 10 years. Ironically, only ones written in the last three years made it onto the album. We recorded everything in our home studio on a Mac and Logic. We did all the engineering, production, artwork, and packaging ourselves. The album reflects the journey through life. You learn as you go, and though you can look back, you can’t go back.
Are you working on a new album?
Well, that may differ across band members, but for at least two of us, the favorite is "One Way Street". This song originally was recorded with just an acoustic guitar and vocals, paralleling the theme or premise of the lyrics. However, we decided to record the song with a full instrumental sound and now are torn between which of those two is our favorite! Overall, we love that song because of the simplicity of the lyrics that attempt to convey many complex life challenges. We have a very interesting idea in the works, but it’s so secret, we can’t talk about it yet.
What is a day like in the life of a musician?
So little time, so many songs to write…

