Friday 13 May 2016

Extract pom.xml version number using Shell script - Scenario 1

Guys, in todays post we'll look into an example where we want to extract version number from pom.xml of a Maven based project. In other words, all we have to do is extract text between 2 strings from a file. Quite obviously we would use sed for that. But let's look into a scenario where you have to pipe sed to other unix commands.

FYI this will work universally on Linux/Unix/Mac OS X flavors.

Let's say I have a pom.xml file of a Maven based project and I want to display only the version number from it. As you may be aware, we define the version number within the <version> </version> tags.

For e.g. my pom.xml looks something like this :


Here we want to extract only the version number from the file. i.e in this case I only want to display 1.0-SNAPSHOT.

Did you notice that in our file we have two lines of the <version></version> tags. One for our main project version and the other is for the dependency version. Now if we use sed to extract text between the "version" words, it will give output like this below.

sed -n '/version/,/version/p' pom.xml
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>testapp</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>

      <version>3.8.1</version>

So let's display only the topmost line with head -1. That should help narrow down our output.

sed -n '/version/,/version/p' pom.xml | head -1
  <version>1.0-SNAPSHOT</version>

Now all we need is to extract the version number. Let's cut the output characters as follows :

sed -n '/version/,/version/p' pom.xml | head -1 | cut -c 12-23
1.0-SNAPSHOT

Cheers guys! That's what we wanted right? Now we could perhaps develop a script around this. Maybe have a variable which stores this version number. Perhaps we could use this variable for some conditional checks. Something like this :

#!/bin/bash
# Program to extract version number from the pom.xml

i=`sed -n '/version/,/version/p' /Users/ironcladzone/workspace/MavenTest/testapp/pom.xml | head -1 | cut -c 12-23`

echo $i

if [ $i = "1.0-SNAPSHOT" ]; then

echo "Version 1.0 Development copy. Team A is working on it."
else

echo "That's not a Version 1.0 Dev copy"

fi

Output :

./ExtractVersionFromPom.sh
1.0-SNAPSHOT

Version 1.0 Development copy. Team A is working on it.

The possibilities are limitless! Until next time, ciao!

Thursday 12 May 2016

Play audio file from Terminal on Mac OS X without iTunes

Guys, am sure this post will definitely interest you - how to play an audio file from Terminal on Mac OS X without using iTunes. Well, we play it using the "afplay" command.

Well here's what you need to do in Terminal :

afplay -q 1 --leaks /Users/ironcladzone/Music/Bo\ Saris\ -\ She\'s\ On\ Fire\ \(Maya\ Jane\ Coles\ Remix\).mp3 -d -r 1

Playing file: /Users/ironcladzone/Music/Bo Saris - She's On Fire (Maya Jane Coles Remix).mp3
Playing format: AudioStreamBasicDescription:  2 ch,  44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame

Buffer Byte Size: 20135, Num Packets to Read: 19
Enable rate-scaled playback (rate = 1.00) using Spectral algorithm

-q switch is to set the quality level. 0 is default for low quality. Set it 1 for high quality version.

-d switch is for debugging which shows you the technical details like frames/packet, buffer byte size etc.

-r is the rate / speed of playback. Default is 1. Try changing it to 2 or 3 for speedier playback ;)

Oh and by the way, in case if you didn't notice, I was playing the cool Maya Jane Coles remix of Bo Saris' "She's on Fire". Maya Jane Coles rocks :)

Tuesday 10 May 2016

Print a triangle using * in a Bash script

Hello coders! Hows it going? Today we'll see a basic simple shell script to print a triangle using asterisk * only. Here's the code to do that :

#!/bin/bash
# Simple program to print a triangle using * of height 10

star="*"

for i in {1..10}
do
echo "$star";
star="$star *"

done

You see basically, all we are doing is append a * to itself recursively. Here we are using a basic for-loop to print a triangle of height 10. You can change the height as per your requirement, as needed.

Output :

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *

* * * * * * * * * *

Cheers!

Friday 6 May 2016

Identify exact port number used by a process or app on Mac OSX

Guys, if you ever wanted to find out the exact specific port number used by a process/application on Unix/Mac OSX/Linux, type the following in Terminal :

