Monday, November 2, 2015

How do you run Salesforce queries in Perl?

use WWW::Salesforce;

my $username = '<UserName>';
my $password = '<Password>';
my $security    = '<Token>';
my $stoken      = "$password$security";

# Authenticate with the Salesforce API
my $sforce = eval { WWW::Salesforce->login (
                    username => $username,
                    password => $stoken );
                  };
die "Could not login to Salesforce: $@" if $@;

my $query = "SELECT Id, Name, Email, AccountId FROM Contact";
my $res = $sforce->do_query( $query );

open(FH, '>:encoding(UTF-8)', "SF_Report.csv")
  or die "Could not open file: \"SF_Report.csv\"";

foreach my $field (@$res) {
    print FH "$field->{'Name'},$field->{'Email'},$field->{'AccountId'}\n";
}

Monday, October 19, 2015

How do you run PostgreSQL query on Command Prompt?

@echo off
set REPORTNAME=%1
set timestamp=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set PGPASSWORD=<password>
"C:\Program Files (x86)\pgAdmin III\1.16\psql" -A -h %REPORTNAME% -U <UserName> -d <DatabaseName> -F , --pset footer -c "<Query>" -o "%REPORTNAME%_%timestamp%.csv"

Friday, September 11, 2015

How do you create a God Mode folder on Windows?

"God Mode" is a hidden feature of Windows that gives you access to every option in Control Panel on one screen. This is useful, especially for power users, since navigating the traditional Control Panel is tedious. The added advantage of this option can be further exploited to hide data in disguise.

Follow these steps to access God Mode on Windows 7/ 8/10 :

1. Create a new folder or use any existing folder wherever you want the would-be GodMode folder. Right-click in Windows Explorer, select New, then click Folder.

2. Open Command Prompt and traverse directory using CD command.

3. Next, rename the folder by executing the command below :

ren <Folder Name> <Folder Name>.{ED7BA470-8E54-465E-825C-99712043E01C}

e.g., ren robie robie.{ED7BA470-8E54-465E-825C-99712043E01C}

For Windows 9x :
  • Follow steps 1 & 2.
  • Next execute command
          ren <Folder Name> <Folder Name>.{21EC2020-3AEA-1069-A2DD-08002B30309D}

To restore the orginal folder, run the command below :
         ren <Folder Name>.{21EC2020-3AEA-1069-A2DD-08002B30309D} <Folder Name>

Thursday, June 11, 2015

How do you set current timestamp to field of HL7 result in Mirth?

var ctimestamp = DateUtil.getCurrentDate('yyyyMMddhhmmss');

msg['MSH']['MSH.7']['MSH.7.1'] = ctimestamp;
msg['MSH']['MSH.10']['MSH.10.1'] = ctimestamp;

Formatting options :
- yyyy year (four-digit)
- M, MM month, month with leading 0
- d, dd day, day with leading 0
- HH hour, 24-hour-format
- hh hour, 12-hour-format
- mm minutes
- ss seconds
- SSS milliseconds
- ww week in year

What are the driver URLs for database reader in Mirth?

jdbc:postgresql://localhost:5432/dbname
jdbc:mysql://localhost:3306/dbname
jdbc:jtds:sqlserver://localhost:1433/dbname
jdbc:Cache://localhost:1972/NAMESPACE"

('mirthdb' is default dbname and localhost is '127.0.0.1')

How do you hide the DOS console while GUI running?

my $hwnd = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($hwnd);

Sunday, February 15, 2015

How do you set name of logfile to that of script basename?

use Time::Piece;

# Get the base name of the script
( my $me = $0 ) =~ s{.*(\\|/)}{};

my $today = localtime->strftime('%d%m%Y');

#Set name of log file to that of script name
(my $logfile = $me ) =~ s/\.pl/\_$today\.log/ig;

Tuesday, January 27, 2015

How do we fix "Could not locate a PPD (Perl package descriptor) file for a package" on Windows?

Usually Activatestate perl tries to refer the default repository http://code.activestate.com/ppm/ and download the relevant files for a package to be installed.

When it does not get the specified one, it throws exception. To overcome such a situation, redirect PPM to access a different repository easily available over internet.

For example, to install package XML-LibXML from a different repository, run the following command on console :

ppm install repository/XML-LibXML.ppd

For instance,

ppm install http://www.bribes.org/perl/ppm/XML-LibXML.ppd