Archive for Dev Notes’ Category

12

Jul
2012
Comments Off on Installing MySQL on CentOS

Installing MySQL on CentOS

First thing you need to do is make sure the binaries are installed using yum. Note that this will only install MySQL and that you may need to run it as root depending on your systems permissions.

[korey@localhost ~]$ yum install mysql-server mysql

The next thing is start MySQL:

[korey@localhost ~]$ service mysqld start

Once you start the service, it will give you some instructions for having it start automatically on reboot, and how to secure it.
Finally, secure MySQL, by setting a password for the root user and removing the anonymous user. Just make sure you use the same password for the first two statements below, otherwise you’ll end up scratching your head as to why you cannot login sometimes.

[korey@localhost ~]$ mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('****');
mysql> SET PASSWORD FOR 'root'@'localhost.localdomain' = PASSWORD('****');
mysql> DROP USER ''@'localhost.localdomain';
mysql> DROP USER ''@'localhost';
read more

25

May
2012
Comments Off on Installing your Android App on your Phone

Installing your Android App on your Phone

One part of testing an Android app is installing it on an actual phone and making sure that it still behaves as you expect. Given the fact that there are so many different vendors that tweak the OS in order to create a unique experience for their end users before shipping it off with their custom screen resolution phone, there is a lot that can go wrong with an android app. TechCrunch recently had an article about how a hong Kong based company tests their apps and it was a scary realization.

Back to our point here! Once you have the app ready, you may want to send it to a customer or another friend to validate and chances are that they do not have and Android development environment setup to compile your code and push it to the device, so here are two other ways:

(Note: the instructions here are geared towards linux based systems. Adjust as necessary for Windows)

The some-what technical way

  1. Install the Android SDK.
    For the sake of this example we will assume it is installed in ~/AndroidSDK. (Note: For Windows you may need to installed the USB drivers as well)
  2. Make sure that USB storage is turned off. This is typically off by default and you can get to the screen once you have connected you phone to your PC via USB. Swipe down from the top of the screen (just like you do to see your notifications) and choose the USB Connected option.
  3. Make sure that you can install apps from unknown sources.
    To do this, go to ‘Settings’, click ‘Security’ and make sure ‘Unknown sources’ is checked.
  4. Now open a terminal (or command) window and run the following commands to make sure that the SDk can see your device.
    1
    2
    3
    4
    
    > cd ~/AndroidSDK/platform-tools
    > ./adb devices
    List of devices attached 
    XXXXXXXX5B3900XX	device
  5. Now run the following commands to install your .apk file. For the sake of this example, our file is located at ~/dev/myApp/bin/myApp.apk.
    1
    2
    
    cd ~/AndroidSDK/platform-tools
    ./adb install ~/dev/myApp/bin/myApp.apk

    You can optionally provide a -s parameter to install the app on the SD card.

  6. You should now see the app in the list of your installed apps

The really easy way

For folks that are not technical, there is an easier way.

  1. Go to the Google Play store and install AppInstaller (free app).
  2. Copy the .apk file to the SD card of your phone.
    this can be done in two ways:

    1. If your phone has an SD card that can be taken out, you can insert the SD card into your PC and copy the file
    2. If your phone does not have an insertable SD card (like the Nexus S), then connect your phone to your PC via USB, turn on USB storage, copy the .apk file to your phone’s SD card and disconnect the phone
  3. Run the AppInstaller app
  4. The app will list all the apk files on your SD card. Select your .apk file to install it
  5. Note: In this case, you may still have to check the option to be able to install apps from ‘Unknown sources’

read more

7

Mar
2012
Comments Off on Another Blow to J2EE

Another Blow to J2EE

I recently came across the Play framework (not to be confused with the new name for the Android Market Place). Think of it as the Java version of Ruby on Rails, or one of a dozen other frameworks that leverage convention over configuration.

The real beauty here is that you get all the benefits of compiled code with the ease of use of scripted languages.

With all of these light, easily scalable frameworks, why would you need a full J2EE stack? In my opinion, the latter is only necessary in very rare situations, where as the former will do the job most of the time with more ease and less cost. Its the old 80-20 rule.

read more

7

Mar
2012
Comments Off on Reproducable Development Environments

Reproducable Development Environments

Have not had a chance to try this out yet, but Vagrant seems like a great solution to create small, portable development environment.

With this, there will be less of “Well it works on my box!”. You can just receive the development environment where the problem exists and easily reproduce it.

read more

4

Jan
2012
Comments Off on Adding Titanium Modules

Adding Titanium Modules

Appcelerator Titanium is a decent tool once you get used to its quirks. However, it is even more powerful with its marketplace and optional modules you can add to it. Two of my recent purchases have been from 0x82: Testflight, and KeyChain.

here is a quick quide on how to add new modules to your titanium project:

  1. Unzip the downloaded module.
  2. Copy it to the following folder on OSX Lion /Library/Application Support/Titanium/modules. Be sure to drop it in the right location according to the unzipped folder structure of the module.
  3. Edit your project’s tiapp.xml file and add the following:
  4. <modules>
        <module platform="iphone" version="0.5">com.0x82.key.chain</module>
        <module platform="iphone" version="0.7">com.0x82.testflight</module>
    </modules>
  5. Start Titanium Studio and follow the module’s instructions to integrate it into your project.

 

Good luck!

read more

2

May
2011
Comments Off on Getting started with PhoneGap

Getting started with PhoneGap

PhoneGap just released version 0.9.5, but it still does not fix the issue with getting a project started with Xcode 4. Here is what I did to get my project going:

  1. Make sure Xcode is closed.
  2. Install the latest version of PhoneGap
  3. Go to Xcode prefrences -> Source Trees -> Add a new entry PHONEGAPLIB = /Users/<your username>/Documents/PhoneGapLib
  4. Either get create_script.sh, or use PhoneGap’s build system to get you started.

create_script.sh

This is harder of the two routes, and it may have just been my experience due to point #1, but all you have to do is provide two parameters: a) the project name b) The path where it needs to be installed.

PhoneGap Build

This is easy as cake. Just put in your project name and in 30 seconds or so you get a project zip file you can download and get started.

Happy coding!

read more

28

Oct
2010
Comments Off on Add new files to SVN from the command line

Add new files to SVN from the command line

Here is a little tip for automating files that need to be added to SVN.

First make sure you are in your project folder that is under source control. Then try the following:

svn status | grep -e ^?

With this you’ll notive that it will list the files, but its not in a format ready automatable. So lets enhance it:

svn status | grep -e ^? | awk '{print $2}'

This time we get a list of the files that need to be added, but lets take it a step further and also add the files to SVN in one step:

svn add `svn status | grep -e ^? | awk '{print $2}'`

There. Now all you have to do is commit.

read more

5

Oct
2010
Comments Off on GAE: Querying on Child objects using parent Key

GAE: Querying on Child objects using parent Key

This post is about the Google App Engine and its limitations. I googled for a while to try and find an article on how to do better queries using the datastore, but I did not find what I needed. I hope this helps some of you out there.

I have a a bunch of child entities, but I only want a select few of them, so I need to query like good old SQL.

here is the scenario:

@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class A {
}
 
public class B  extends A {
    List<D>members;
}
 
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class C extends A {
    B owner;
}
 
public class D extends C {
    boolean active;
}
 
public class E extends C {
    String otherProp;
}

As you can see A is my base object with some properties that I want all my objects to have. Now i want to get all Cs that are active and belong to a particular B. Well, the short answer is you cannot and that is because the relationship is not directly on the child class but is on its super class. This must be a bug!!!

Solution is to move the property down to both D and E, then I can do the query I want and get on with the rest of my life.

JDO:

1
2
3
4
5
6
Key ownerKey = KeyFactory.stringToKey(ownerKeyString); 
String queryStr = "select from " + C.class.getName() + 
                        " where owner == ownerParam && active == true"; 
Query q = pm.newQuery(queryStr); 
q.declareVariables(B.class.getName() + " ownerParam"); 
myCs = (List<C>)q.execute(ownerKey);

Here is a thread where I was discovering this.

read more

5

Oct
2010
Comments Off on Get going with Tomcat & Eclipse on OSX

Get going with Tomcat & Eclipse on OSX

I recently had to move a project off of Google App Engine. To my surprise, Google App Engines performance was just not fast enough for this project.

In any case, this lead to my installation of Tomcat on OSX and integrating into Eclipse so here is how to do it:

  1. Get the latest tomcat: http://tomcat.apache.org/index.html. You need to make sure you get the tar or zip file.
  2. Move the download to /usr/local/.
  3. Start a super shell:
  4. $ sudo sh
  5. If you downloaded the tar, you may have noticed the warning that it will not work with OSX tar command, so make sure to use gnutar which comes with OSX.
  6. $ gnutar xzvf apache-tomcat-6.0.26.tar.gz
  7. Now you can change owner ship on this new folder so you can start and stop tomcat without having to sudo, but I left it as is.
  8. Create a link to the folder so that you make your life eaiser in the long term when you install newer versions:
  9. $ ln -s apache-tomcat-6.0.26 tomcat
  10. Go back to your home folder and create a new script :
  11. 1
    2
    3
    4
    5
    6
    7
    8
    
    #!/bin/sh
    export CATALINA_HOME=/usr/local/tomcat
    export JAVA_HOM=/usr
    if [ "$1" == "start" ] ; then
        $CATALINA_HOME/bin/startup.sh
    else
        $CATALINA_HOME/bin/shutdown.sh
    fi
  12. Now you can start and stop tomcat from your home folder
  13. $ sudo ./tomcat.sh start  <== To start
    $ sudo ./tomcat.sh        <== To stop

Now that Tomcat is setup, you need to configure it in Eclipse:

  1. Go to Eclipse Preferences ->Server -> Runtime Environments
  2. Click Add and select the right Tomcat Version
  3. Put in /usr/local/tomcat for the Tomcat Installation directory (the link we created above)
  4. Click Finish and you should be setup
    1. Good Luck!

      read more

Page 2 of 212