top | awk '{print $2, $7}'

The output would be something like :

COMMAND #PORTS
awk 12
top 22+

top 19

This will show only the specific Command and Port columns from the top command and will skip other details like Process ID, % CPU utilisation , Memory usage etc.

Alternatively if you wanted to just find the port number used by a specific application, say for e.g. TextEdit, you could use the following command :

top | awk '{print $2, $7}' | grep TextEdit
TextEdit 140+
TextEdit 140

TextEdit 140

Cheers guys!

Thursday 5 May 2016

Read file line by line and count no. of lines using Shell script

Guys, in today's post we'll see how to parse a file line by line and count the number of lines in it.

We will simply use redirection to read the file. Note that we will pass the filename as a runtime parameter to the script.

Alright here we go. Suppose I have a file TextFile1.txt with the following contents. I want to print the total number of lines in it.

ABCD
DEFG
GHI
JKL
MNO
PQR
STU

VWXYZ

Now, here's the script part.

#!/bin/bash
#Sript to count number of lines in a file

File=$1

count=0

while read LINE

do

let count++

echo "$count $LINE"

done < $File


echo -e "Total $count Lines read\n"

Here's the output :

1 ABCD
2 DEFG
3 GHI
4 JKL
5 MNO
6 PQR
7 STU
8 VWXYZ

Total 8 Lines read

Cheers it has correctly displayed the count of lines in the file. In case of any questions/doubts, kindly leave your comments.

Search for string in a file and print the line : Unix basics

Guys, lets look into a very basic topic today. Today we'll see how to search for a string in a file and print the line in Unix/Linux/Mac OS X

Suppose I have a file SedText.rtf with the following text :

1.Here is a cute little tutorial for
2.trying out different things using
3.the Stream Editor or Sed in Unix.
4.The author of this tutorial is
5.none other than IroncladWriter
6.himself. The tutorial aims to
7.teach folks and educate how
8.they could unlock the power
9.of Unix to the fullest. Am posting
10.this on the blog IronCladZone
11.The best blog on the whole of
12.internet, where you can learn
13.technical stuff as well enjoy 
14.entertaining tidbits like movies,
15.music, television, fashion, food,
16.shopping, travel, trends etc.
17.Just sit back, relax and

18.ENJOY THE RIDE :)

Now I want to search this file for the keyword "Unix" and print all the lines. All we have to do is use the grep statement. Check this out :

grep Unix SedText.rtf
3.the Stream Editor or Sed in Unix.\

9.of Unix to the fullest. Am posting\

Saturday 30 April 2016

Metal Gear Solid V : Phantom Pain - Identify the Screenshot 2

Hello gamers! Hope you are having fun with the Phantom Pain - one of the best games I've played in a while. I absolutely love its stealth gameplay and the mind-blowing level of details. Every time I play the game I discover how minutely every detail has been thought about, designed and accounted for. Although at the moment the free roam is not quite exciting, but the various mission areas are just fantastic. The detailing is so very realistic, practical and to the point. Nothing fancy here, just some realtime replicas of outposts and bases.

Another icing on the cake is its haunting soundtrack. Wow! In case you want to listen to it separately, here's the Youtube playlist for In-game soundtrack.

The tracks that I particularly found haunting are :

  • Track 62 - Evasion
  • Track 68 - Skulls (Before Spotted)
  • Track 73 - Afghanistan Caution 2
  • Track 102 - Afghanistan Day Enemy Suspicion
  • Track 108 - Exfiltrate the Hotzone (Success)
Let me know if I missed any other cool track.


Well, and for today's screenshot of the today, take a look below.



As expected, guess what's the location and the area of operation / mission. Drop in your comments guys.

Oh and in case you missed it, here's the link to MGS V : TPP : Identify the Screenshot : Part 1. Cheers!

Start Stop Jenkins from Terminal on Mac OS X

Ola guys. I hope you came across my previous posts on setting up Ant and Maven with Jenkins. In today's post I'll show you how to start and stop Jenkins from Terminal on Mac OS X machine.

I assume you know how to shutdown Jenkins from console OR restart it from the URL field.

