Executing Dynamically Generated SQL Queries in a Shell Script and Saving the Output to a Variable

If you would like to, in a shell script, dynamically generate SQL queries for MySQL and save the output of those queries to a variable that you can then use in the script, here is an example:

#!/bin/bash

for i in `cat tables_list.txt`
do

   # Build the query
   QUERY="SELECT count(*) FROM ${i}"

   # Run the query from the command-line and save the
   # output into the $ROW_COUNT variable
   ROW_COUNT=$(echo $QUERY | mysql -u${USER_NAME} -p${PASSWORD} -h ${HOST} -P ${PORT} --skip-column-names ${DBASE})

   
Continue reading “Executing Dynamically Generated SQL Queries in a Shell Script and Saving the Output to a Variable”

Install Android Application Directly Without it Being in the Market

When developing apps you will not only want to test them against the Eclipse AVDs but also install them on an actual device.

To do so, set up an HTTP server (here is a link to another article on how to set up a quick and dirty HTTP server) and put you .apk file somewhere where you can get to it from your local network.

Make sure that you check the ‘Unknown sources’ setting that will enable you to → Continue reading “Install Android Application Directly Without it Being in the Market”

Deleting Safari Cookies in iOS Simulator

If you are doing any kind of development that involves cookies and need to be able to delete them while testing iOS you will likely need to delete them as well.

The iOS simulator (Launched from Xcode by going to Xcode > Open Developer Tool > iOS Simulator) stores data for the simulator in the following directory on the host Mac OSX file system:  /Users/<uid>/Library/Application Support/iPhone Simulator/

First, quit out of the iOS Simulator.

To find the cookies and delete → Continue reading “Deleting Safari Cookies in iOS Simulator”

Executing Dynamically Generated SQL Queries from a Shell Script

Following is how to generate dynamic SQL in a shell script and then execute those queries.

Let’s say, for instance, that you have a list of tables that you want to flush regularly during development and don’t want to type in the SQL queries each time.  Moreover, you just want to maintain a list of the table names and add and remove from it when necessary and have your script dynamically generate and execute the delete statements.

For the purposes → Continue reading “Executing Dynamically Generated SQL Queries from a Shell Script”

Setting Up Android SDK and Plugin in an Existing Install of Eclipse

To set up an existing install of Eclipse to do some Android development do the following:

  • Go to http://developer.android.com/sdk/index.html and look for and download the ADT bundle for your OS (in my case I was using Fedora Core 18 at the time)
  • Unpack it as the user that is going to be running Eclipse and/or after you unpack it make sure that your user has read/write/execute permissons for the files in this directory (obviously, you don’t need execute permssion for
Continue reading “Setting Up Android SDK and Plugin in an Existing Install of Eclipse”

Showing Hidden Files and Folders Under Mac OSX

By default the Mac hides a number of different Folder as well as any file or folder that starts with a “.” character.

To show all of these files/folders in the Finder open a terminal and enter teh following commands:

$ defaults write com.apple.Finder AppleShowAllFiles TRUE

$ killall Finder

The Finder should restart and you should be able to see all of the files and folders on the machine.→ Continue reading “Showing Hidden Files and Folders Under Mac OSX”

Do Not Use Symlinks in Jetty’s webapps Directory

I set up a development instance of Jetty on my local machine and have been happily coding, compiling and deploying via a shell script.  The script copies the war from my user’s target directory to the jetty users’s home dir changes the permissions and then moves it to the /webapp dir creating a symlink to the name of the .war that is referenced in a number of config files.

This was working just fine until I did a merge with → Continue reading “Do Not Use Symlinks in Jetty’s webapps Directory”

Getting Markdown Viewer To Display HTML Formatted Markdown Content in Firefox Under Linux

I recently installed the Markdown Viewer 1.3 in Firefox 23.0 under Fedora Core  18.  When I went to open a .md file in the browser it prompted me to download it.

To configure Firefox to display the markdown in the browser do the following:

Edit the ~/.mozilla/firefox/*default/mimeTypes.rdf file.

If there is not yet an existing RDF node for ‘text/plain’ add it, and add “md” as a file extension.

<RDF:Description RDF:about=”urn:mimetype:text/plain”
        NC:value=”text/plain”
        NC:fileExtensions=”md”
        NC:description=”Text Document”>
    <NC:handlerProp RDF:resource=”urn:mimetype:handler:text/plain”/>
Continue reading “Getting Markdown Viewer To Display HTML Formatted Markdown Content in Firefox Under Linux”

Internet Explorer Not Deleting Session Cookies

If you are trying to delete session cookies, those cookies with an expires or max-age value of -1 or no value set for that property, in Internet Explorer, you will probably notice that deleting them from the controls in the browser, does not actually delete them.

Evidently, the IE cookie implementation only writes persistent cookies to the file system and maintains the session cookies in RAM.  Moreover, when telling the browser to delete the cookies, it only deletes the cookies → Continue reading “Internet Explorer Not Deleting Session Cookies”