eTechtips

Tech Tips and Insights

Category: Uncategorized

  • Windows GodMode folder

    I just found a way to create a settings folder in Windows 7. This God Mode folder can be created by:

    1) Create a new Folder
    2) Rename the folder to : GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
    

    Then the folder will change its icon and give you access to the settings for your computer in one place.

    0 Comments
  • Postgres: Create table if it doesn’t already exist

    I have a script that uploads a series of data into tables and occasionally I have an alternate table that is not part of my company template so I need to create the table at run time.  I do not want try to create the table if it exists already.  I also did not want to have to write a table check query and run that separately each time.

    I looked into creating a function to do this but I found that with the release of Postgres 9.1 there was an addition of the “if exists” or in my case, “if not exists” that allowed me to run one query that would only create the table if the table does not exist already.

    CREATE TABLE IF NOT EXISTS {schema}.{table_name}
    
    (
    
    sku character varying(100) not null,
    
    product_image character_varying(300) not null
    
    );
    
    
    0 Comments
  • Invalid JPEG when uploading to photo service

    I create cards in Adobe Illustrator or Photoshop on occasion and have had issues with getting my prints made at on-line or in-store photo services (such as Walgreens, Walmart or Target). I have received invalid JPEG errors.

    You will need to make sure that your color mode is set to RGB for your files and not CMYK.

    Ironically, even though most printers do better with CMYK, the RGB format is required for your JPEGS at these services.

    0 Comments
  • Hello world!

    Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

    0 Comments
  • Java: Split Strings

    I was using Java to add users to a system by parsing a comma seperated value (CSV) file of user entries and I needed to split the file to gather the separate entries. There is also the StringTokenizer class that can seperate the entries as well.

    So the following code snippet was used:

    String fileline;
    
    FileInputStream fis = new FileInputStream("filename.txt");
    DataInputStream dis = new DataInputStream(fis);
    BufferedReader br = new BufferedReader(new InputStreamReader(dis));
    
    while((fileline = br.readline()) != null) {
      String[] entries = fileline.split(",");
    
      for(int i=0;i < entries.length;i++)
      {
        System.out.println(entries[i]);
      }
    }
    
    0 Comments
  • Cron Job entry format

    If you ever need to schedule a job regularly on a Unix system, they have a great utility called cron. This will run a job at a regularly scheduled time.

    Here is the format:

    * * * * *  command to be executed
    _ _ _ _ _ 
    | | | | |
    | | | | +--- day of week (0 = Sunday - 6 = Saturday)
    | | | +----- month (1 - 12)
    | | +------- day of month (1-31)
    | +--------- hour(0-23)
    +----------- minute (0-59)
    

    example of a script that runs every day at 7:

    * 7 * * * sendmeupdate
    
    0 Comments
  • How to exit python script

    When I was trying to terminate a python script after a failure, I tried to find the nicest way to exit. The sys.exit() command provided by importing the sys library was what I found.

    The function can take an optional numeric argument, usually in the range of 0-127, and with no argument it returns 0. The return code is passed back to the Operating System.

    import sys
    sys.exit(1)
    

    When exit returns a non-zero value, it is considered an error.

    0 Comments
  • Mounting drives in Linux

    Sometimes you have a drive that your want to mount under Linux. The mount command can make the drive available to you. But you need to also create a directory to hold the mount point.

    mkdir /mnt/drivepoint
    

    Then you can mount the drive to that mount point by using the mount command and giving the device identifier, in this case it is /dev/sda1, and the mount point which we created as /mnt/drivepoint. One thing to note, is that the mount will use whatever directory you specify, so if there are files located in the directory you use as a mount point, they will no longer be visible.

    mount /dev/sda1 /mnt/drivepoint
    

    This must be run as root or with the sudo command.

    0 Comments
  • Using tar over ssh

    Every once in awhile, I need to backup a large directory from another computer. This can be done by creating a zip or tar of the files you are looking to save and then copying those zips to the other computer. But what it you have a very large directory and not enough room to store the extra file. Here is a way to use tar over ssh:

    ssh tar zcvf – /wwwdata | ssh root@backupserver.mydomain.com “cat > /backup/wwwdata.tar.gz”

    0 Comments
  • Setting timestamp with Touch

    Did you know? You can Set file timestamp using touch command. One way to do this is:
    touch -c -t YYMMDDhhmm filename.txt

    0 Comments