Alright so here we go.

For staring Jenkins from command line, type this in Terminal :

sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Give it a few seconds for Jenkins to startup and you can then see the console in the browser. If you still stay executing the startup command again you'll get the following message :

/Library/LaunchDaemons/org.jenkins-ci.plist: service already loaded

In the meantime you can double check if Jenkins has started by checking the process status in Terminal :

ps -ef | grep jenkins

For stopping Jenkins from the command line, type this in Terminal :

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

A rougher way to stop Jenkins is by killing the process ID of Jenkins that you found above with the ps -ef command.


How to setup Jenkins with custom Maven Home

Guys I earlier posted a quick short article on how to setup Jenkins with custom Ant Home. In today's post you'll learn how to similarly setup Jenkins with your custom Maven Home.

As usual go to Manage Jenkins -> Configure System

Scroll down to the Maven installations and untick Install Automatically. Now simply enter details about your custom MAVEN_HOME. Refer the screenshot below for reference please.


Cheers guys! Hope you are having a good time reading my blog. Make sure to dig in to discover more interesting posts.

Friday 29 April 2016

How to setup Jenkins with custom Ant Home

Ola guys! From today onwards am also including fresh new posts on Jenkins. Jenkins as you know is a popular continuous integration tool where you can setup jobs and define steps to create custom builds. The main advantage of any CI tool is the quick fast feedback. It thereby reduces the overall delivery time and are to able to spot for any errors really fast. I'll post another article on the overall generic advantages of Jenkins later.

In today's post I will start with a very simple basic configuration. I assume you have downloaded Jenkins and set it up on your machine.

Now before we start using Jenkins to perform builds, we need to configure it right. Let's do that.

Go to Manage Jenkins -> Configure System and scroll down to the Ant installations.

If you have already downloaded Ant and set up your custom ANT_HOME and want to use that, then do the following :

Untick Install Automatically and enter the details for ANT_HOME and give it a nice name to identify it. Check the following screenshot for reference.


Now just click Apply. Save. Cheers!

Wednesday 27 April 2016

Character Combinations using Shell Script

In today's post we'll look into a very simple entry level bash script in which we form all possible alphanumeric combinations using just 2 characters and save it in a file. You could tweak the program to suit your needs - e.g. all combinations of 6 or 7 or 8 characters or maybe include special characters as well. The file in which all these combinations are stored would be more like a dictionary.

#!/bin/bash
# Program to print all possible 2-character combinations

echo {a..z}{0..9} > /Users/ironcladzone/Documents/xyz.txt


echo {0..9}{a..z} >> /Users/ironcladzone/Documents/xyz.txt

Here's the output of xyz.txt :

a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 g0 g1 g2 g3 g4 g5 g6 g7 g8 g9 h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9 k0 k1 k2 k3 k4 k5 k6 k7 k8 k9 l0 l1 l2 l3 l4 l5 l6 l7 l8 l9 m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 n0 n1 n2 n3 n4 n5 n6 n7 n8 n9 o0 o1 o2 o3 o4 o5 o6 o7 o8 o9 p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 q0 q1 q2 q3 q4 q5 q6 q7 q8 q9 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 u0 u1 u2 u3 u4 u5 u6 u7 u8 u9 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 w0 w1 w2 w3 w4 w5 w6 w7 w8 w9 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 z0 z1 z2 z3 z4 z5 z6 z7 z8 z9
0a 0b 0c 0d 0e 0f 0g 0h 0i 0j 0k 0l 0m 0n 0o 0p 0q 0r 0s 0t 0u 0v 0w 0x 0y 0z 1a 1b 1c 1d 1e 1f 1g 1h 1i 1j 1k 1l 1m 1n 1o 1p 1q 1r 1s 1t 1u 1v 1w 1x 1y 1z 2a 2b 2c 2d 2e 2f 2g 2h 2i 2j 2k 2l 2m 2n 2o 2p 2q 2r 2s 2t 2u 2v 2w 2x 2y 2z 3a 3b 3c 3d 3e 3f 3g 3h 3i 3j 3k 3l 3m 3n 3o 3p 3q 3r 3s 3t 3u 3v 3w 3x 3y 3z 4a 4b 4c 4d 4e 4f 4g 4h 4i 4j 4k 4l 4m 4n 4o 4p 4q 4r 4s 4t 4u 4v 4w 4x 4y 4z 5a 5b 5c 5d 5e 5f 5g 5h 5i 5j 5k 5l 5m 5n 5o 5p 5q 5r 5s 5t 5u 5v 5w 5x 5y 5z 6a 6b 6c 6d 6e 6f 6g 6h 6i 6j 6k 6l 6m 6n 6o 6p 6q 6r 6s 6t 6u 6v 6w 6x 6y 6z 7a 7b 7c 7d 7e 7f 7g 7h 7i 7j 7k 7l 7m 7n 7o 7p 7q 7r 7s 7t 7u 7v 7w 7x 7y 7z 8a 8b 8c 8d 8e 8f 8g 8h 8i 8j 8k 8l 8m 8n 8o 8p 8q 8r 8s 8t 8u 8v 8w 8x 8y 8z 9a 9b 9c 9d 9e 9f 9g 9h 9i 9j 9k 9l 9m 9n 9o 9p 9q 9r 9s 9t 9u 9v 9w 9x 9y 9z

