Archive for Dev Notes’ Category

19

Jul
2012
Comments Off on Configure Witopia VPN on DD-WRT

Configure Witopia VPN on DD-WRT

I like using a VPN service for a more secure browsing experience and I have used Witopia for the past little while with great success. The only issue was that I had to install it on all the PCs that I wanted to use it with and then remember to turn it on, etc which I did not like very much. So after a decent amount of googling, I decided to get a second router that supports DD-WRT and set that up to always be connected via VPN. This way, it is just a matter of switching my wireless connection from any device. After some research I settled on Buffalo AirStation WHR-HP-G300N (bought from Newegg) which is a tiny little router that comes with DD-WRT installed. The only downside, I later found, is that since it’s got smaller memory on-board it does not support OpenVPN. Witopia itself does provide a Cloakbox Pro device itself which is a higher end Buffalo router pre-configured to VPN, but I wanted to do it my way. So keep in mind as you read the instructions below that my setup is using a VPN router that is behind my main router.

Setup Instructions

  1. Add Google’s public DNS servers as static DNS servers for the DHCP server. Note that since my main router is using 192.168.1.x, I put this router on 192.168.11.x to make sure there is no complications.
  2. Configure the wireless access point on the router so that it does not conflict with your main wirless connection (i.e. give it a different name and use a different channel to be extra safe).
  3. Enable and configure the PPTP client on the router to connect to your favorite VPN location. You can get a list of the VPN location for Witopia here. For the Server IP or DNS Name I put in the IP address of the vpn server I wanted to connect to (e.g. pptp.chicago.witopia.net).
  4. Add a startup script to the router to configure it to use the VPN connection properly. The script below will wait until VPN is connected and then update the router’s routing appropriately. Note that 192.168.1.1 is the internal IP of my main router, not the VPN router which is 192.168.11.1.
    echo "echo \"Startup Config started\" >> /tmp/mylog.txt" > /tmp/startupConfig.sh
    echo PPTPSERVER=$(/usr/sbin/nvram get pptpd_client_srvip) >> /tmp/startupConfig.sh
    echo PPTPGWY=192.168.1.1 >> /tmp/startupConfig.sh
    echo "/sbin/route add -host \$PPTPSERVER gw \$PPTPGWY" >> /tmp/startupConfig.sh
    echo "#/sbin/route del default" >> /tmp/startupConfig.sh
    echo "/sbin/route add default gw \$PPTPGWY metric 100" >> /tmp/startupConfig.sh
    echo "/sbin/route add default dev ppp0" >> /tmp/startupConfig.sh
    echo "/sbin/route del default" >> /tmp/startupConfig.sh
    echo "/sbin/route del default" >> /tmp/startupConfig.sh
    echo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE >> /tmp/startupConfig.sh
    
    echo "ifconfig ppp0 > /dev/null" > /tmp/whileLoop.sh
    echo "RC=\$?" >> /tmp/whileLoop.sh
    echo "echo \"Checking ppp0: \$RC\" >> /tmp/mylog.txt" >> /tmp/whileLoop.sh
    echo "while [ \$RC -ne 0 ]; do" >> /tmp/whileLoop.sh
    echo "  sleep 5" >> /tmp/whileLoop.sh
    echo "  ifconfig ppp0 > /dev/null" >> /tmp/whileLoop.sh
    echo "  RC=\$?" >> /tmp/whileLoop.sh
    echo "  echo \"Checking ppp0: \$RC\" >> /tmp/mylog.txt" >> /tmp/whileLoop.sh
    echo "done" >> /tmp/whileLoop.sh
    echo "echo \"Running startupConfig.sh\" >> /tmp/mylog.txt" >> /tmp/whileLoop.sh
    echo "ifconfig ppp0 >> /tmp/mylog.txt" >> /tmp/whileLoop.sh
    echo "sh /tmp/startupConfig.sh" >> /tmp/whileLoop.sh
    
    sh /tmp/whileLoop.sh &
    
Once all this is setup, connect to the wireless for the VPN router, and go to IP Location Finder and make sure that it reports your location correctly. If it is still reporting your current location, then VPN is not working and you have to get your hands dirty and login to the router itself and poke around. That is beyond what I wanted to get into here, but I am sure you can find your solution on the internets. read more

12

Jul
2012
Comments Off on Calculate the Broadcast IP for your network

Calculate the Broadcast IP for your network

There is a good article on how to calculate the broadcast IP based on your IP address and net mask on eHow. What I have here is a quick utility to facilitate things.
provide IP and netmask:
IP:
Netmask:
Broadcast IP:


read more

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.
    > 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.
    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

Page 2 of 3123