Sunday, July 26, 2020

Backup(Transferring and Synchronizing files) using python multiprocessing and rsync !

rsync(remote sync) is a utility for efficiently transferring and synchronizing files between a computer and an external storage

  1. Copy or sync files locally:

  2. rsync -zvh [Source-Files-Dir] [Destination]

  3. Copy or sync directory locally:

  4. rsync -zavh [Source-Files-Dir] [Destination]

  5. Copy files and directories recursively locally:

  6. rsync -zrvh [Source-Files-Dir] [Destination]  

  7. Sample  python code  script to do a backup using python...


  8. #!/usr/bin/env python

    import subprocess

    from multiprocessing import Pool


    from os import walk 


    src= "/home/user/data/"

    dest="/home/user/data/backup/"

    def backupData(dir):

        print("dir = "+ src+dir +" dest = " + dest+dir)

        subprocess.call(["rsync", "-arq", src+dir, dest+dir]) 


    dirList = []

    for (root, dirs, files) in walk(src):

        dirList.extend(dirs)

        break;

    print (dirList)

    p= Pool(len(dirList))

    p.map(backupData, dirList)


Read More...

Saturday, June 6, 2020

Cucumber/Gherkins with Java(kotlin) !

Cucumber is an opensource, Behavior-Driven Development (BDD) framework, where you execute your automated tests. You can pick up a regression suites for your automation test. We will mostly discuss about the the automation test written in Java/Kotlin in this tutorials.
Cucumber reads executable specifications written in plain text and validates that the software does what those specifications say.

What is Gherkins:
Gherkins is a business readable domain specific language. It is a set of grammar rules that makes plain text structured enough for Cucumber to understand.
Example :  Users are presented with Invalid Username/Password method when authentication fails
Scenarios: 
Cucumber uses Scenarios to defines the steps . You describe the Scenarios using Given, When, And and Then, But 
Example: 
Scenario: Users are presented with Invalid Username/Password method when authentication fails
Given User is in the login page
when User fills the invalid username or password
And User hit the submit button
Then User see the pop up screen saying Invalid Username/Password
When we define the  Scenario, we  can define multiple pre condition and multiple action and multiple expected outcomes.

We can collapse these two or more similar scenarios into a Scenario Outline as following
Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |    12 |   5 |    7 |
    |    20 |   5 |   15 |
(src: cucumber.io)
What is Feature and Feature File:
Feature can be defined as a standalone business functionality of a project. Feature file describes the testing needs for any features. A features file can contains one or many scenarios for you automated testings.In order the automatically detect the features by cucumber framework, you need to define it with .feature file extension. You will normally have a desperate feature file for each feature. 
(This post is still in progress--- keep visit us again)
    

Read More...

Tuesday, June 2, 2020

Updating the hosts file in MAC

echo '172.16.144.128 hdp hdp' | sudo tee -a /private/etc/hosts


Read More...

Saturday, May 16, 2020

Bash script to rename or move files from a directory !

Following is the bash script that renames a sets of file form the current directoy. In the following is just updating the extension.

#/bin/bash

for file in *.JPEG; do

        name=$(basename "$file" .JPEG)

        mv "$file" "$name.jpeg"

done




Read More...

Monday, April 20, 2020

Git - more on Git Tags -




The following steps outlines the Git Tag delete process both locally and remotely.
  1.  Fetch all the tags from
    git fetch --tags
  2. Delete the tag locally
    git tag -d yourTagToDelete  (eg: git tag -d v1.15.0)
  3. Delete the tag in Remote
    git push origin :yourTagToDelete (eg git push origin :v1.15.0)
  4. Create a new  tag locally
    git tag yourNewTag  (eg: git tag v1.15.0)
  5. Push tag to Remote
    git push origin yourTagToDelete (eg git push origin v1.15.0)

Read More...

Saturday, April 18, 2020

Restarting Spring Boot Application !

Restarting Spring Boot Application  !

You have several options to restart Spring boot Application . You can restart either of the following three options. Based on your requirement you can choose one of the following.

  1. Using spring-boot-devtools
  2.            Add your Gradle dependency
        dependencies{ 
                    compileOnly("org.springframework.boot:spring-boot-devtools")
      }
        After that Add, you can simply add an end poing on your controller class and have the following:
              org.springframework.boot.devtools.restart.Restarter.getInstance().restart();   

    The drawback of using tools is you cannot make a good used of @Cacheable . it might cause ClassCastException while reading from the cache.

  3. Using RestartEndPoint from 
  4.    Add your Gradle dependency
      dependencies{ 
         compile "org.springframework.boot:spring-boot-starter-actuator"
      }
        After that Add, you can simply add an end on your controller class and have the following:
         @Autowired
         RestartEndpoint restartEndpoint;
         
        And call the following methond from your controller :
        restartEndpoint.restart() 
         
    You might see NullPointer Exception while trying to bring the application up specially when you have UnderTow as your servlet container 
     3.   And the third one is reading the current context and restarting it. You can simply add the following method on the Main Class and invoke from your controller
       public static void restart() {
          ApplicationArguments args = appContext.getBean(ApplicationArguments.class);
          Thread thread = new Thread(() -> {
          appContext.close();
          SpringApplication springApplication = new SpringApplication(MyBootApplication.class);
          springApplication.addListeners(new ApplicationPidFileWriter());
          appContext =springApplication.run(args.getSourceArgs());
        });
       thread.setDaemon(false);
       thread.start();
      }

