Archive for the Programming Category

Google Custom Search – Restricted to specific directory, and filetype…

Posted in CSE, Custom Search Engine, Google, Google, Information Technology, JavaScript with tags , , , , , , , , , on 2012.26.01 by w3bguy

So I’ve been having trouble getting a new Google Custom Search to look only in a specific directory on my web server, as well as to only look at specific file types.   It seemed like this should have been SO easy…  But, it took me a bit to figure it out.  So here’s the information just in case anyone else needs it.

  1. Set up a new search engine, in Google Custom Search.
  2. Make sure that you have the root directory in the “Sites” section.  I used “”.
  3. You can enter refinements, but they only seem to work if the user clicks on them; not what I wanted.
  4. Go down to “Get Code” and grab the code block that is created for you.  For me it was this:
    • <div id="cse" style="width: 100%;">Loading</div>
        <script src="" type="text/javascript"></script>
        <script type="text/javascript">
          google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
          google.setOnLoadCallback(function() {
            var customSearchOptions = {};
            var customSearchControl = new
              'Custom Search ID', customSearchOptions);
          }, true);
  5. This will give you the basic search.  In order to add in the site restriction and the filetype restriction I changed it to:
    • <div id="cse" style="width: 100%;">Loading</div>
        <script src="" type="text/javascript"></script>
      <script type="text/javascript">
      google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
      var customSearchOptions ={};
      /* Add Custom Search Option to restrict directory */
      customSearchOptions []={"as_sitesearch": ""};
      var customSearchControl = new"Custom Search ID", customSearchOptions );
      /* Add query addition to restrict filetype */
      function(control, searcher, query) {
      searcher.setQueryAddition("filetype:pdf OR filetype:PDF");
      }, true);

    I hope that helps out anyone else who might be looking for a similar problem…


Move a file to a shared drive in Java

Posted in Information Technology, Programming with tags , , , , , on 2011.28.11 by w3bguy

I had a bit of trouble with this, in a program I’m writing at the moment. Every time I tried to move a file to a shared folder, on my computer, it would fail. Turns out, it (apparently) because Java doesn’t necessarily share my mapped drives. Here’s the code that I used to overcome this:

System.out.println("Try to move file");

// create a net use command to map the drive...
String command = "c:\\windows\\system32\\net.exe use Z: \\\\\\f$";
Process p = Runtime.getRuntime().exec(command);

// create an instance of the file to move
File f=new File(".\\myImage.jpg");

// make sure that the file actually exists
boolean fileExists=f.exists();
System.out.println("File Found");
System.out.println("File Not Found");

//create a random number and timestamp, for a unique file name
Random rand = new Random();
int randNum = rand.nextInt();
Date date=new Date();

// Create the new filename
String newFileName=new String("myImage_"+date.getTime()+"_"+randNum+".jpg");

//try to move the file
boolean moved=f.renameTo(new File("Z:\\Home\\ITS\\sigImages\\"+newFileName));
System.out.println("File moved -&gt; "+newFileName);
System.out.println("File Not moved");
}catch(Exception ex){

I’m sure there is a more elegant way of doing this, that more experienced Java programmers will know. But, I could not find too much out there on the web… Hope this helps someone…


HTML5 Cheat Sheet

Posted in HTML5, Information Technology Links, Programming, Programming Links, Web Development on 2011.23.07 by w3bguy



HTML5 Cheat Sheet

HTML5 Cheat Sheet


Just finished my first actual Adobe Air application

Posted in Adobe Air, Adobe Flex, Desktop Applications, Google, Programming, Programming Links on 2011.22.07 by w3bguy

So, I just finished my first actual Adobe Air application.

Version 1.0 is a basic QR code generator.  This version just takes a string and embeds it into the QR Code; created for use with URLs, but it will take any string.  The next version will have fields for creating contact information QR Codes.

Search for non-duplicates bettween two tables.

Posted in Information Technology, MySQL, PHP, Programming, Web Development with tags , , on 2011.17.02 by w3bguy

I recently had some issues trying to make sure that two columns from two different tables were the same.  After some random code writing, I came up with the following MySQL code…  Hope it helps others…

/* return from first table */
$checkTable1=@mysql_query("SELECT table1.column1 FROM table1 LEFT JOIN table2 ON table2.column2 = table1.coumn1 WHERE table2.column2 IS NULL");

/* return from second table */
$checkTable1=@mysql_query("SELECT table2.column2FROM table2 LEFT JOIN table1 ON table1.column1 = table2.column2 WHERE table1.column1 IS NULL");

I’m sure there is a better way to accomplish it, but this worked for my needs…  Just a quick search, and then I added some extra code to update the tables if there are any discrepancies.


Easy GPS Coordinates

Posted in Google, Google, Google Maps, JavaScript, Web Development with tags , , on 2010.05.11 by w3bguy

Ever need to find the GPS coordinates for a location?
Try the simple step below to get the GPS coordinates for any location, using Google Maps:

  1. Open Google Maps, and find the areayou wish GPS coordinates for
  2. Right click at the specific spot you would like GPS coordinates for
  3. Select “center map here” from the list
  4. Paste this JavaScript code into the address bar
    • javascript:void(prompt(”,gApplication.getMap().getCenter()));
  5. Press Enter on your keyboard
  6. A pop-up will appear showing the coordinates of the center of the map. It should look something like this: (43.60336, -110.7362)
  7. Right click on the coordinates to copy, and click either “OK” or “Cancel”

13 Super Useful jQuery Content Slider Scripts and Tutorials

Posted in Information Technology, JavaScript, jQuery, Programming on 2010.21.07 by w3bguy

via WDL

You’ve probably noticed that a lot of websites lately have a featured area with content that slides or changes in some way. This is a great technique to show several pieces of content in a limited amount of space and a good way to engage the user. If you’ve been wondering how this is accomplished, here are 13 very useful tutorials and scripts that will help you create these types of effects using jQuery.