Metal Gear Solid V : Phantom Pain - Identify the Screenshot

Hello Gamers! How's it going? These days am currently hooked to playing MGSV : Phantom Pain over the weekends. Its quite an exciting tactical shooter which obviously rewards stealth over mindless shooting. I particularly like its Base Management System which unfolds and unlocks new features slowly as per the progress of the missions.

Check out the screenshot of the day. It features one of the platforms of your Mother Base.


Can you guess which platform is it? Drop in your comments guys.

Wednesday 20 April 2016

Area & Circumference of a circle - Shell script for Mac OS X

Guys in todays post let us look into a simple basic Mathematics problem. Let us automate the calculation of area and circumference of a circle, using a simple bash script. It's an easy script useful for learning some basic shell scripting.

Note : Value of pi used is a constant value rounded off to 3.142

#!/bin/bash
#program to calculate area and circumference of a circle

echo "=========================================="
echo "Area & Circumference of Circle Calculator"
echo "=========================================="

pi=3.142

echo "Please enter the radius of the circle : "
read radius

circumference=`expr "2*$pi*$radius"|bc`
echo "Circumference of circle : $circumference"
area=`expr "$pi*$radius*$radius"|bc`

echo "Area of circle : $area"

Output :

./AreaOfCircle.sh
==========================================
Area & Circumference of Circle Calculator
==========================================
Please enter the radius of the circle : 
5
Circumference of circle : 31.420

Area of circle : 78.550

Also do check out my previous post on Simple Interest Tool for additional scripting reference.

Script to check if a server / machine is up and running

Guys you might often come across some situations where you want to check if a server or machine is physically up and running. Quite obviously you would use the ping command to do so.

But in today's post let us write a simple bash script to automate this.

#!/bin/bash
#program to check if a server/machine is up and running

ipaddr=192.168.1.34

ping -c 4 $ipaddr >> /dev/null

if [[ $? -ne 0 ]]
then
echo "FAIL: Server seems to be down and not responding" 

else
echo "SUCCESS : Server is up and running"


fi

Note : $? is a special Unix variable to check if the previous command was executed successfully or not. It returns a numerical value - either 0 or 1. If the command was executed successfully, it returns 0, else if not, it returns 1.

In above script, simply replace the variable 'ipaddr' value to your server's ip address and check.

Also note that by redirecting the output of the ping command to /dev/null, we are suppressing and silencing the output i.e the ping o/p will not be shown on terminal. If you want to see the exact output of ping, remove the ">> /dev/null" part.

Output :

./PingServer.sh
SUCCESS : Server is up and running

Cheers!

Simple Interest Calculation : Shell Script for Mac OS X

Guys, today we'll look into a very basic simple shell script to calculate the Simple Interest. For this we need 3 essential details :

Principal Amount
Rate of Interest
Period i.e No. of years

Here's the bash script to calculate the Simple Interest.

#!/bin/bash
#program to calculate simple interest