Read More...

Saturday, March 21, 2020

Thread Dumping in Unix - flyway recorder !

 jcmd 8308 JFR.start duration=100s filename=tempo.jfr

Read More...

Thursday, March 5, 2020

Monogo Pipeline scripts !

1. Filter by an assistance of an array element in a document:
  $and:[{assessmentPeriods:{$ne:null, $exists:true, $ne: []}}  ]

2. 


Read More...

Friday, April 5, 2019

Java 11 and Groovy Compatibility and JAXBContext !


If you see the following error during compile : 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestGroovy'.
> org/codehaus/groovy/ast/MethodCallTransformation


Add the folling line to your gradle file :

ext['groovy.version'] = '2.5.6'  //i.e your grovy version.


Another issues with java 11

 Unable to load class groovy.xml.jaxb.Jaxb GroovyMethods due to missing dependency javax/xml/bind/JAXBContext 

You can fix this by adding the following dependency on the latest groovy version


Read More...

Wednesday, February 6, 2019

Useful Unix Commands

1. Count number of lines on all the files in the current folder
wc -l *

2. Count the number of files on the current directory :
ls | wc -l
3. Print all the line containing word/s in a file
grep -iw "search words" arc.log
4. Thread dumping for a process
 jcmd 8308 JFR.start duration=100s filename=tempo.jfr

Read More...

Wednesday, December 19, 2018

Simple hack to Update System Properties and Environment variables on Window !

If you don't have a permission to edit the System variable on your local window machine, the following hack might work

Click Window and  type "SystemPropertiesAdvanced"  on Search programs and file search text option. Then, once you see the 
SystemPropertiesAdvanced shortcut, right click it and open it as an administrator.  You might be able to edit it now.




Read More...

Friday, April 13, 2018

MySql Query to turn ON Query statistics I/O

SET STATISTICS IO ON
SET STATISTICS TIME ON
SELECT er.ReportID, er.ReportName, er.ReportNumber
FROM dbo.EmployeeReports er
WHERE er.ReportNumber LIKE '%33%'
SET STATISTICS IO OFF
SET STATISTICS TIME OFF

Read More...

MySQL Nested Case SQL statements (CASE WHEN OR THEN ELSE END )

Following is an example of nested MySQL Case When or then else End statement.
select
  CASE
  When (table.field1 = '01')
    THEN
      CASE
      When (SUBSTRING_INDEX(table.field1, ' ', 1) = 'abc')
         THEN '01abc'
         ELSE 'abc'
      END
  WHEN (table.field1 = '02')
    THEN
      CASE
      When ((SUBSTRING_INDEX(table.field1, ' ', 1)) = 'def')
        THEN '02def'
        ELSE 'def'
      END
  When (table.field1 = '03')
    THEN
      CASE
      When ((SUBSTRING_INDEX(table.field1, ' ', 1)) = 'efg')
        THEN '03efg'
      ELSE 'efg'
      END
  WHEN (table.field1 = '04')
    THEN
      CASE
      When ((SUBSTRING_INDEX(table.field1, ' ', 1)) = 'pqr')
        THEN '04pqr'
      ELSE 'pqr'
      END
  END
from table ;

Read More...

Tuesday, December 19, 2017

Is this the beginning of the end of BitCoin, Etherum and LiteCoin ? Did it really crashed today evening ??

The BitCoin was traded at $14,212 at 6:40 PM CST, December 19 2017. The price is almost 27% less than its highest value. At the time of the post of this blog, the BitCoin is now backed up to $17,149 

The Etherum was traded at $705 at 6:40 PM CST, December 19 2017. The price is almost 17% less than its highest value. At the time of the post of this blog, the Etherum is now backed up to $772 The

LiteCoin was traded at $277 at 6:40 PM CST, December 19 2017. The price is almost 37% less than its highest value of $371. At the time of the post of this blog, the LiteCoin is now backed up to $320 

Where as the Bitcoin Cash is enjoying a ride of $3100 per bitcoin cash which is almost 41% higher than its yesterday's price.

Read More...

Wednesday, August 30, 2017

Fix for xcrun: error: invalid active developer path after updating your mac OS to Sierra

If you are geting the following error with Git or any other tools while running it on from your terminal
 xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun. 

 using the following command to fix it
xcode-select --install

Read More...

Pages

 ©mytechtoday.com 2006-2010

 ©Mytechtoday

TOP