Posts

Showing posts from 2017

Fix error "Invalid data set: 0" in Perl module GD::Graph

Image
Error Message: Invalid data set: 0 at D:\New\TOOL\graph.pl line 24. Problem Code: my @a1 ; my @a2 = [-9,8,0,1,-2,-5,6,-4,3,7]; foreach my $i (1..10) {     push @a1 , $i; } my @data = (     @a1 ,     @a2 ); Solution: my @a1 ; my @a2 = [-9,8,0,1,-2,-5,6,-4,3,7]; foreach my $i (1..10) {     push @a1 , $i; } my @data = (     [@a1],     @a2 );

Fix error "Not a valid source data structure" in Perl module GD::Graph

Image
Error Message: Not a valid source data structure at D:\New\TOOL\graph.pl line 24. Problem Code: my $gd = $graph->plot( @data ) or die $graph->error; Solution: my $gd = $graph->plot( \@data ) or die $graph->error; Complete working code: #!/usr/bin/env perl use strict; use warnings; use GD::Graph; use GD::Graph::bars;

Windows 10 Fall Creators Update and Microsoft Launcher (Preview)

Image
Fall Creators Update is the latest version of the Windows 10 Operating System by Microsoft. It is now available as beta release. To get this update you need to register your Windows 10 account as an Windows Insider. To join the program go to: https://insider.windows.com/en-us/ Windows 10 PC Version History: Version Code Name Marketing Name 1507 Threshold 1 1511 Threshold 2 November Update 1607 Redstone 1 Anniversary Update 1703 Redstone 2 Creators Update 1709 Redstone 3 Fall Creators Update Windows 10 version 1507, codenamed "Threshold 1", is the first release of Windows 10. It carries the build number 10.0.10240; while Microsoft has stated that there was no designated release to manufacturing (RTM) build of Windows 10, 10240 has been described as an RTM build by various media outlets. Windows 10 Fall Creators Update, or Windows 10 version 1709, codenamed "Redstone 3"...

Monoalphabetic Substitution Cipher in Python

Image
import random plain_text = "devharsh_T @ $01.2" cipher_text = '' decipher_text = '' alphabets = [chr(a) for a in range(0,127)] mappings = [chr(a) for a in range(0,127)] random.shuffle(mappings) print(alphabets) print(mappings) for i in range(len(plain_text)):   for j in range(127):     if(plain_text[i] == alphabets[j]):       cipher_text += mappings[j]   print(plain_text) print(cipher_text) for i in range(len(cipher_text)):   for j in range(127):     if(cipher_text[i] == mappings[j]):       decipher_text += alphabets[j]       print(decipher_text) This Python version of a monoalphabetic substitution cipher shuffles the character set to build a random mapping, then substitutes each character of the message over a wide character range. It is useful for learning, but like all simple substitution ciphers it preserves character frequencies and is broken easily by anal...

Monoalphabetic Substitution Cipher in C++

Image
#include <iostream> #include <string> #include <ctime> #include <chrono> #include <thread> int main() {   char plain[100] = "devharsh";   char cipher[100];     char alphabets[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};   char mappings[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};     alphabets[26] = '\0';   mappings[26] = '\0';     std::cout << alphabets << "\n"; ...

Mozilla Firefox Quantum 57+ Legacy Extensions And Alternatives

Image
If you are a Firefox fan than you must have experienced periodical out-dating and temporary unavailability of your favorite extension every time you update your browser. Same thing is going on with the upcoming release of Firefox which is Firefox 57. It will release from November 2017 but if you are on beta channel you can upgrade to it now, from October 2017. If you have upgraded you will notice many extensions are not compatible and since disabled by-default and there is no option available to enable them. These extensions are listed as "Legacy Extensions" which used to be listed as incompatible extensions in previous versions. From Firefox Official Blog: In the past, extensions often stopped working each time a new version of Firefox was released, because developers had to update them every six weeks to keep them compatible. Since extensions could also modify Firefox internal code directly, it was possible for bad actors to include malicious code in an innoce...

Java Standard Edition 9 Features And Download Links

