Archive by Author

Galaxy S Setup & Apps

So I’ve had the Galaxy S for a while now so I thought I’d share my current setup and what I have installed.

I’m still running Android 2.1. The official Samsung release of 2.2 (for africa) is supposed to be here before the end of the year so i’m holding out for that before I start playing around with other 2.2 ROMs.

I have however rooted the phone in order to install certain apps. If you’re not sure what that is, rooting your phone basically gives you greater access to all areas of the OS that you don’t have by default. For a full explanation on rooting your device, read this blog post. Note this does void your warranty, but you can easily unroot your phone.

These are just few of the apps I have installed that generally improve the overall performance/experience of the device:

One Click Lag Fix (requires rooting)
- In a nutshell, this app will speed up your phone. Although it is a lot more complicated.

Market Enabler (requires rooting)
I live in South Africa which is one of countries that don’t yet have access to paid apps on the Android Market. This handy little app will fake your country allowing you to see and purchase paid apps. It’s not permanent and goes back to normal after a reset. It’s available to download via the Android Market.

Samsung Home Screen Changer (requires rooting)
- This will change the default home screen to whatever you select. By default its always the first home screen.

Rom Manager Free Version (requires rooting, available in the Market)
- This tool allows you to manage your roms. Backup, Restore and do OTA updates. I just use it to keep backups of my stock samsung rom.

TypoClock
- This is a very nice clock widget. Way better than any Samsung or Androd clock widget.

ConnectBot
- SSH client. Handy for when you are no where near a pc.

Beautiful Widgets (paid – about $2.05)
- Beautiful Widgets comes with some very nice clock & weather widgets. Its very customizable and there are plenty of  user-submitted skins to be downloaded for the clocks & widgets.

Zedge
– While I would normally avoid any website that even mentioned the words “Free ringtones & wallpapers” like the plague, Zedge is not like those. It has thousands of user submitted wallpapers and ringtones. If you register on their site for an account (optional), you can mark your favourites which allows you to easily get the items back if you lose them for whatever reason.

Angry Birds
- No list of apps would be complete with out this game. No explanation needed, just go download it and clear your schedule the next 3 or 4 hours.

I take no responsibility if you break your phone :)

My Latest Gadget – Samsung Galaxy S

I’ve been wanting an Android device for sometime now because I want to start writing apps (or atleast start learning to write apps). I finally settled on the Galaxy S, but the HTC Desire came very close.

Theres just no comparison to my Samsung Omnia i900 and I’m glad to be rid of Windows Mobile 6.1.

The Galaxy is running Samsungs TouchWiz 3.0 and I had read a lot of bad reviews about it while researching the phone, but so far I’ve had no issues with it. Although I suppose anything is better than WinMo 6.1.

There are a few small issues with the phone but overall I’m really happy with it. The main issue I had was USSD messages (for checking your balance etc) were not working. I read somewhere that it’s Samsungs Mobile Tracker that breaks it. Mobile Tracker is for locating your lost/stolen phone among other things. Disabling this feature fixed the problem. This has apprently been fixed in the 2.2 firmware.

Kohana HTTPS redirect

To redirect to https in Kohana use the site function in the URL class to create the URL.

eg

$url = URL::site(Route::get('ROUTE_NAME')->uri(), 'https');
Request::Instance()->redirect($url);

To force actions to be loaded using https I do something like this:

The main template controller:

class Controller_Whitelabel extends Controller_Template
{
 
public $ssl_required = false; //controller-wide ssl required
public $ssl_actions = false; //action specific ssl required
 
public function before()
{
 
  parent::before();
 
  $this->sslRedirect();
 
   ..........
}
 
private function sslRedirect()
{
 
   $action_name = Request::instance()->action;
 
   if ( ($this->ssl_required) || (is_array($this->ssl_actions) && in_array($action_name, $this->ssl_actions) ) )
   {
 
      if (Request::$protocol == 'http')
      {
         Request::Instance()->redirect(URL::site(Request::Instance()->uri, 'https'));
      }
 
   }
   else
   {
      if (Request::$protocol == 'https')
      {
         Request::Instance()->redirect(URL::site(Request::Instance()->uri, 'http'));
      }
   }
 
   }

It allows you to set either all actions to require ssl, or only specific ones.

Example Controller where all actions require ssl:

class Controller_Payment extends Controller_Whitelabel {
 
   public $ssl_required = true;
 
   ......
}

Example Controller where only the index & list actions require ssl:

class Controller_Payment extends Controller_Whitelabel {
 
