Sunday 22 December 2019

Philosophizing

Work calls. And I shall have to finish my tasks. For what we do in modernity, echoes in eternity.

Friday 20 December 2019

Quickly Find Out Blank Cells within a Column

The headline is misleading or is incomplete at best. I agree. You will, too, after you have gone through this post. As bland as it may seem at first, you might find this a tad interesting for the application it was designed and intended to perform. 

Microsoft Excel VBA macro programming is a powerful way to experience how data can be manipulated and viewed.

I was given this assignment to find out number of blank cells between two non-blank cells within a range in a spreadsheet. For example, if A1 was a non-blank cell and A4 was the same, too, then B1 should have a display of 2 to indicate that there are two cells that are blank in between. 

Following is the full extract of the macro that I wrote to accomplish the task at hand. In case you need help, please do not hesitate to reach out to me.


Function CheckBlanks(CheckRange As Range)
'Created: Satadru Sengupta.
'Dated: 18-12-2019
    Evaluate "CheckBlanksSub(" & CheckRange.Address(False, False) & ")"
    CheckBlanks = "Difference of blanks created"
    MsgBox ("Range difference created. You may delete the formula / user-defined function used.")
End Function
Private Sub CheckBlanksSub(CheckRange As Range)

        Dim getRowNum As Integer
        Dim getColNum As Integer
        
        Dim initiatePointRow As Integer
        Dim endPointRow As Integer
        Dim differenceRows As Integer
        
        getRowNum = CheckRange.Row
        getColNum = CheckRange.Column


         initiatePointRow = 1
         differenceRows = 0
        
         initiatePointRow = getRowNum
         endPointRow = initiatePointRow
         
         For row1 = 2 To CheckRange.Columns(1).Cells.Count
         
         If CheckRange.Cells(row1, 1).Value = "" Then
            differenceRows = differenceRows + 1
         Else
            ActiveSheet.Cells(endPointRow, getColNum + 1).Value = differenceRows
            endPointRow = getRowNum + row1 - 1
           
            differenceRows = 0
         End If
         
    
         Next
            
     
End Sub

Monday 16 December 2019

Pithy Saying

At some future period, not very distant as measured by centuries, the civilized races of man will almost certainly exterminate and replace the savage races throughout the world.

Charles Darwin

Friday 13 December 2019

Secularism and Citizenship

It is a sad state to see that we are quickly going the way of losing our secular identity. Fundamentalists and extremists seem to be rampant on either religious denominations. I pray to the Almighty the Omniscient the Munificent that may peace and harmony prevail forever in the land that gave birth to Netaji Subhash Chandra Bose, the Mahatma, our national pride and the Late President Abul Pakir Jainalubdin Abdul Kalam, Mohammed Rafi Ahmed Kidwai, and many more who shall forever remain etched in the fabric of our nation's great history and proud heritage.

My heart grows sad for no one should feel alienated or segregated. Ghettoisation is neither wanted nor should be tolerated. Jingoism and playing to the crowd are what our nation does not ever require. What our country needs is to eradicate corruption, sectarian violence, ensure that its citizens are protected at night and in remote corners of the country at all times. Our country needs our children to grow strong, healthy and prosperous. Religion is what we turn to to keep our society from plunging into depravity and moral turpitude. Religion is not and should never be a rod to stir up issues for the sake of political mileage and economic benefit for a select few.

It is said that quotes by the Mahatma are the most frequently quoted ones on the Internet. What, therefore, could be better than using one made famous by his views on Truth and Nonviolence - "It is easy enough to be friendly to one's friends. But to befriend the one who regards himself as your enemy is the quintessence of true religion. The other is mere business."


Tuesday 29 October 2019

Java String Encryption




Think of password encryption in Java programming and the word “BCrypt” springs to mind. There are such several excellent articles and tutorials written on the subject, that one need only examine those at leisure to incorporate the techniques illustrated with ease. I find that the resources available here and here ought to be worth the time for anyone keen on understanding how password encryption can be used and programmed in Java language.

However, it was not until when I came upon this did I really began to appreciate the value of digging deeper into the world of password encryption algorithms and techniques in Java. Interestingly, a comment that appears here set me off on a search to Argon2 password hashing

I came upon this excellent resource which uses Jargon2 - an API to assist in implementation of Argon2 password hashing in Java. 

To test whether I was on the right track to use this library, I followed the instructions. The salient features were the inclusion of the following in pom.xml of Java project that I created anew in Eclipse IDE. Before adding the following section to the pom.xml, I converted the Java Project to a Maven Project.


<dependency>
    <groupId>com.kosprov.jargon2</groupId>
    <artifactId>jargon2-api</artifactId>
    <version>1.1.1</version>
</dependency>
<dependency>
    <groupId>com.kosprov.jargon2</groupId>
    <artifactId>jargon2-native-ri-backend</artifactId>
    <version>1.1.1</version>
    <scope>runtime</scope>
</dependency>

The actual code was straightforward copy of the simple example provided and is reproduced below:


import static com.kosprov.jargon2.api.Jargon2.*;

public class Jargon2EncodedHashExample {
    public static void main(String[] args) {
        byte[] password = "this is a password".getBytes();

        // Configure the hasher
        Hasher hasher = jargon2Hasher()
                .type(Type.ARGON2d) // Data-dependent hashing
                .memoryCost(65536)  // 64MB memory cost
                .timeCost(3)        // 3 passes through memory
                .parallelism(4)     // use 4 lanes and 4 threads
                .saltLength(16)     // 16 random bytes salt
                .hashLength(16);    // 16 bytes output hash

        // Set the password and calculate the encoded hash
        String encodedHash = hasher.password(password).encodedHash();

        System.out.printf("Hash: %s%n", encodedHash);

        // Just get a hold on the verifier. No special configuration needed
        Verifier verifier = jargon2Verifier();

        // Set the encoded hash, the password and verify
        boolean matches = verifier.hash(encodedHash).password(password).verifyEncoded();

        System.out.printf("Matches: %s%n", matches);
    }
}


To make this program run on a standalone basis with all dependencies bundled into it, all I did was to add the following fragment to the pom.xml:



<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.test.argon2.Jargon2EncodedHashExample</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>



Again, the above was copy from an excellent resource to be found here.


The author presents lucid examples on how to use the Jargon2 library. For anyone keen on extending password encryption to another level, this should be an interesting find.



Thursday 3 October 2019

Dabbling in Plain Text

I am a writer; or at least I pretend to be one. But for all my efforts at writing, the most that I do is reading. Some say, that you need to be an avid reader to come even remotely close to being a writer. That said, writing is not a 9 to 5 business routine that needs to be respected and bowed to at every turn. Far from it. Writing is a feeling that overwhelms you and begs you to take to your smartphone, laptop, PC, tablets, or even to few blank sheets and pencil at odd hours.

Being a person with interest in history and computers, I thought of shoehorning those sources of stimuli into earning my livelihood. Thus far, that task has been onerous at best; and a source of frustration and of many arguments with friends and family at worst. Notwithstanding my struggles, a fate that many aspiring writers probably share as well, writing is a channel that acts as an opiod analgesic. 

Writing, if you like, can be both a release and a profession. It demands interest and a soul to begin with. It also requires a distraction-free environment for the most part.

Think of a normal daily routine. You could be in a public transport riding choc-a-bloc with fellow travellers steaming inside a packed compartment with little room for your own elbow. Or you could be in your own personal transport immersed in your thoughts trying to negotiate rush hour traffic. Whatever be the environment you may find yourself in, it does not take much for any interesting thought to kick in. 

At this point, the urge is to jot down one's thoughts as quickly and as effortlessly as possible. And the tools to do so? Certainly not a piece of pen and paper, for you would be hard-pressed to hold those implements rock steady while on the move. Your best bet would then be the smartphone residing in your pocket. Or an iPad if you are seated, with the steering of the vehicle you are in controlled by someone not hit with the same impulse as yours at that precise moment.

It is at this juncture when you begin to tap in the words you begin to realize the value of screen space. Word processors do not offer distraction-free writing space. On the contrary, menu icons and title bars hog a noticeable portion of the space. Formatting woes fill in your senses while you write. All very acutely distracting.

What you need is simple plain interface with minimalistic approach in terms of visibility, but at the same time loaded on features. Enter the Markdown syntax and iA Writer for Android and iOS.

The iA Writer is offered for Android, iPad, iPhone, Mac and Windows platforms as on date. Thoughtfully crafted, the simplicity of the software makes it attractive for writers who are light-fingered and need thoughts to be inscribed in black and white as quickly as humanly possible. 

And yet with its Markdown syntax support, it is as feature-rich as most writers would like without the often unused options that are offered by word processing apps.

Priced at  699.00, the iPad version is competitively priced compared to competing cloud models offered by similar apps. The Android version is free. 

While the iA Writer (Android) allows opening and saving of files on Dropbox and on Google Gloud, the iPad version considerably extends the range to include iCloud and OneDrive.  

What all this means is that you and I no longer have to fret over maintaining more than one cloud account if we can help it. Many rely on either Dropbox or OneDrive for storing their documents online. And indeed this does make sense in an age where devices are swapped and can be exchanged or sold within a couple of years or less. 

With the feature that the iA Writer for iPad now offers, connecting to OneDrive can be a lot easier than ever before.

For writers who are on the move, or who need less of distraction at every possible turn, the combination of iA Writer’s text support with cloud storage accessibility and support for prominent brands does look promising.

In case you would like to leave comments or feedback, please feel free to do so by sending an email. I am almost always constantly available and do respond as quickly as possible.

Let me know your questions, if any, that you would like me to help you out with.







Resetting password of Amazon Kindle Paperwhite (7th Generation)

What to do to in case one forgets the password of an Amazon Kindle Paperwhite (7th Generation)? The answer is to type in  111222777  and...