Image
Java Development Kit (JDK) 9 Download Link: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html Java SE 9 At JavaOne 2011, Oracle discussed features they hoped to release for Java 9 in 2016. Java 9 should include better support for multi-gigabyte heaps, better native code integration, a different default garbage collector (G1, for "shorter response times") and a self-tuning JVM. In early 2016, the release of Java 9 was rescheduled for March 2017, later again postponed four more months to July 2017, and changed again to be finally available on September 21, 2017, due to controversial acceptance of the current implementation of Project Jigsaw by Java Executive Committee, which led Oracle to fix some open issues and concerns, and to refine some critical technical questions. Source: https://en.wikipedia.org/wiki/Java_version_history End of Public Updates for Oracle JDK 8 Oracle will not post further updates of Java S...

Extract Audio from Video with FFmpeg and Format Factory

Image
FFmpeg: FFmpeg is a free software project that produces libraries and programs for handling multimedia data. Download link: https://ffmpeg.org/download.html Format Factory: FormatFactory is an ad-supported freeware multimedia converter that can convert video, audio, and picture files. It is also capable of ripping DVDs and CDs to other file formats, as well as creating .iso images. It can also join multiple video files together into one. Download link: http://www.pcfreetime.com/formatfactory/feature.php?language=en How to extract audio from video using FFmpeg: If you just want to copy the audio stream without re-encoding just do: ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac -vn is no video. -acodec copy says use the same audio stream that's already in there. Read the output to see what codec it is, to set the right filename extension.

Getting started with SQLite database in Perl

