On Java, Python, Groovy, Grails, Spring, Node.js, Linux, Arduino, ARM, Embedded Devices & Web

Archive for the ‘Programming’ Category

contains information related to programming that’s not Java based but others. Since Java is my language at work with at this present time.

Quantum Computing Demands a Whole New Kind of Programmer

Posted by Venkatt Guhesan on May 10, 2017

Quantum computers finally seem to be coming of age with promises of “quantum supremacy” by the end of the year. But there’s a problem—very few people know how to work them. The bold claim of achieving “quantum supremacy” came on the back of Google unveiling a new quantum chip design. The hyperbolic phrase essentially means building a quantum device that can perform a calculation impossible for any conventional computer.

The technology has a major challenge to overcome. Programming these devices is much harder than programming conventional computers.

For a start, building algorithms for these machines requires a certain level of understanding about the quantum physics that gives qubits their special properties. While you don’t need an advanced physics degree to get your head around it, it is a big departure from traditional computer programming.

Source: Quantum Computing Demands a Whole New Kind of Programmer

Posted in General, In the News, Programming, Science and Technology | Tagged: , , | Leave a Comment »

A URL Shortener Service using Go, Iris and Bolt – Medium

Posted by Venkatt Guhesan on March 15, 2017

Go (cross-platform language/compiler)  
 + Iris  (web framework in Go)  + Bolt (embedded key-value DB) = one powerful combination 


Posted in GoLang, Programming | Tagged: , , | Leave a Comment »

Where API Management Is Headed in 2017 – DZone Integration

Posted by Venkatt Guhesan on March 13, 2017

In terms of API management in 2017, analysts are scrambling to catch up. Full lifecycle API management, security, and orchestration must be top considerations.

Source: Where API Management Is Headed in 2017 – DZone Integration

Posted in API | Tagged: , | Leave a Comment »

Your password is probably useless, says coding guru Jeff Atwood. Here’s why | ZDNet

Posted by Venkatt Guhesan on March 13, 2017

The best way to improve passwords is to think like the user and stop creating bad password-composition rules, Stack Overflow founder Jeff Atwood tells developers.

Source: Your password is probably useless, says coding guru Jeff Atwood. Here’s why | ZDNet

Posted in Security | Tagged: , , | Leave a Comment »

An insecure mess: How flawed JavaScript is turning web into a hacker’s playground | ZDNet

Posted by Venkatt Guhesan on March 13, 2017

Researchers say tens of thousands of sites are using JavaScript libraries that are years old and contain publicly known vulnerabilities.

An analysis of over 133,000 websites has found that 37 percent of them have at least one JavaScript library with a known vulnerability.

There are no reliable vulnerability databases, no security mailing lists maintained by library vendors, few or no details on security issues in release notes, and often, it is difficult to determine which versions of a library are affected by a specific reported vulnerability.

Source: An insecure mess: How flawed JavaScript is turning web into a hacker’s playground | ZDNet

Posted in Javascript, Security | Tagged: , , , , | Leave a Comment »

Developing email applications on Windows, targeted for Linux environment – email, mailx, sendmail

Posted by Venkatt Guhesan on December 11, 2016

linux_centos_logoIf you’re developing on a Windows platform for an application targeted for Linux or Unix that deals with email, then this article will be useful.

Let us begin by  understand the problem.


If you are a Java/Spring developer, (developing in Java is platform independent – runs on any platform where a JVM is available) then you have two options in front of you for sending emails from a Java application:

Option #1: JavaMail API

Option #2: Linux sendmail or mailx invoked via Runtime.getRuntime().exec(invoke – linux – mail – command) [example here]

If you are a PHP or Ruby or Bash or Python developer, you can do the same using a native library available within the language or invoke a native Linux execute-command to invoke either sendmail or mailx.

What happens if you are developing a hybrid library that needs to send email both from Java and Python. Then most likely you want to leverage a common library accessible to all the various libraries. In this case, you’re going to depend on either sendmail or mailx.   Now let us throw in a additional problem into this mix. Suppose you are developing on a Windows platform but the end application is targeted to run on Linux. This now creates a new additional problem. Sendmail or Mailx do not exist for Windows. Well, this article provides a way to develop on Windows by invoking execute mailx calls from your native code to the underlying emulation of Linux on Windows.

Now that we have established the problem, let us walk through a solution.

Please note that this is not the only solution but a potential solution. If you know of other mechanisms, feel free to send me a link and I’ll add them in.


Step-1: Make sure that you have Cygwin installed (with email tool selected additionally) on your Windows computer.

# Download  setup-x86_64.exe from
# and run it.

# When you run the setup, please additionally select "email" tool additionally. It is not added by default.