echo "================================"
echo "Simple Interest Calculation Tool"
echo "================================"
echo "Enter principal amount : "
read principal
echo "Enter Rate of Interest : "
read roi;
echo "Enter No. of years : "
read years;

simple_interest=`expr "($principal*$years*$roi)/100"|bc`
echo "Simple Interest = $simple_interest"

Output :

./SimpleInterest.sh
================================
Simple Interest Calculation Tool
================================
Enter principal amount : 
5000
Enter Rate of Interest : 
9.5
Enter No. of years : 
5

Simple Interest = 2375

If you note, we have used the bc command to evaluate our expression i.e the Simple Interest formula. More on bc can be read here.

How to identify available shells on Mac OS X

Guys you may be aware that you can find your current shell in Mac OSX or any Unix machine by typing the following in Terminal.

echo $SHELL
/bin/bash

But to identify the available shells on Mac OS X type the following :

cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

Also, if you ant to change your default shell, type this :

chsh
Changing shell for ironcladzone.

Password for ironcladzone: 

Hope it helps. Cheers!

Saturday 9 April 2016

GRE GMAT CAT Wordlist - TurboPack 8

Hi there! Hows it going today? Hope the previous TurboPacks are helping you in a small and efficient way in your preparations. Well let me know your valuable suggestions and comments to improve the quality and/or overall experience.


For now, let's continue with the latest TurboPack 8 for the day.

supple : flexible, bending and moving easily, limber
mogul : powerful person
lofty : very high
wholesome : healthful
indigence : extreme poverty
aspersion : slanderous remark, attack on someone's reputation
archetype : prototype, a typical example
gorge : narrow canyon, narrow valley, throat
putrid : foul smelling, decaying or rotten smell
simulate : imitate, pretend

Folks, more TurboPacks are on the way. Make sure to check for my previous TurboPacks 1-7 for reference. Again let me repeat that try to work on small batches of words at a time and focus on them thoroughly. Hope it helps. Ciao!

Thursday 7 April 2016

GRE GMAT CAT Wordlist - TurboPack 7

Hi guys! hows it going? Hows your verbals preparation coming along. Hope the previous TurboPacks are useful in some way. Kindly do post your valuable comments and suggestions guys.



Here's another small batch of 10 Turbo words for the day.

encircle : surround
armada : fleet of warships
garish : overbright in color, gaudy, showy
exhume : dig out from ground
ferret : hunt out of hiding, assiduous search for something
arid : dry, barren
jetsam : things thrown from a ship usually to lighten it
oust : expel, drive out
paragon : model of perfection, a perfect example, of perfect quality
exquisite : very finely made, very beautiful and delicate

And incase you missed it, here are the links to previous TurboPacks

TurboPack 1
TurboPack 2
TurboPack 3
Turbopack 4
TurboPack 5
TurboPack 6

Wednesday 6 April 2016

GRE GMAT CAT Wordlist - TurboPack 6

Ola fellas! como estas? How you guys doing? Hope the TurboPacks are aiding your preparations. Let me know your valuable comments and suggestions and if any more assistance needed.


So the TurboPack 6 is as follows :

rebuke : scold harshly, sharply criticise
mischance : ill luck, bad luck
ineffectual : weak, not effective
shirk : avoid/neglect work or responsibility
petty : trivial, unimportant
respite : relief, time for rest
parable : short story with a moral or lesson
shrewd : clever, astute
mirage : unreal reflection, optical illusion
astral : relating to the stars

The TurboPack 7 will be posted tomorrow. Stay tuned folks.

Tuesday 5 April 2016

GRE GMAT CAT Wordlist - TurboPack 5

Thanks guys for the good response for my previous TurboPacks. Well, as I said before more TurboPacks are in the pipeline and would be posted at regular intervals. Am really encouraged to post more Packs like these. Again let me reiterate that the USP of TurboPacks is the random non-alphabetical sequencing of words. I think it helps in improved memorisation. Hope it helps guys.

In the meantime, I suggest you cut a cardboard or simply a blank page into 10 mid-sized rectangles. Create your own 10 flash cards the moment you come across the new words in TurboPack. On one side of the rectangle write the word and on the other side write the meaning/synonym. Perhaps a rectangle of the size of the logo below. What say? You could refer to them throughout the day, whenever you wish to. Just target this small batch of 10 words and focus on them thoroughly.


