Skip to main content

Posts

Showing posts from 2010

Android SDK: String Arrays and Controls like Spinners

Due to how the Android SDK and Java are setup it isn’t really a simple task to link up an array with a spinner control. I’ll go over some basics I just learned of the process. In this example I setup a setting control that will allow the user to select from a list of values. The spinner control will be initialized by the global setting value (from a black box object in this example), and a control listener will be defined that allows the user to change the global setting. To define a list of string values that can be loaded into android controls you would do something like this. You can add an arrays.xml file to your project (in the /res/values directory): <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="settinglist01"> <item>1</item> <item>2</item> <item>3</item> <item>4</item> <item>5</item> </string-a...

Android Eclipse Issue: Unparsed aapt error Unknown Android Packaging Problem

I added my first menu to an Android application through Right-click on the project in New >> Other… >> (Android) >> XML file. After editing the file I tried running it and received this error: Unparsed aapt error(s)! Check the console for output. PROJECT_NAME Unknown Android Packaging Problem A google search brought up a few results which helped. All you need to do is access the Eclipse IDE menu item: Project >> Clean… You can then clean all projects open or just the one having an issue. Seems like and file.xml.out gets generated or something causing a packing issue to occur. The clean process fixes that. A strange error that isn’t easy to diagnose without having knowledge about the IDE and Android Plug-in for sure…

Setting up Subversion (SVN) on Ubuntu Linux

After getting the Android SDK and Eclipse IDE installed and running, I started on getting Subversion ready for our first project. Here are the general steps necessary. For my configuration there is a Ubuntu server that I connect through ssh and will need to do the same to connect to SVN after everything is configured. Useful tutorials: https://help.ubuntu.com/community/Subversion https://help.ubuntu.com/community/AddUsersHowto https://help.ubuntu.com/community/AptGet/Howto Commands executed to setup the system: sudo apt-get install subversion cd / mkdir svn_repository sudo addgroup subversion sudo adduser USERNAME1 subversion sudo adduser USERNAME2 subversion # Repeat the above line for other usernames as needed sudo adduser www-data subversion cd /svn_repository mkdir android_test sudo svnadmin create /svn_repository/android_test cd /svn_repository sudo chown -R www-data:subversion android_test sudo chmod -R g+rws android_test Above I have an example where a directory called “svn_re...

Setting up the Android SDK in Linux (Eclipse IDE)

While it’s generally pretty “easy” to setup the Android SDK in Linux (in my case Ubuntu 10.04), there are a few quirks that required some searching on the Internet to figure out. The SDK and related items are located here: http://developer.android.com/sdk/index.html Here is the general process I went through to get things running: – Install JDK by typing “jdk” into the ubuntu software center and install the proper piece of software. I think you need at least version 5 or 6 for the Android SDK. – Install eclipse by getting the latest version at http://www.eclipse.org/downloads/ – Download “Eclipse IDE for Java Developers” – Extract eclipse-java-helios-SR1-linux-gtk-x86_64.tar.gz (or similar depending on what version you download) to say the… /home/user/ directory (you can run the program by double clicking on the “eclipse” icon in the main directory of the program. – I started the program and defin...

Securing Wordpress Continued...

I had written a basic securing wordpress article back in February of this year. Since then I’ve done a bit more research and came upon the idea of using Apache to help secure the administration directory and scripts, making it more difficult for intrusions to take place. It’s always a good idea to try and protect your sites as best you can. When dealing with open source software, the code is visible to the world, so any exploits that have been found can travel fast. Issues and security flaws get fixed on well known open source projects like WordPress, but it also leaves an un-upgraded system easily open to attack. One option to add a second layer of protection by using Apache server’s built-in directory password functionality. Thankfully, Askapache made a decent plug-in to save a good deal of time playing around with Apache .htaccess settings and researching the necessary code. While the plugin needs work, it functions with a bit finesse on your part. Download the Askapache Passw...

Solid Basic Javascript Input Validation

Here is a simple yet pretty powerful and easy to use way to do validation on HTML form text boxes and text areas and similar controls. It checks to make sure required form field have *something* in them before allowing processing to continue. It’s a good simple way to add some basic validation to prevent trusted individuals from forgetting to fill out required fields. This is generally useful for internal websites where you can assume the user isn’t trying to hack the site. First we have two global JS variables that define the default and error-ed state of text boxes in question. Below I have standard controls with black borders and error-ed controls with red borders. // Assign a default border color for all form controls var defaultControlBorderColor = '#000000'; // Use a special color to highlight trouble (such as if a control doesn't validate) var notificationControlBorderColor = '#ff0000'; Below I have the primary function that does the field validation. F...

Execute a console command in PHP revised

While it seems like there are multitude of different methods to execute commands in PHP, so far the code I will go over below is my preferred method. Using the passthru() function works nicely and includes the final return code of whatever was being executed, which is generally useful to me in error checking. In processing, I also include ob_start(), ob_get_contents(), and ob_end_clean() so that I can capture the console programs output and return it the user eventually. // Execute a console command and return both the // command's success value and any output to the console it made function executeConsoleCommand($commandToExecute, &$commandConsoleOutputToAppend) { $returnValue = 0;      // Append command to output $commandConsoleOutputToAppend .= $commandToExecute . "\r\n"; // Catch console output ob_start(); // Execute the console program passthru($commandToExecute, $returnValue); // Save console output to a string variable (this s...

.NET Path.Combine() in PHP

I’m the type of person who prefers to do things in a way that I perceive as the proper or correct way. While this tends to make things take a bit longer to accomplish, I feel the result ends up being better overall. One such thing I noticed is that file and path handling in PHP was missing a function I used quite a bit when writing C# code. In C# there is a Path.Combine() function that appends two file paths together to form one complete path without having to care what the beginning character and ending character of the two paths are. I wrote up a little function in PHP to mimic what happens. // Take a path and/or a filename and combine them into one file path function filePathCombine($path1, $path2) { $completedPath = ''; // Check if path1 ends with DIRECTORY_SEPARATOR if (substr($path1, -1) !== DIRECTORY_SEPARATOR) { $completedPath = $path1 . DIRECTORY_SEPARATOR; } else { $completedPath = $path1; } // Check if path2 starts with D...

Lucid Ubuntu and GDAL Latest

I’m writing some software that relies on a feature of GDAL (Geospatial Data Abstraction Library) in a more recent version than the one Ubuntu Lucid currently has in their repository. As I write the software on my desktop, I found out pretty quickly that I was using an old version of one of the commands (more specifically ogr2ogr and the clipping functionality). Thanks to this site for the initial tip, it’s pretty easy to get the latest “unstable” release of GDAL installed without having to manually compile the program from source code yourself. If you are using Karmic or above, you can run these commands: sudo apt-get install python-software-properties sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable Or you can opt for the more involved version below: In your desktop, navigate to here: System -> Administration -> Software Sources “Other Software” tab Add these two items: deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu <codename> main deb-src htt...

Speed up Netbeans in Ubuntu Linux

Java Netbeans is a pretty decent editor for PHP code. I use Linux Ubuntu now for my primary desktop computer, so it’s quite convenient and easy to get running. One issue is that in default configuration the program is a bit slow feeling. Doing a quick search I found this page: http://performance.netbeans.org/howto/jvmswitches/ Which describes a few command line parameters that might help the IDE function faster. I’m currently running the command “/usr/bin/netbeans -J-Xverify:none -J-Xmx384m -Dsun.java2d.opengl=true” Basically, it removes one unnecessary verification check, adds 256mb of RAM to the default RAM pool the program can use, and attempt to use OpenGL to render the IDE. I am currently using closed-source video card drivers, so your mileage could very with that last parameter. You can modify your default system menu link by doing this: Right-click on the “Applications” dropdown system menu. Select the “Edit Menus” list item. Cli...

.NET MONO Which Operating System is Running?

Do you want to execute operating system specific code (exes) in the .NET/Mono framework? I’ll go over how you can do that. Below is part of a class I had written that can determine if Linux or Windows is running. Keep in mind that for the code to properly detect Mac OS, you will need to figure out the proper platform number and modify the code respectively. using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace namespace1 { public static class HostOS { /// <summary> /// An enumerator that holds a list of possible operating systems /// this code can execute on. /// </summary> public enum HostEnvironment { Windows, Linux } /// <summary> /// Determine the operating system this program is running on. /// </summary> /// <returns>The current operating system</returns> /// <rem...

Wordpress Visual Editor CRLF Quirk

Adding extra vertical space (eg. carriage return) to postings in WordPress can be a pain. While there might be a plugin to fix the issue, learned by searching around that using the code: <br class="blank" /> When in HTML mode will not be deleted by the visual mode processor. So if you flip back and forth between the two input modes, that code appears to be safe from being removed.

Securing a WordPress Blog

Please view this newer article for another method of securing the wp-admin directory from access. Here are a few tips to securing a wordpress based blog or site: Change the location of your wp-content directory. This is good for making your site’s source code less discernable as a wordpress blog. In the wp-config.php file: define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content'); define('WP_CONTENT_URL', 'http://example/wp-content'); Change “wp-content” to something else. Keep in mind that some plugins are not programmed correctly and have hard-coded links to the content directory as “wp-content”, so that could cause issues. If you notice your plugins not working, open the related source files and search for the phrase. ————————– Change the admin’s login name to something besides “admin” This can be done with something like phpMyAdmin to edit the database. The user_login varchar(60) field in the wp_users table is the value you wan...