Image
SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the world with more applications than we can count, including several high-profile projects. [ https://www.sqlite.org/about.html ] Following program demonstrates how to Create a new SQLite database, how to connect to a database with credentials, how to create a table, how to insert values and how to select values. #!/usr/bin/perl use DBI; use strict; use warnings; my $dsn = "DBI:SQLite:test.db"; my $userid = ""; my $password = ""; my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1, AutoCommit => 0})    or die $DBI::errstr; print "Opened database successfully\n";

Plot colored node graph with networkx in Python

Image
Networkx: NetworkX is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. URL: https://networkx.github.io/ Code: import networkx as nx import matplotlib.pyplot as plt G=nx.Graph() color_map = ['blue','green','red'] G.add_nodes_from([1,10]) G.add_edge(1,2) G.add_edge(1,3) G.add_edge(4,3) G.add_edge(5,3) G.add_edge(6,8) G.add_edge(7,9) G.add_edge(8,7) G.add_edge(9,6) G.add_edge(10,5) G.add_edge(1,4) nx.draw(G,node_color = color_map,with_labels = True) plt.show() Output: This example draws a colored node graph in Python with NetworkX and Matplotlib. NetworkX builds and analyzes graphs, and a color map assigns a color to each node before drawing. Visualizing a graph helps you see structure such as clusters and hubs. NetworkX also offers many algorithms for paths, centrality, and connectivity on the same graph object.

Create HTML dashboard of Jenkins jobs status

Image
Perl script to fetch live jobs' status from Jenkins server and generate and display HTML dashboard from it. use strict; use warnings; use autodie; use REST::Client; use MIME::Base64; use JSON; my $api_proto = 'http';               #HTTP/HTTPS my $api_url = 'localhost';       #Server IP my $api_port = '8080';                #Port number my $api_user = 'admin';           #Jenkins account username my $api_pass = 'password';          #Jenkins account password my $client = REST::Client->new();    #Perl Rest Client Object $client->addHeader('Authorization', 'Basic '.encode_base64($api_user . ':' . $api_pass)); $client->GET($api_proto.'://'.$api_url.':'.$api_port.'/api/json?tree=jobs[name,color,url]'); my $html = ""; $html = $ht...

Parse DICOM Image in Python | Convert DICOM to PNG in Python

Image
DICOM: Digital Imaging and Communications in Medicine (DICOM) is a standard for storing and transmitting medical images. It includes a file format definition and a network communications protocol. PNG: PNG (pronounced ping as in ping-pong; for Portable Network Graphics) is a file format for image compression that, in time, is expected to replace the Graphics Interchange Format (GIF) that is widely used on today's Internet. Portable Network Graphics (PNG /ˈpɪŋ/) is a raster graphics file format that supports lossless data compression. PNG was created as an improved, non-patented replacement for Graphics Interchange Format (GIF), and is the most widely used lossless image compression format on the Internet. Prerequisites: You need to install following python packages: pydicom, pylab, pypng To install these modules you can type following commands in console: pip install pydicom pip install pylab pip install pypng

Build Jenkins Job Remotely | Fix: Error 403 No valid crumb was included in the request

Image
In case you are a newbie with Jenkins read through this article: http://com.puter.tips/2017/09/getting-up-and-running-with-jenkins.html Build Jenkins Job Remotely I have found two ways in which you can trigger a build on job remotely via scripting. Both methods are simple HTTP Get/Post requests, nothing fancy here. Along with these Requests we need to pass login credentials. Method 0: No protection enabled => This is the case when you are in a secure environment and have disabled all additional protection mechanism like CSRF (Method 1) and Authentication Token (Method 2). If this is the case then you can simply trigger a HTTP Request like this: 'http://username:password@jenkins_url:port/job/job_name/build' e.g. http://admin:pass@localhost:8080/job/job1/build

Jenkins: Trigger build remotely via script using Authentication Token

Image
Powershell: $acctname = "admin" $password = "password" $server = "localhost" $port = "8080" $jobName = "test02" $jobToken = "test02_authentication_token" $params = @{uri = "http://${server}:${port}/job/${jobName}/build?token=${jobToken}";             Method = 'Get';             Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$(${acctname}):$(${password})"));}} Invoke-RestMethod @params

Jenkins: Trigger build remotely via script using crumb

Image
Python: import requests api_proto = 'http' api_url = 'localhost' api_port = '8080' api_job = 'test01' api_user = 'admin' api_pass = 'password' api_crumb = requests.get(api_proto + '://' + api_user + ':' + api_pass + '@' + api_url + ':' + api_port + '/crumbIssuer/api/json') if api_crumb.status_code == 200 :     api_crumb = api_crumb.json()['crumb'] resp = requests.post(api_proto + '://' + api_url + ':' + api_port + '/job/' + api_job + '/build', auth=(api_user, api_pass), headers={"Jenkins-Crumb":api_crumb}) if resp.status_code == 201:     print(api_job + ' was triggered successfuly..')

"No connection adapters were found for '%s'" % url [Solved]

Image
Error: Traceback (most recent call last):   File "C:\Users\310211146\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\api.py", line 110, in post     return request('post', url, data=data, json=json, **kwargs)   File "C:\Users\310211146\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\api.py", line 56, in request     return session.request(method=method, url=url, **kwargs)   File "C:\Users\310211146\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 475, in request     resp = self.send(prep, **send_kwargs)   File "C:\Users\310211146\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 590, in send     adapter = self.get_adapter(url=request.url)   File "C:\Users\310211146\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\sessions.py", line 672, in get_adapter     raise InvalidSchema(...

Getting up and running with Jenkins 2.60.3 on Windows [How to solve Error: no workspace]

Image
Jenkins: The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project. Jenkins is a Continuous Integration server. Basically Continuous Integration is the practice of running your tests on a non-developer machine automatically every-time someone pushes new code into the source repository. Prerequisites: Java Development Kit (JDK) Java Run-time Environment (JRE) To install JDK go to http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html To install JRE go to http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

Count number of items and sum of the items in a column in R

Image
Code: mydf <- data.frame(Key=c('a','b','c','d','a','a','a','a','b','c','d','c','c','d','b','b','a'), Values=c(4,6,3,4,5,6,2,1,3,4,5,6,4,2,4,5,6))                 mydf_keys <- unique(mydf$Key) mydf_vals <- c(nrow(mydf_keys)) for (i in mydf_keys) {     mydf_vals <- c(mydf_vals, nrow(mydf[mydf$Key %in% i, ])) } #mydf_count gives count of items i.e. how many times they appear mydf_count <- data.frame(item=mydf_keys, count=mydf_vals) print(mydf_count) #mydf_sum gives sum of values of items in the column you specify mydf_sum <- setNames(aggregate(mydf$Values, by = list(item=mydf$Key), FUN = sum, na.rm = TRUE), c('item', 'sum')) print(mydf_sum) Output: If you have a better approach for this then please share in the comments below or email me. :) This R example groups rows by a key column and comput...

Run Microsoft R Open Script From Command Prompt

Image
Microsoft R Open is Multi-core environment developed on Core R. Microsoft R Open (MRO), formerly known as Revolution R Open (RRO), is the enhanced distribution of R from Microsoft Corporation. It is a complete open source platform for statistical analysis and data science. Microsoft R Open 3.4.1 is coming September 11th. MRO comes with Microsoft R Open GUI and you can also use it in RStudio IDE. But in case you want to run it from command prompt, it is pretty easy. First you need to set Path in environment variable. For 32-bit version path would be like: C:\Program Files\Microsoft\R Open\R-3.4.0\bin For 64-bit version path would be like: C:\Program Files\Microsoft\R Open\R-3.4.0\bin\x64 Now save it and restart command prompt if already open or open a new command prompt window. Type command "where rscript" and check whether it returns a correct path. Now you can type command "rscript your_script.r" and it will get executed. No...

Xiaomi Mi A1 vs Motorola Moto G5S Plus Price and Comparison

Image
Xiaomi Mi A1 The Xiaomi Mi A1 is a dual-SIM (Nano-SIM) smartphone that runs Android 7.1.2 Nougat. It features a 5.5-inch full-HD (1080x1920 pixels) display. It is powered by an octa-core Qualcomm Snapdragon 625 SoC coupled with 4GB of RAM. In terms of optics, the dual rear camera setup of the Xiaomi Mi A1 bears two 12-megapixel sensors, with one featuring a wide-angle lens with a 1.25-micron pixel sensor and f/2.2 aperture, and the other sporting a telephoto lens, 1-micron pixel sensor, an f/2.6 aperture, and capable of delivering 2x optical zoom. The smartphone bears a 5-megapixel front camera with a real-time beautification mode. The Xiaomi Mi A1 comes with 64GB of inbuilt storage, which is expandable via microSD card (up to 128GB) in a hybrid dual-SIM configuration. It houses a 3080mAh battery. Motorola Moto G5S Plus The dual-SIM (Nano) Moto G5S Plus runs Android 7.1 Nougat out of the box, and it sports a 5.5-inch full-HD (1080x1920 pixels) IPS LCD display. It is...

Perl Subroutine Arguments

Image
Subroutines:- 1. Retrieving arguments to a subroutine with shift: A subroutine's arguments come in via the special @_ array. The shift without an argument defaults to @_ .     sub volume {         my $height = shift ;         my $width = shift ;         my $depth = shift ;         return $height * $width * $depth ;     }

C/C++ Parameter Passing

Image
C parameter passing:- 1. Pass by Value: - The value of a variable is sent to function. - The actual parameter cannot be changed by function. - Duplicate Copy of Original Parameter is Passed. - No effect on Original Parameter after modifying parameter in function. # include < stdio.h > void interchange ( int number1 , int number2 ) { int temp ; temp = number1 ; number1 = number2 ; number2 = temp ; } int main ( ) { int num1 = 50 , num2 = 70 ; interchange ( num1 , num2 ) ; printf ( " \n Number 1 : %d " , num1 ) ; printf ( " \n Number 2 : %d " , num2 ) ; return ( 0 ) ; }

Campagna T-Rex

Image
Campagna T-Rex From Wikipedia, the free encyclopedia The Campagna T-REX is a two-seat, three-wheeled motor vehicle created by the Campagna Motors, located in Quebec, Canada. Its powered a 1.6 L, straight-six engine. Although it is usually registered as a motorcycle, the interior can accommodate the driver and a single passenger seated side-by-side, with adjustable seat backs, a foot-pedal box, and retractable three-point seat belts. The manual transmission, controlled by hand, more closely resembles a motorcycle's transmission than that of a car. The T-REX has been commercially available since the early 1990s. The Campagna T-REX was designed and styled by Deutschman Design.

Polaris Slingshot

Image
Polaris Slingshot From Wikipedia, the free encyclopedia The Polaris Slingshot is a three-wheeled motor vehicle. It was introduced in 2014 as a 2015 model. The Slingshot is manufactured by Polaris Industries, which claims "It's a three-wheeled motorcycle!" It has a tilt-adjustable steering wheel, side-by-side bucket seats, and does not lean. Three-point seat belts are fitted, however it has no airbags or crumple zone, and driver and passenger must wear motorcycle helmets in certain jurisdictions. It has no roof, doors, or side windows. A small windshield is an optional extra on the base model, and fitted as standard on the SL model. The steering wheel, gear stick, and brake, clutch, and throttle pedals have a conventional automobile layout.

Payments Bank in India

Image
[source: http://economictimes.indiatimes.com/definition/payments-banks ] Payments banks is a new model of banks conceptualized by the Reserve Bank of India (RBI). These banks can accept a restricted deposit, which is currently limited to ₹1 lakh per customer and may be increased further. These banks cannot issue loans and credit cards. Both current account and savings accounts can be operated by such banks. Payments banks can issue services like ATM cards, debit cards, net-banking and mobile-banking. Airtel has launched India's first live payments bank. Paytm is the second such service to be launched in the country. India Post Payments Bank is the third entity to receive payments bank permit after Bharti Airtel and Paytm. Aditya Birla group earned payments bank permit on 3 March 2017. [source: https://en.wikipedia.org/wiki/Payments_bank ]

Android 8.0 Oreo list of supported Devices

Image
Here are the Google devices which will receive the Android Oreo 8.0 update.     Google Pixel (Developer Preview available to download)     Google Pixel XL (Developer Preview available to download)     Google Pixel 2     Google Pixel C (Developer Preview available to download)     Google Nexus Player (Developer Preview available to download) === Here is the list of Samsung phones getting Android 8.0 O update.     Samsung Galaxy S8(G950F, G950W)     Samsung Galaxy Note 8 (Upcoming)     Samsung Galaxy S8 Plus(G955,G955FD)     Samsung Galaxy S7 Edge(G935F, G935FD, G935W8)     Samsung Galaxy S7(G930FD, G930F, G930, G930W8)     Samsung Galaxy A3( 2017)(A320F)     Samsung Galaxy A5( 2017)(A520F)     Samsung Galaxy A7 ( 2017)(A720F, A720DS)     Samsung Galaxy A8 ( 2...

Android 8.0 Oreo list of unsupported Devices

Image
Google: Google Nexus 5 Google Nexus 4 Google Nexus 3 HTC: HTC Desire 728 HTC One E9s HTC Butterfly 3 HTC A9 HTC One M9 HTC One M9 Plus HTC One M8 HTC One M8s Huawei: Huawei Honor 8 (Controversial) Huawei Honor 5A Huawei Honor 5c Huawei Y3II Huawei Y5II Huawei Mate 8 (Controversial) Huawei Y6 Huawei Honor 7 Huawei Y3( L02/03/L22/L23 U00) Huawei Y7 Huawei Y6 Huawei Y5

Edit photo - Picture frame - Image effects in Python

Image
from skimage import data, io import sys from skimage.color import gray2rgb try:     rgb_image = data.imread(sys.argv[1])     height = rgb_image.shape[0]     width = rgb_image.shape[1]     if(len(rgb_image.shape) < 3):         rgb_image = gray2rgb(rgb_image)         for i,j in zip(range(int(width/8)), range(int(width/8),0,-1)):         rgb_image[i, 0:j, :] = 0         for i,j in zip(range(int(7*(height/8)),height), range(0,int(width/8))):         rgb_image[i, 0:j, :] = 0    

Edit photo - Square crop - Image resizing in Python

Image
from skimage import data, io import sys from skimage.color import gray2rgb try:     rgb_image = data.imread(sys.argv[1])     height = rgb_image.shape[0]     width = rgb_image.shape[1]     if height == width:         print("already square image")         else:         if(len(rgb_image.shape) < 3):             rgb_image = gray2rgb(rgb_image)                     right_image = rgb_image.copy()         left_image = rgb_image.copy()         center_image = rgb_image.copy()        

Edit photo - Oil painting effect - Image manipulation in Python

Image
from skimage import data, io import random import sys from skimage.color import gray2rgb try:     rgb_image = data.imread(sys.argv[1])     height = rgb_image.shape[0]     width = rgb_image.shape[1]     if(len(rgb_image.shape) < 3):         rgb_image = gray2rgb(rgb_image)         for i in range(height):         for j in range(width):             for k in range(rgb_image.shape[2]):

Edit photo - Pencil sketch effect - Image processing in Python

Image
Code: from skimage import data, io, util import random import sys from skimage.color import rgb2gray try:     rgb_image = data.imread(sys.argv[1])         height = rgb_image.shape[0]     width = rgb_image.shape[1]         if(len(rgb_image.shape) == 3):         rgb_image = util.img_as_ubyte(rgb2gray(rgb_image))

Python: Count occurences in List

Image
1. Histogram >>> mylist = [1,3,2,5,4,4,2,2,4,2,4,2,4,6,4,5,2] >>> import matplotlib.pyplot as plt >>> plt.hist(mylist) (array([ 1.,  0.,  6.,  0.,  1.,  0.,  6.,  0.,  2.,  1.]), array([ 1. ,  1.5,  2. ,  2.5,  3. ,  3.5,  4. ,  4.5,  5. ,  5.5,  6. ]), <a list of 10 Patch objects>) >>> plt.show()

Edit photo - Change color effects - Image filtering in Python

Image
Code:- from skimage import data, io import random try:     rgb_image = data.imread("Collage.jpg")     #print(rgb_image.shape)         red_image = rgb_image.copy()     green_image = rgb_image.copy()     blue_image = rgb_image.copy()         red_image[:, :, (1, 2)] = 0     io.imsave("red_output_image.jpg", red_image)         green_image[:, :, (0, 2)] = 0     io.imsave("green_output_image.jpg", green_image)         blue_image[:, :, (0, 1)] = 0     io.imsave("blue_output_image.jpg", blue_image)    

Bar plot in Python using Bokeh

Image
import pandas as pd from collections import Counter from datetime import datetime, timedelta from bokeh.charts import Bar, output_file, show from bokeh.models.layouts import Column import numpy as np try:     data = pd.read_csv('new.csv')     scan_col = Counter(data['Scan'])     values = list()     keys = list()         for s in scan_col.keys():         scan_time_total = datetime.strptime("00:00:00","%H:%M:%S")         scan_time_total = timedelta(hours=scan_time_total.hour, minutes=scan_time_total.minute, seconds=scan_time_total.second)

Bar plot in Python using Matplotlib

Image
import pandas as pd from collections import Counter from datetime import datetime, timedelta import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt try:     data = pd.read_csv('new.csv')     srn_col = Counter(data['SRN'])     month_col = Counter(data['Month'])     scan_col = Counter(data['Scan'])     scan_dict = {}

Bar plot in Python using Plotly

Image
Step 1: Install plotly package if you haven't. Follow this article: http://com.puter.tips/2017/02/install-plotly-package-in-python.html Step 2: Set up your online credentials for plotly account. 2.1: Go to https://plot.ly/settings/api 2.2: Sign in/sign up. 2.3: Open https://plot.ly/settings/api (API Settings page) and click on Regenerate Key button. Copy the API key.

Install Plotly package in Python

Image
You need pip package manager to install Plotly package in Python. Use this command to install plotly with python: pip install plotly Ref.: https://plot.ly/python/getting-started/ Plotly is a library for building interactive charts in Python that render in the browser, with hover, zoom, and pan built in. Installing it is a single pip command, as shown above. Once installed you can create figures with plotly.express or plotly.graph_objects and export them to HTML or images. It works well inside Jupyter notebooks and dashboards.

Find difference between two text files in Python

Image
#!/usr/bin/python import difflib, sys file1 = sys.argv[1] file2 = sys.argv[2] diff = difflib.unified_diff ( open(file1).readlines(), open(file2).readlines(), fromfile=file1, tofile=file2 ) strings = list() for line in diff:     strings.append(line.replace('\n', '')) for string in strings:     print(string) This script compares two text files in Python using difflib and prints a unified diff, the same format version control tools use. You pass the two file paths as arguments. difflib ships with the standard library, so nothing needs installing, and it is handy for comparing generated output, logs, or configuration against an expected version.

Find difference between two text files in Perl

Image
#!/usr/bin/env perl use strict; use warnings; use Text::Diff; my $file1 = $ARGV[0]; my $file2 = $ARGV[1]; my $diffs = diff $file1,$file2; my @strings = split("\n",$diffs); foreach(@strings) {     print $_."\n"; } This Perl script compares two text files and prints their differences using the Text::Diff module. You pass the two file paths as arguments and it reports the changed lines, much like the Unix diff command. Doing this in code is useful inside larger pipelines, for example checking generated output against an expected baseline or flagging configuration drift between environments.