Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Subscribe to this RSS Feed
  • Retuning a MySQL Query in CSV
    01/07/2011 8:25AM

    The following is an example of how to run a query on the command line to output the result of a MySQL query to a CSV file.

    Create a text file with the your query, query.sql:

    SELECT * FROM hosts;

    The run the following command:

    mysql --skip-column-names -uuser -ppassword database < query.sql | sed 's/\t/","/g;s/^/"/;s/$/"/;' > filename.csv

    This will run the MySQL query and output the results to a text file in .csv format.

    The sed commands do the following:

    Replace all 'tabs' with ","

    s/\t/","/g;

    Print a " at the beginning of the line

    s/^/"/;

    Print a " at the end of the line

    s/$/"/;

    If you have a single column of data that is returned and want that in CSV, run an additional sed command on the output:

    sed ':a;N;$!ba;s/\n/,/g' > filename.csv


  • Retrieving a Previously Deleted File in Subversion
    12/27/2010 1:06PM

    Let's say that you have deleted a file (or directory) in your checked out copy of a svn repository and then checked it in (committed your change).

    You discover that you really would like to have that file back in your current version of your repo.? You can either us the svn merge command, or copy the file from a previous version of your repo.

    Here is how you can copy the file from a previous version:

    svn rm blah.txt
    svn commit blah.txt -m "removed blah.txt"

    (now you are at version 15)
    Make a number of other commits/changes, and now you want blah.txt back from version 14.

    svn cp url/to/repo/blah.txt -r14 blah.txt
    svn commit blah.txt -m "retrieved blah.txt from r14"

  • Setting up Proxy Authentication for a Linux Box to use yum
    12/13/2010 10:50AM

    Should you find yourself running a Linux box behind a proxy that requires authentication you will need to update your setup so that you can get access to the outside world, and make some configuration changes to yum.

    First, add the following to your /etc/yum.conf (note, this is incredibly insecure as you will now have your proxy uid and password in clear text on your machine.? You should remove your login details after you have made your connections):

    proxy=http://proxy_url:80
    proxy_username=uid
    proxy_password=passwd

    Secondly, if you want to have access to the outside world for other processes you'll need to edit your .bash_profile and add the following (again, this is really insecure):

    http_proxy=http://uid:password@proxy.url.com:80

    source your .bash_profile and now you should be able to authenticate to the proxy server.


  • Mount Your Motorola Droid Under WinXP
    09/06/2010 9:37PM
  • An Excellent Beginners Tutorial for Apache Ant
    05/04/2010 11:00PM
Advanced Search

Categories

Archives