Once Cygwin is installed, most people traditionally use all the Cygwin tools from within a Cygwin Command-Prompt. The executables are located under “\bin\**” directory. Which means that if you run a “ls” in a DOS command-prompt, it will error saying “command not found”. There is a undocumented\not so known secret to emulating Linux commands natively in Windows. This is where your true Linux power comes in under native Windows.

Step-2: Add Cygwin\bin path natively to Windows PATH.

# In my computer, I have Cygwin installed at the following path: c:\cygwin64\

To add "c:\cygwin64\bin" the system path, perform these steps:

1. Start the System Control Panel applet (Start - Settings - Control Panel - System).
2. Select the Advanced tab.
3. Click the Environment Variables button.
4. Under System Variables, select Path, then click Edit.
5. Add c:\cygwin64\bin to the path.

Once Step-2 is completed. If you start a new DOS command-prompt and run a “ls” command, you should see the directory listing (same as a ‘dir’ command under Windows).

Step-3: The send email application uses “c:\cygwin64\etc\email\email.conf” for SMTP and other email properties.

# Edit c:\cygwin64\etc\email\email.conf and add your SMTP details (domain/server name, user-id, password)
# For this example, I have setup a *special* GMail Email account specially to test [Don't use your private GMail] so I will use the user-id and password for that Gmail account.

SMTP_PORT = '587'
USE_TLS = 'true'
MY_NAME  = 'Venkatt Guhesan'

Step-4: Let’s test this under a DOS command-prompt.

# Open a DOS Command-Prompt and run the following:

echo "Test from Cygwin in Windows under DOS command-prompt" | email -s "Testing Email from Windows DOS" 

# Within minutes, you should see an email in the Gmail inbox as expected.

# If you are not seeing it, then you can use the example below where you can pass in the SMTP arguments for validation. Maybe you typed in the password for the Gmail account incorrectly or you entered one of the parameters incorrectly in the c:\cygwin64\etc\email\email.conf file.

echo "Test from Cygwin in Windows under DOS command-prompt" | email -s "Tetsing Email" -r -p 587 -m login -u -i YOUR_GMAIL_PASSWORD_GOES_HERE -tls


Once you have confirmed a successful email then the next step is to create a mailx application.

Step-5: Create a mailx.exe (mailx) within Cygwin’s bin directory.

For emulating mailx from Cygwin’s email.exe, you’re in luck. The format for mailx is identical to the email.exe’s arguments. All you are missing is mailx.exe. So simply copy email.exe under Cygwin’s bin directory to mailx.exe under the same Cygwin’s bin directory. And you’re all set!

# simply copy email.exe under Cygwin's bin directory to mailx.exe under the same Cygwin's bin directory

cd c:\cygwin64\bin
cp email.exe mailx.exe

# Now just like you running email (without the .exe suffix) you can run mailx (without the .exe suffix)

Step-6: Test sending an email using mailx

echo "Test from Cygwin-mailx in Windows under DOS command-prompt" | mailx -s "Testing Email from Windows DOS" 


As a last step, now within your Java application, test Runtime.getRuntime().exec(“mailx command”);

Runtime.getRuntime().exec("echo 'Test from Cygwin-mailx in Windows under DOS command-prompt' | mailx -s 'Testing Email from Windows DOS'");

Now your Java application as well as any Python, Bash, Linux shell applications and/or scripts are now leveraging the common “mailx” and your development is now consistently the same using one common mailx library.


Today’s inspirational quote:
  • We must all either wear out or rust out, every one of us. My choice is to wear out.
– Theodore Roosevelt, an American statesman, author, explorer, soldier, naturalist, and reformer who served as the 26th President of the United States from 1901 to 1909.

Posted in Bash, CentOS 6.X, CentOS7, Grails, Groovy, Java, Linux, Spring, Windows | Tagged: , , , , , , | Leave a Comment »

Friday humor with languages

Posted by Venkatt Guhesan on September 30, 2016

I found this on the internet made me laugh!


Posted in Programming | Tagged: , , | Leave a Comment »

Python pycharm – configuring remote interpreters from Windows to Linux

Posted by Venkatt Guhesan on April 20, 2012

If you are an avid Python developer, you may all be excited about the new features available in the Pycharm 2.5 release, especially the remote interpreters, virtualenv and support. You can read more about the new exciting features here.

But as I started to tinker with the “remote interpreter” feature – I stumbled upon some challenges and I thought I’d document them for other PyCharm users who might benefit from this blog entry.

Let’s get right into the issue:

My Setup:

I have a Windows 7 host where I do most of my development. I develop software for a Linux based system and most of the Python libraries that I need to work from third-party vendors are only available for Linux. And so my PyCharm IDE runs on Windows and I have a VirtualBox instance of CentOS linux running within my host machine accessible via a Virtual Box – Bridged Adapter. This Linux could also be running in a separate  physical host accessible via TCP-IP. Now that we have a good idea about my development environment, let’s go over why I want to use the “remote interpreters” feature.

