Thursday 27 December 2012

Amazon EC2 Basics (Part 1.2)


To install a regular Apache version of Tomcat 7 (c.f., the version found in the Amazon repository described in Part 1):
  • If you installed Tomcat by following Part 1, stop the currently running Tomcat service:
    • sudo service tomcat7 stop
    • sudo chkconfig tomcat7 off
    • chkconfig --list (check that everything is off)
  • Get the Apache Tomcat repo and untar it into the /opt directory in your filesystem:
    • cd /opt
    • sudo wget -c http://apache.mirror.iweb.ca/tomcat/tomcat-7/v7.0.34/bin/apache-tomcat-7.0.34.tar.gz (Go to the official Apache Tomcat website and get the URL of the binary version you want to work with. I have chosen apache-tomcat-7.0.34 here.)
    • sudo tar xvfz apache-tomcat-7.0.34.tar.gz
    • sudo ln -s /opt/apache-tomcat-version /opt/tomcat (This is optional. It creates a symbolic link to the directory.)
  • Create a user account to run Tomcat. If you installed Tomcat by following Part 1, then skip this step. Otherwise, run the following commands: 
    • sudo /usr/sbin/groupadd -g 91 -r tomcat
    • sudo /usr/sbin/useradd -c "Apache Tomcat" -u 91 -g tomcat -s /sbin/nologin -r -d /opt/apache-tomcat-7.0.34 tomcat
  • Change file permissions:
    • cd /opt/apache-tomcat-7.0.34
    • sudo chown -R root:apache-tomcat-7.0.34 *
    • sudo chmod -R go-w bin lib
    • sudo chmod -R g+rw conf logs temp webapps work
  • Create a start/stop script (preferably):
    • sudo vim /etc/init.d/tomcat
    • Type in:
    • #!/bin/sh
      # Baseline Apache Tomcat start/stop script
      #
      # chkconfig: 345 80 20
      # description: Apache Tomcat
      
      case $1 in
      start)
              /bin/su -s /bin/sh -l tomcat -c /opt/apache-tomcat-7.0.34/bin/startup.sh
              ;;
      stop)
              /bin/su -s /bin/sh -l tomcat -c /opt/apache-tomcat-7.0.34/bin/shutdown.sh
              ;;
      restart)
              /bin/su -s /bin/sh -l tomcat -c /opt/apache-tomcat-7.0.34/bin/shutdown.sh
              /bin/su -s /bin/sh -l tomcat -c /opt/apache-tomcat-7.0.34/bin/startup.sh
              ;;
      esac
      exit 0
    • sudo chmod go-w /etc/init.d/tomcat (Change permission of script file.)
  • Start Tomcat using the script:
    • sudo service tomcat start
  • You should be able to see the Tomcat manager on port 8080 of your instance! If you don't see it, make sure you change your Amazon security group permissions to allow access to port 8080. 
  • If you want to start Tomcat automatically on instance boot, type:
    • sudo /sbin/chkconfig --add tomcat
I personally chose to install the Apache version and not the Amazon version, because:
  • The Amazon version is a customised and only certain builds are available. 
  • The Amazon packages get upgraded when you update the system. This might break things.
  • Most of the help resources you find online refer to the Apache version.
(This post is based on this article.)

Monday 17 December 2012

Raspberry Pi store!

The folks at the Raspberry Pi Foundation have just released the Raspberry Pi store! There are only a couple of apps a the moment, but this is a fantastic idea and I'm really excited by the possibility of developing Python-based games for the Raspberry Pi!

Friday 7 December 2012

Smoothing edges in Photoshop

How to smoothen edges in Photoshop (something I'm going to have to do a lot for my next project):

  • Select magic wand tool 
  • Click outside of object
  • Select inverse
  • Add layer mask
  • Add gaussian blur
  • Click levels (Image -> Adjustments) 
  • Adjust to liking

Monday 3 December 2012

AngelHack Toronto : Presentation Disaster


Background :

Saturday morning, I headed off to Extreme Labs in Toronto to create an Android client for Rock88.com, an app which connects amateur rock musicians. Musicians can form gigs, attend auditions, form bands, etc. This was a solo project.




Day 1 :

I built the app up from ground up, coding all day and night. It was going extremely well. Here was when I made a huge mistake- I registered to present before anybody else had registered. This effectively meant that I was the first to present out of about 66 presenters.

Day 2 :

I applied the finishing touches to my app. I was to present at 2pm. The problem was, that the AngelHack guys didn't have a HDMI cable for me to connect my Android device to the screen.  All other devices (including Google TV) were accounted for. This was extremely frustrating- the only way to present would be to use the Android emulator. These emulators are extremely slow and horrendous.

Presentation :

An unqualified disaster. My app was beautiful, but I never got a chance to showcase it. I had only 2 minutes to present. The Android emulator immediately froze up, and there went my chances. I had prepared a few screenshots though, which I managed to bring up. However, 2 minutes just flew by and I had nothing to show.
Damage Control :

  • I sent a mail to the organizers requesting a second presentation due to the technical failures.
  • I sent mails to the judges apologizing for the failed Android emulator. This isn't surprising- Android emulators consume a lot of memory and are bulky. iOS emulators work beautifully well on the other hand.
  • There was a presentation break midway. I did what I had to. I walked up to the seated judges, and personally demo-ed my product on my Android device. Some of them didn't seem interested; others were more receptive. I was satisfied though- my presentation might've been an unqualified disaster, but at least they had seen my product in action.

Lessons Learnt :
  • Have backups : I should have created a powerpoint presentation for this. Although I did have the screenshots, they were not organized in any order and the judges likely got confused.
  • Don't depend on the organizers to make provisions for your product : I should've purchased an Android HDMI cable beforehand. Relying on the Android emulator is possibly the worst thing anyone can ever do.
  • NEVER be the first presenter : I "submitted" my app the first, which by default, made me the first presenter. Presenting early is probably a good thing, but never first.
Conclusion :

Kinda disappointing. I went without any sleep, built a beautiful app, but screwed up the presentation. However, I took a chance and personally demo-ed the product to the judges during the break. I felt way better after that. Anyway, I shall work on Rock88 to completion and release it in the coming few months.

Other comments :

Wifi connectivity was poor, but the organizers (Hackernest) did a great job overall.

Congrats to the winners - Airpost (Met Alam and Angelo beforehand),  Raffi (Met Ian beforehand) and Froogler (Didn't meet anyone from this team beforehand).

Presentation order :

Airpost   - 49 / 66
Raffi       - 29 / 66
Froogler  - 13 / 66

Rock88 Screenshots :