Ok so here we go again. Here's the TurboPack for today.

mortician : an undertaker, a funeral director
biennial : every two years
pyromaniac : person with an obsessive desire to set things on fire
canard : baseless unfounded rumor or story
onslaught : fierce attack, a vicious assault
philanderer : womaniser, a flirt, faithless lover
churlish : rude or boorish
rebate : discount, partial refund
doze : nap, short light sleep
residual : leftover, remaining

Saturday 2 April 2016

Mac OS X - Hidden Gems : Part 3

Guys in today's new gem, we'll see how to play the hidden game Tetris on Mac OS X which comes bundled by default for FREE. Didn't you even know that? I bet you didn't!

Allright! So to play Tetris on Terminal, do this :

  • Open Terminal
  • Type emacs
  • Now hit the Esc button and immediately press x

  • When you see the M-x prompt, just type tetris. Now simply relax and play a cool game of Tetris. How cool is that?



GRE GMAT CAT Wordlist - TurboPack 4

Guys, I have seen many people trying by-heart the dictionary all at once while trying to prepare for the verbals of these competitive exams. In my opinion, its wiser to take small batches of words and work on them regularly. Hence the name TurboPack which is essentially a small batch of 10 random words in non-alphabetical sequence. I will try to post some word-sets like these at regular intervals. Make sure you bookmark them for future references.

Also, in case you missed, here's the list of previous TurboPacks.

TurboPack 1
TurboPack 2
TurboPack 3

Tip : Learn the meanings of these words and try to use them in any sentences. For starters, you could add a comment to my blog post with a sentence including a word you just learnt from the TurboPack. Try to have a conversation with someone and use these words randomly. I bet this approach will significantly boost your memorisation.


So here is the latest TurboPack for the day.

diadem : a jewelled crown
amazon : female warrior
cataract : a large waterfall, an eye abnormality
facsimile : copy
contusion : bruise, an injury
encumber : burden in such a way that movement is restricted
kernel : a central or vital part, core
maxim : proverb, a short statement of general truth
noxious : harmful, unpleasant, poisonous
orator : an eloquent/skilled public speaker

That's it for now. Will try to post more exciting and interesting TurboPacks very soon. In the meantime make sure to post an instant comment with some random sentence making use of the above words. Ciao!

GRE GMAT CAT Wordlist - TurboPack 3

The TurboPack 3 wordlist for today is as follows guys. Also do checkout TurboPack 1 and TurboPack 2 for reference.

apparition : ghost, phantom
buccaneer : pirate
nomenclature : terminology, the system of naming things
modicum : small amount, limited quantity
fallacious : based on a fallacy or mistaken belief, misleading
ewe : female sheep
cessation : stoppage, bringing to an end
pragmatic : practical, in a realistic way
recline : lie down, lean back
forlorn : sad and lonely, desolate

Friday 1 April 2016

Upgrade Subversion on Mac OS X using Homebrew

Hi guys, in today's article we will see how to upgrade Subversion on Mac OS X using Homebrew. Subversion i.e SVN as you know is a popular centralised version controlling system.

First of all check in Terminal, the default pre-loaded version of Subversion that comes packaged with OS X.

svn --version
svn, version 1.7.20 (r1667490)

Now lets install Homebrew on the machine. For that just type the below command as mentioned on Homebrew's homepage. Btw for those who may be unaware, Homebrew is a free open source package management solution.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Now it will begin the installation process and will change/update the owner and permissions of the following folders.

==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
==> The following directories will have their owner set to ironcladzone:
/usr/local/.
/usr/local/bin
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin


Once Homebrew is installed, we need to install Subversion using it. First of all lets get some information about svn installation. Type this in terminal :

brew info subversion