Remote Interpreters

This feature allows you to connect with a Python environment and all’s of it’s SITE_PACKAGES available on the remote machine as if you were running it locally on your native PC. Furthermore, you can perform step-through of your code right from your development platform as if you ran the IDE right within the Linux machine. (Please note that this feature can then lend itself to running the Linux server as a terminal without a GUI/Windows Manager like KDE/Gnome). This will simplify your footprint on the server side.


When you run the interpreter, you will run into issues such as “No such file or directory.” That’s because when you execute a file natively in Windows under c:\temp\ – the “remote interpreter” is now looking for a file under that same path in the remote server under Linux. To avoid this issue, here’s the solution I have engaged.

  1. Share my c:\projects\MyProject to myself so that I can map a new drive under Windows such as “K:\MyProjects”.
  2. Shared a “Machine Folder” to my Virtual machine. If you have a remote host, then either setup a GIT push scheme or a SFTP from your Windows to this remote server. See image below for illustration.
    Virtual Box - Machine Target
  3. At this time, My “c:\projects” folder is shared to the Linux environment as “/media/sf_K_DRIVE/” and “auto-mounted”. (I have also added my user-id to the “vboxsf” group because of permissions. But that’s another blog…)
  4. Now every modification of my Python files in my “K:\MyProject”, is exactly the same on the Linux virtual-box.
  5. The first setting to change is the “Line Seperator” (unless you want to execute Dos2Unix each time you run the file on Linux). This can be done under “Code Style” in PyCharm Settings. See image below:PyCharm Settings Line Seperator
  6. Next, configure the “Remote Python Interpreter”. See screenshot below:PyCharm - Configure Remote Interpreter
  7. In the previous step, when you choose a path on the Linux server for the “PyCharm helpers”, PyCharm pushes via SSH a set of libraries and software that helps with the remote debugging and scaffolding.
  8. The next step is to Run (or Debug) your code. See the screenshot below that shows the details of the “Run/Debug Configuration” screen. The important parts are “Working Directory” and “Path Mappings”. This is the trick that allows you to map your Windows Path to an equivalent Linux Path.PyCharm - Run/Debug Configuration Screen
  9. Now run (or debug) away your code as if it was running locally on your native Windows development platform.

That should get the job done.

Update on May 18th, 2012

#This shows you an example of how you would invoke a Python UnitTest via remote-interpreter to another script located in the same folder.

#Invoked from
scriptName = ""
# BASE_PATH is the absolute path of ../.. relative to this script location
BASE_PATH = reduce(lambda l,r: l + os.path.sep + r, os.path.dirname( os.path.realpath( __file__ ) ).split( os.path.sep ) )
#print BASE_PATH
# add ../../scripts (relative to the file (!) and not to the CWD)
NEWSCRIPTPATH = os.path.join( BASE_PATH, scriptName )

#Further down in code…
p1 = os.popen("%s" % self.NEWSCRIPTPATH, "w")

For early Pythons…

#If you are using Python 2.6.6 (not Python 2.7+)
scriptLocation = ""
scriptLocation = os.path.join( os.path.dirname( os.path.realpath( __file__ ) ), scriptLocation )
print scriptLocation

#Further down in code…
p1 = os.popen("%s" % self.NEWSCRIPTPATH, "w")

Posted in Programming, PyCharm, Python, Technology | Tagged: , , , , , , , , , , , , | 6 Comments »

How to extract public key from certificate?

Posted by Venkatt Guhesan on February 15, 2011

How to extract public key from certificate?

Recently I had to extract the public key from a certificate. Each time I do this I end up looking up the man pages for openssl and so I thought I’d blog it for myself and for others to use when needed.

$ openssl x509 -inform pem -in certificate.pem -pubkey -noout > publickey.pem


Posted in Programming, Uncategorized | 3 Comments »

Extract all images in PDF file in a directory (batch extract images)

Posted by Venkatt Guhesan on November 28, 2010

Sometimes you need a way to extract all images in a PDF but then you have a directory of files and you need to extract them iteratively.


1. Install Cygwin or linux environment with Perl support.

2. Install ImageMagick.

3. Install GhostScript.

Afterward run the following script:


my $directory = $ARGV[0];
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR))
if ($file =~ m/\.pdf/)
my $newfile = $file;
$newfile =~ s/\.pdf/_%01d\.jpg/;
print "Processing " . $file . " ; newfilename: " . $newfile . "...\n";
`convert -density 150 $file $newfile`;

How to invoke:
scriptname path_to_pdf_files


Posted in Programming | Tagged: , , | Leave a Comment »