iphone and gis development notes

By Rupert

Follow me on TwitterRSS Feeds

  • Home
  • About

Long Time No Trac

Nov 25th

Posted by rupert in Uncategorized

No comments

Its been a while I haven’t setup an svn repository for SCM. Anyhow, here are the steps just in case I forget again and again…

1. Add a new trac setting in /etc/apache2/sites-available/default

 

2. Copy a template

cp -Rf /var/www/trac/trac-template /var/www/localdumplings

3. Restart Apache2

4. Resync the repository

trac-admin localdumpling resync
trac

Rails Note #9: Getting HTTP Headers

Nov 20th

Posted by rupert in Uncategorized

No comments

1. I was trying to get the http headers dump from a mobile phone. So I quickly dump it in a log file to see its contents..

    headers['Content-Type'] = 'text/xml; charset=utf-8'
    for header in request.env.select {|k,v| k.match("^HTTP.*")}
        logger.info(header[0].split('_',2)[1] + ":" + header[1])
    end

Reference:
http://tonycode.com/wiki/index.php?title=Dumping_HTTP_Headers

2. However, please note that you can actually see everything from the request as parameters.

Parameters: {“MSAG-ADDRESS-PREFIX”=>”aSTARTa”, “format”=>”xml”, “protocol”=>”ussd”, “user-agent”=>”Jakarta Commons-HttpClient/3.0.1″, “WHOISD-ABONENT”=>”8613520747210″, “action”=>”menu”, “controller”=>”ussd”, “subscriberID”=>”8613520747210″, “WHOISD-USR”=>”-1″, “host”=>”wap.watago.mobi”, “WHOISD-USSD-MESSAGE”=>”", “content-length”=>”0″}

This means we can easily do..

@whoisd_abonent = params['WHOISD-ABONENT'] || nil
ruby on rails

Rails Note #8: Testing with session variables

Nov 18th

Posted by rupert in Uncategorized

No comments

Taken from http://guides.rails.info/testing_rails_applications.html

The get method kicks off the web request and populates the results into the response. It accepts 4 arguments:

*The action of the controller you are requesting. This can be in the form of a string or a symbol.
*An optional hash of request parameters to pass into the action (eg. query string parameters or post variables).
*An optional hash of session variables to pass along with the request.
*An optional hash of flash values.

Example: Calling the :show action, passing an id of 12 as the params and setting a user_id of 5 in the session:

get(:show, {'id' => "12"}, {'user_id' => 5})
ruby on rails
picture-2.png

Rails Note #7: NIL in Fixtures

Nov 18th

Posted by rupert in Uncategorized

No comments

If you want user_id to be ‘nil’, then omit it from your fixtures. I tried setting user_id: nil before, and it turned out to be ’0′ in the database.

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
<% u = UserLogin.create( :password => 'foo') %>
<% u.password=('password') %>
 
user_no_profile:
 email: noprofile@yahoo.com
 admin: false
 user_id: nil
 salt: <%= u.salt %>
 salted_password: <%= u.salted_password %>

Picture 3.png

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
<% u = UserLogin.create( :password => 'foo') %>
<% u.password=('password') %>
 
user_no_profile:
 email: noprofile@yahoo.com
 admin: false
 salt: <%= u.salt %>
 salted_password: <%= u.salted_password %>

Picture 2.png

Before pulling your hair out on what went wrong with your functional tests, check the test database if you have the correct values in your records. Remember ’0′ is different from ‘nil’.

ruby on rails

Rails Note #6: Pagination

Nov 16th

Posted by rupert in ruby

No comments

1. will_paginate docs
Main http://github.com/mislav/will_paginate/wikis
Reference http://mislav.uniqpath.com/static/will_paginate/doc/
Clone URL: git://github.com/mislav/will_paginate.git

2. Installation as a gem
http://github.com/mislav/will_paginate/wikis/installation
gem sources -a http://gems.github.com

Once installed, do script/server

3. Controller

class PoiAppController < ApplicationController 
  def poi_by_category
	mylimit = 100
    sql = "SELECT pa.* FROM poi_apps pa WHERE pa.id IN " +
          "(" +
			  "SELECT pc.poi_app_id " +
			  "FROM poi_categories pc " +
			  "WHERE pc.categ_node_id LIKE '" + params[:node_id] + "%%'" +
			  "LIMIT " + mylimit.to_s +
          ")"
    #@poi_apps = PoiApp.find_by_sql(sql)
    @poi_apps = PoiApp.paginate_by_sql [sql], :page => params[:page], :per_page => 10
 
  end
end

4. View

<h2>POIs</h2>
 
<div clas="page_info">
  <%= page_entries_info @poi_apps %>
</div>
 
<table>
  <tr>
    <td>POI_APP_ID</td>
    <td>CN_NAME</td>
  	<td>EN_NAME</td>
  </tr>
	<% for poi in @poi_apps %>
	<tr>
	  <td><%= poi.id %></td>
	  <td><%= poi.cn_name %></td>
		<td><%= poi.en_name %></td>
	</tr>
	<% end %>
</table>
 
<%= will_paginate @poi_apps %>

5. Checkout the styles http://mislav.uniqpath.com/static/will_paginate/

ruby on rails
« First...«89101112»203040...Last »
  • Tags

    Algorithms apache centos china coldfusion coldspring debian eclipse ExtJS firefox gdal GeoJSON google iphone javascript lbs leopard linux mac mapinfo mapserver modelglue mod_python mysql ogr2ogr openlayers oracle pgRouting postgis postgres python qmail raster reactor routing ruby ruby on rails sqlite3 subversion svn tilecache trac uml windows mobile WordPress
  • Recent Posts

    • iPhone Bug Note #1: Route-Me and Three20 in the same Project. _aasin dup symbol when building on iOS4
    • iPhone Dev Note #21: Route-Me Offline Mapping from Database
    • What I’ve learned during the past two weeks (July 26 – Aug 8) in iOS Development?
    • iPhone Note #14: Drawing a Point, Line, Polygon on top of MKMapview
    • iPhone Cross Application Launch/Marketing Strategy
    • Blogging, MyTravelPhilippines, Navteq
    • Rails Note #14: QuickStart Tutorial
    • iPhone Note #20:Integrating Mapserver/TileCache to RouteMe
    • iPhone Note #19: Route-Me: Opensource mapping for the iphone
    • iPhone Note #18: Integrating Ads (AdMob) on your iPhone App
  • Comments

    • Brgeizhh on OpenLayers + Google Spherical Mercator Example
    • insurance457501375 on Installing Firefox on Linux (Debian)
    • Xbox 360 Spiele on Installing Mapserver on Debian (reprise)
    • Iddzzlej on OpenLayers + Google Spherical Mercator Example
    • Fgnrmegh on OpenLayers + Google Spherical Mercator Example
  • Archives

    • August 2010 (4)
    • July 2010 (2)
    • February 2010 (1)
    • January 2010 (1)
    • December 2009 (2)
    • November 2009 (2)
    • October 2009 (3)
    • September 2009 (4)
    • August 2009 (13)
    • July 2009 (1)
    • June 2009 (2)
    • May 2009 (2)
    • April 2009 (1)
    • December 2008 (4)
    • November 2008 (18)
    • October 2008 (2)
    • September 2008 (6)
    • August 2008 (7)
    • July 2008 (6)
    • June 2008 (3)
    • May 2008 (9)
    • April 2008 (2)
    • March 2008 (9)
    • February 2008 (7)
    • January 2008 (7)
    • December 2007 (2)
    • November 2007 (8)
    • October 2007 (3)
    • August 2007 (16)
    • July 2007 (13)
    • June 2007 (11)
    • May 2007 (1)
    • April 2007 (5)
    • March 2007 (5)
    • February 2007 (9)
    • January 2007 (12)
    • September 2006 (5)
  • Useful Links

Mystique theme by digitalnature | Powered by WordPress
RSS Feeds XHTML 1.1 Top