   public $ssl_actions = array('index', 'list');
 
   public function action_index()
   {
   }
 
   public function action_list()
   {
   }
 
   public function action_view()
   {
   }
}

MyGate PHP Class

I’ve been working on a PHP class for integrating Mygate’s payment gateway.

Its not 100% finished so I wont upload it just yet, but its a starting point and the basics are working. If you’re interested in it let me know.

This is for the ‘My Enterprise’ service.

Quotes database – kwotes.co.za

I finished my first personal project using the Kohana Framework. I wanted to see how quickly I could get a very basic site up and running.

I used the ORM plugin (in some areas) for the first time. It works well and is quite straight forward, but I still prefer writing my own SQL.

I build a very simple quotes website with a mobile equivalent. Over all it probably took about a week of doing a few hours each evening. Its lacking in design, but I didn’t want to spend too much time on the css.

Site: www.kwotes.co.za

Mobile Site: m.kwotes.co.za

Kohana Framework

kohana For my latest project I was looking for a much lighter framework than Symfony or CakePHP. All I really wanted was an MVC framework that could handle the routing and templates. I came across Kohana which was originally based on CodeIgnitor (it has since been rebuild from the ground up in PHP5). Version 3.x had just been released so I decided to go for that.

The only problem I have at the moment is lack of decent documentation, but there is an unofficial wiki which covers a fair amount, and an active community of users. But the next best thing is to just browse the API for whatever you need.

So far i’m happy with my decision and the project is going smoothly. In the next few weeks I will post some code snippets and modules that I have written.

Migrating symfonydev.co.za

Its been almost a year since I’ve done any dev work with symfony. Therefore I have migrated symfonydev.co.za over to here. I have since started using a few other PHP frameworks so having a blog related only to symfony didn’t make sense anymore.

Posting to Twitter using PHP

I haven’t had much to post about lately so I’ll just share a simple bit of code to update your Twitter status and shrink any urls in the post. Maybe someone will find it useful.

I downloaded a small Twitter class from here but the download link doesnt seem to work anymore so leave a comment if you want the script. There are also loads of other free PHP twitter scripts so just do a search.

The site I was building just needed to post the name and url of an item to twitter. This bit of code will first shrink the URL using TinyURL’s api, then post to twitter.

Note: I wrote this for a Symfony 1.0 project. I haven’t used sfWebBrowser in 1.2 so im not sure if it will work, but you could replace it with cURL or even just file_get_contents()

$curTwitter = new twitter("USERNAME", "PASSWORD");
 
$b = new sfWebBrowser();
$my_url = 'http://www.YOUR-DOMAIN.com/';
 
$b->get('http://tinyurl.com/api-create.php?url='.$my_url);
$tinyurl = $b->getResponseText();
 
$curTwitter->setStatus($this->getRequestParameter('name'). ' ' . $tinyurl );


Update: Forgot to mention, sfWebBrowser is a plugin for anyone who didnt know.


Follow me on twitter

Loading helpers from an action or model in Symfony 1.2

Just quick post today about loading helpers in symfony 1.2 from an action or model.

Previously I would use the sfLoader class to load a helper, but it now says:

The sfLoader::loadHelpers() method is deprecated. Please use the same method from sfApplicationConfiguration.

So, from the action you should now use:

$this->getContext()->getConfiguration()->loadHelpers('Url');

From the model you can use:

sfContext::getInstance()->getConfiguration()->loadHelpers('Url');

multiple TinyMCE editors with sfWidgetFormTextareaTinyMCE

I noticed the other day that when using the sfWidgetFormTextareaTinyMCE widget which is part of the sfFormExtraPlugin plugin, it wouldnt display more than 1 editor on a page. After looking at the class and comparing the javascript to the javascript that was generated by the old textarea_tag() function I noticed a few differences.

To fix this, copy \plugins\sfFormExtraPlugin\lib\widget\sfWidgetFormTextareaTinyMCE.class.php to \lib\widgets\ and make the following change to the javascript:

<script type="text/javascript">
  tinyMCE.init({
    mode:                              "exact",
    theme:                             "%s",
    elements:                          "%s",
    %s
    %s
    theme_advanced_toolbar_location:   "top",
    theme_advanced_toolbar_align:      "left",
    theme_advanced_statusbar_location: "bottom",
    theme_advanced_resizing:           true
    %s
  });
</script>

You will probably have to create the \lib\widget directory. Dont forget to clear your cache.