subversion: stable 1.9.3 (bottled)
Version control system designed to be a better CVS
https://subversion.apache.org/
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/subversion.rb
==> Dependencies
Build: pkg-config , scons
Required: sqlite , openssl
Optional: gpg-agent
==> Options
--universal
Build a universal binary
--with-gpg-agent
Build with support for GPG Agent
--with-java
Build Java bindings
--with-perl
Build Perl bindings
--with-python
Build with python support
--with-ruby
Build Ruby bindings
==> Caveats
svntools have been installed to:
  /usr/local/opt/subversion/libexec

You see there are some dependencies that Brew will install along with Svn. Dependencies like sqlite, openssl etc. Proceed with the installation now and be patient for a while till it finishes.

brew install subversion

==> Installing dependencies for subversion: readline, sqlite, openssl
==> Installing subversion dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-6.3.8.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-6.3.8.el_capitan.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
.
.
.
==> Caveats
svntools have been installed to:
  /usr/local/opt/subversion/libexec

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/subversion/1.9.3: 148 files, 11.1M

Just check which svn versions are installed on your machine. I mean the locations of svn.

which -a svn
/usr/local/bin/svn
/usr/bin/svn

Now after the installation is complete, if you check svn --version you will still see the older version of svn. Hey but it should be 1.9.3 the latest version right?

svn --version
svn, version 1.7.20 (r1667490)

To fix this we need to add a line to ~/.bash_profile

sudo vi ~/.bash_profile

export PATH="/usr/local/bin:$PATH"

Now type : source ~/.bash_profile

Check the svn version now and it will show the latest one.

svn --version
svn, version 1.9.3 (r1718519)

Cheers! You just upgraded Subversion on Mac OS X. Hope it helps guys!

Wednesday 30 March 2016

Metal Gear Solid V - Phantom Pain : Cloaked in Silence S-Rank FullHD Walkthrough

Guys, check out the High definition Hi-resolution walkthrough of Episode 11 : Cloaked in Silence of the blockbuster video game Metal Gear Solid V : Phantom Pain.

In this episode, you encounter the female Vanguard Sharpshooter "Quiet" in Afghanistan. It is usually triggered automatically when you pass a specific area [Aabe Shipaf Ruins] while going for the Stun-Arm blueprint Side Ops mission. You can either kill her or capture her and take to your Mother base. The choice is yours. If you capture her, you could use her as your buddy partner in future missions.

Tips and Tricks : 

  • This mission is particularly difficult coz Quiet has a sharp sight. She spots you quickly and also does lethal damage to your health when hit. Use the stones and rocks as your cover as much as possible.
  • She also has invisibility powers and zips around pretty fast. Also note that although if you spot her with the Analyser, she is untraceable after a while and you lose her position. Stay sharp!
  • Keep moving around and don't stay at one place for long.
  • While spotting Quiet with the Analyser, keep checking the Mic volume to hear her humming a soft tune. This helps to pinpoint her location.
  • If you lose her sight, stand up or come out in the open for a few moments to identify the angle  from which she spots you. It's risky I know.
  • Once you spot Quiet, immediately draw your Sniper Rifle for a quick hit. Make sure you do it accurately within a matter of few seconds. Time is of essence here.
  • There are multiple ways of hitting her in either lethal or non-lethal ways, this video will focus on the traditional approach using only the sniper rifle.

Check out this impossible S-Rank walkthrough video for reference :

Tuesday 29 March 2016

Modify a part of file path using Sed in Mac OS X - Tricky Scenario

Lets look into a fairly simple task with a slight twist today - update/modify a part of the file paths mentioned within a file using Sed from command line in Unix/Mac OS X. Mark this as a tricky interview question.

Let's consider a simple example. For instance we have a text file named Filepaths.txt which has the following file path details :

/Users/ironcladzone/Downloads/file1.txt
/Users/ironcladzone/Downloads/image.jpg
/Users/ironcladzone/Downloads/presentation.ppt
/Users/ironcladzone/Downloads/Spreadsheet.xls
/Users/ironcladzone/Downloads/Audio.mp3
/Users/ironcladzone/Downloads/Movie.avi
/Users/Shared/Downloads/Test1
/Users/Shared/Downloads/ABC
/Users/ironcladzone/Downloads/MovieClip.mov

