Posts

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