Thursday, June 16, 2011

Points to note: Publishing to Nokia OVI #2

This time it is about submitting a Java/J2ME app to OVI Store. I submitted an App developed for s-40 6th edition devices. You need to know all the devices that your application might work.

Also since it was religious content I was once rejected by OVI stating which countries do not accept such content. So, beware.

Signing - Do not worry about signing. Nokia does it for free. They just need some documentation. You need to create a flowchart of the app and fill up a pdf and submit both JAR and JAD files.

hth!

Wednesday, March 9, 2011

Points to note: Publishing to Nokia OVI

If it is a game that you are trying to publish, De-select China and South Korea from distribution list unless of course you are chinese/korean and know these stuff.

If it is a normal application make sure you package it using Nokia provided UIDs. The process to get UID is simple: just email to nokia ovi from an email registered with nokia and they will send you five UIDs.

Monday, November 15, 2010

Uploading Zip files via Chrome v/s IE

Again the ZIP on Linux tricked me. I was uploading zip files using my rails application and was using Chrome for development. With all confidence when I submitted to the QA team it crashed.

After loosing some hair I found that IE and Chrome send zip contents in different ways. IE send in filename in params while chrome sends entire contents.

So here is how then I tackled it differently in controller file:

def bulk_requests_upload
#upload files
require 'pp'
file_name = params[:request][:bulk_requests_file]
dest_path = "tmp/dir_#{rand(9999)}/"
Dir.mkdir("#{dest_path}") rescue nil
begin #For IE and Mozilla
uploaded_zipfile_path = File.join(dest_path,file_name.original_filename) if file_name.original_filename
uploaded_file= File.new("#{uploaded_zipfile_path}","wb")
uploaded_file.write file_name.read
uploaded_file.close
rescue # For Chrome
uploaded_zipfile_path = File.join(dest_path,'new_file.zip')
uploaded_file= File.new("#{uploaded_zipfile_path}","wb")
uploaded_file.write file_name
uploaded_file.close
end

#unzip files
system "unzip -o #{uploaded_zipfile_path} -d #{dest_path}"
#find csv in uploaded files
csv_file_path = find_csv_file(dest_path)
#import csv
req_imports = ImportRequests.new
req_imports.import_file(csv_file_path)
@errors = req_imports.errors
#remove uploaded files
system "rm -rf #{csv_file_path}"
system "rm -rf #{uploaded_zipfile_path}"
system "rm -rf #{dest_path}*"
system "rm -rf #{dest_path}"
@errors.compact!
if @errors.size != 0
render 'requests/bulk_requests'
else
flash[:notice] = "Successfully imported requests"
redirect_to :action=> 'list_my'
end
end


Another finding here was defining the destination directory for unzip command.
system "unzip -o #{uploaded_zipfile_path} -d #{dest_path}"


I am still to find a good way to delete those randomly named empty directories getting piled up at the server.

The first two rm commands work, but
system "rm -rf #{dest_path}*"

says rm: failed the directory is not empty

which is BS.. because the directories, I swear, are empty.

Anyway, as soon as I find it out there will be another post. :-)

Tuesday, August 3, 2010

Compressed Tar and untar in linux/unix

Most of the text available on internet tell you to "tar -cvf filename" to tar a file. And it's damn correct. But what it doesn't tell you is that TAR (TAPE ARCHIVE) is not a compression format like zip. So a tar file is not necessarily a compressed file. It's just a tape archive and has some history attached to it, which i do not care about.

WTF...!

The real command to get a compressed tar file or compressed tar.gz file is

tar -czvf tarfilename.tar.gz file1 file2 file3 ...


And to extract

tar -xzvf tarfilename.tar.gz


Huh! Ignorance is antonym of Bliss.

Wednesday, July 28, 2010

Setting up a UAT box remotely

I am not much in to unix environment. So, when I had to setup a UAT box remotely, I had a score of issues and after a lot reading, learning, trying and asking I reached a set of commands that worked. This is not very specific to the requirement I had.. installing ruby on rails 1.2.3 and postgres on Fedora 12 machine using putty. I know it's a very old version. I wish I could secretly upgrade the version overnight. But it's not possible especially when product is already in production.

Anyway, here are the steps to set up the box that just had Fedora 12 installed and had access to internet.

Installing postgres
yum -y install postgresql postgresql-server postresql-devel


Installing ruby
wget ftp://ftp.ruby-lang.org//pub/ruby/1.8/ruby-1.8.6-p399.tar.gz
tar -xzvf ruby-1.8.6-p399.tar.gz
cd ruby-1.8.6-p399
./configure
make


Checking Ruby installation
ruby -v


Installing rubygems
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.2.tgz
tar -xzvf rubygems-1.3.2.tgz
cd rubygems-1.3.2
ruby setup.rb


Installing all the required gems
gem install rails -v=1.2.3 --include-dependencies
gem install pg -- --with-pgsql-include-dir='/usr/include/pgsql' --with-pgsql-lib-dir='/usr/lib/pgsql'
gem install postgres
gem install mongrel
gem install rubyzip
yum install fcgi fcgi-devel
gem install fcgi -r -- --with-fcgi-lib=/usr/local/fcgi/lib --with-fcgi-include=/usr/local/fcgi/include


Restoring the database

[root@uvt eProfile]# su postgres
-bash-4.0$ psql template1
template1=# create database extranet owner postgres;
template1=# \q
[root@uvt eProfile]# psql -U postgres -d extranet -f db.out


After doing all this, placing the application and starting the server. I wasn't still able to access the application via browser. Later the Admin found that it was due to unix internal firewall. Huff! twas a tough time. But, tough times never last, tough people do.

Wednesday, July 14, 2010

Dynamic variable names

Here is a way of dynamically setting instance variable names in ruby. So as in given example you can use @a, @b et. al. w/o first defining them.

def funcA
new_hash = {:a=>'A',:b=>'B',:c=>'C',:d=>'D'}
new_hash.each{|k,v|
instance_var = "@#{k}"
instance_variable_set(instance_var.to_sym, v)

}
end

funcA
puts @a


Actually, I wanted to iterate through a Settings table and create instance variables for all the settings available. Settings table has name and value columns to store admin settings. And I did not want to write a line for setting every instance variable.

It was simpler than i had thot

settings = Settings.find(:all)

settings.each{|setting|
instance_variable_set("@#{setting.name}","#{setting.value}")
}


Regards,
UVT

PS - I luv Ruby :-)

Saturday, July 10, 2010

Cyclic redundancy issue

Q. Error expected specifier-qualifier-list

A. It is because of cyclic-imports. One file imported to other file and the other file imported back to first one. To avoid this one should use "Forward Class reference"

@class for one of the files instead of #import.

It's explained here : http://timburrell.net/blog/2008-11-23/effective-c-cyclical-dependencies/