Here we want to replace only a part of the file path i.e replace all instances of the word"Downloads" with "Documents". Sure you can instantly do it in some text editor using "Replace All". But the catch is I want to replace the word Downloads with Documents if and only if it exists in the /Users/ironcladzone/Downloads/ path. I want to skip all other file paths. In this case I want the path /Users/Shared/Downloads/Test1 & /Users/Shared/Downloads/ABC to remain intact and unchanged.

So let's see how to do it from command line using a Sed regex.

Open up terminal and type this :

sed 's/\/Users\/ironcladzone\/Downloads/\/Users\/ironcladzone\/Documents/g' FilePaths.txt

So here's the output as expected. Cheers!

/Users/ironcladzone/Documents/file1.txt
/Users/ironcladzone/Documents/image.jpg
/Users/ironcladzone/Documents/presentation.ppt
/Users/ironcladzone/Documents/Spreadsheet.xls
/Users/ironcladzone/Documents/Audio.mp3
/Users/ironcladzone/Documents/Movie.avi
/Users/Shared/Downloads/Test1
/Users/Shared/Downloads/ABC
/Users/ironcladzone/Documents/MovieClip.mov

Friday 25 March 2016

Logging in Ant : Live Practical Example

Hi! Hows it going guys! Today is an auspicious Indian day - Holi : the festival of colors. On this good auspicious day am also presenting a fresh new 200th post.

Let's look into a simple concept - how to take logs in Apache Ant builds. By taking logs I mean how to capture the console output in a log file.

The foremost thing you need to be aware of is the <record> task with which we tell Ant when and where to capture the console into a log. Detailed explanation of the task can be read at Ant Official Manual.

Let's use a familiar example that we used in our earlier posts - Ant build.xml updates : Feb 28 and Ant - Build.xml Introduction.

Check out our new updated build.xml below :

<?xml version="1.0" encoding="UTF-8"?>

<project name="AntBuildTest" default="generate-docs" basedir=".">

<property name="build.home" value="${basedir}" />
<property file="build.properties"/>

<tstamp>
<format property="timestamp" pattern="dd-MM-yyyy"/>
</tstamp>

<target name="clean">
<delete dir="${build.home}/src" />
<delete dir="${build.home}/bin" />
<delete dir="${build.home}/lib" />
<delete dir="${build.home}/test" />
<delete dir="${build.home}/dist" />
<delete dir="${build.home}/docs" />
<delete dir="${build.home}/logs" />
</target>

<target name="createdir" depends="clean">
<mkdir dir="${build.home}/src" />
<mkdir dir="${build.home}/bin" />
<mkdir dir="${build.home}/lib" />
<mkdir dir="${build.home}/test" />
<mkdir dir="${build.home}/dist" />
<mkdir dir="${build.home}/docs" />
<mkdir dir="${build.home}/logs" />
<record name="${build.home}/logs/build.log" action="start" append="no" loglevel="verbose" />
</target>

<path id="classpath">
<pathelement location="${build.home}/bin"></pathelement>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>

<target name="copydir" depends="createdir">
<copydir src="${workspace.src}"
dest="${build.home}/src"></copydir>
</target>

<target name="compile" depends="copydir, clean">
<javac classpathref="classpath" includeantruntime="false"
srcdir="${build.home}/src"
destdir="${build.home}/bin"
includes="**/*.java"></javac>
</target>

<target name="create-jar" depends="compile">
<jar basedir="${build.home}/bin" destfile="${build.home}/dist/${timestamp}-TestJar-${versionnum}.jar"
includes="**/*.class">
<manifest>
<attribute name="Main-class" value="com.ironcladzone.FileSize"/>
</manifest>
</jar>
</target>
<target name="generate-docs" depends="create-jar">
<javadoc sourcepath="${build.home}/${src.dir}" destdir="docs"/>
<record name="${build.home}/logs/build.log" action="stop" append="no" />
</target>


</project>

Notice the "createdir" task where we started the recorder and in the "generate-docs" we stopped it. The loglevel parameter is an optional one. In this example you see we have set the loglevel to verbose. It means it will have much detailed information in the logs than the default console output. However it can have any of the 5 possible values - error, warn, info, verbose, debug. Experiment with each level to see the difference.

Btw check the directory structure for reference.

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker