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.

Sunday, 20 March 2016

Double digit Arguments Passed to Shell script - Tricky Scenario

Guys, you know that $# is a special variable that gives the arguments passed to the shell script.

$1 will give the 1st argument passed, $4 will give the 4th argument passed to the script.

Let's consider a tricky scenario. 
Note : This is a tricky interview question.

Let's say you want to pass 12 arguments to the script.

Did you notice that after 9th argument, all arguments passed would be of 2 digits... I mean the 10th, 11th and 12th argument.

So let's say to get the 12th argument, you may tend to use $12. But hey look again! Thats not right! The script doesn't understand that. Check out a practical example to know what I mean.

Let's take a simple bash script and compare the output of Wrong and Correct versions.

[WRONG VERSION]

#!/bin/bash

# Call this script with 12 parameters

echo "1st parameter is $1";
echo "2nd parameter is $2";
echo "3rd paramter is $3";
echo "4th parameter is $4";
echo "5th paramter is $5";
echo "6th parameter is $6";
echo "7th parameter is $7";
echo "8th paramter is $8";
echo "9th parameter is $9";
echo "10th parameter is $10";
echo "11th parameter is $11";

echo "12th paramter is $12";

Now lets say you execute the script with 12 arguments. Watch the output :

./Parameters_Pass.sh 5 10 15 20 25 30 32 35 42 45 50 65

1st parameter is 5
2nd parameter is 10
3rd paramter is 15
4th parameter is 20
5th paramter is 25
6th parameter is 30
7th parameter is 32
8th paramter is 35
9th parameter is 42
10th parameter is 50
11th parameter is 51
12th paramter is 52

See how the 10th 11th and 12t argument that we passed got screwed up. Instead of 45, 50, 65 what we see is 50, 51 and 52. Thats's so wrong, right?

Now here's the correct version of the script.

[CORRECT VERSION]

#!/bin/bash

# Call this script with 12 parameters

echo "1st parameter is $1";
echo "2nd parameter is $2";
echo "3rd paramter is $3";
echo "4th parameter is $4";
echo "5th paramter is $5";
echo "6th parameter is $6";
echo "7th parameter is $7";
echo "8th paramter is $8";
echo "9th parameter is $9";
echo "10th parameter is ${10}";
echo "11th parameter is ${11}";

echo "12th paramter is ${12}";

Observe the brace brackets used for 10th, 11th and 12th argument. Now if you execute the script with 12 arguments again, we'll get the correct output as expected.

./Parameters_Pass.sh 5 10 15 20 25 30 32 35 42 45 50 65

1st parameter is 5
2nd parameter is 10
3rd paramter is 15
4th parameter is 20
5th paramter is 25
6th parameter is 30
7th parameter is 32
8th paramter is 35
9th parameter is 42
10th parameter is 45
11th parameter is 50
12th paramter is 65

Saturday, 19 March 2016

List only hidden files in Unix / Mac OS X

Folks you may be aware that ls -a will list all hidden files and visible files as well.

But to list only the hidden files, type the following in Terminal :

ls -ld .?*

This is one of the tricky interview questions, so make a note of this.

Friday, 18 March 2016

Mac OS X - Hidden Gems : Part 2

Oh boy! yet another Mac OS X hidden gem that you probably weren't aware of.

Type this is Terminal to read Mrs Fields secret Cookies recipe.

open /usr/share/emacs/22.1/etc/COOKIES

Mac OS X - Hidden Gems : Part 1

Guys, presenting a mind blowing Mac OS X hidden gem that I just stumbled onto.

Type the following in Terminal to read some Apple supplied Jokes :)

open /usr/share/emacs/22.1/etc/JOKES

Thursday, 17 March 2016

How to change Bash History Size on Mac OS X

Guys, I hope you must be aware, that the commands that you type in terminal get saved in the history. On Mac OS X, the default size of commands history is 500 i.e it saves the most recent 500 commands that you typed in terminal in a special file named "bash_history".

Open Terminal and check for yourself.

vi ~/.bash_history

Hit escape and type this to see the history limit
:set number


Now to change this default limit of 500 to something else, lets do the following in Terminal.

sudo vi ~/.bash_profile

Enter your password.

Add this line to the file :

#history
HISTFILESIZE=1000

That's it. It means from now on, it will save upto 1000 latest commands that you typed in history. Ciao!

Wednesday, 16 March 2016

GRE GMAT CAT Wordlist - TurboPack 2

Guys, in our previous TurboPack, we saw the first set of wordlist for your reference. From this post onwards, lets rename the "Set" of words to something more appealing - "TurboPack". The random non-alphabetical sequence of words in the pack is intended for stronger and better memory retention.

TurboPack 2

uncanny : strange, mysterious
recluse : loner, someone living a solitary life
penchant : strong inclination or liking to do something
palate : sense of taste
visage : face, facial appearance
occult : mysterious, supernatural, mystical
medley : mixture, motley
jaunt : short trip, short excursion
indolent : lazy
torque : force producing rotation

Courtesy : Barron's and Google

Cheers!

Monday, 14 March 2016

How to find size of Hashes in Perl

Hashes as you know are basically key-value pairs. So in Perl, if you want to find the size of hashes, check this out.

Consider a simple practical real-time Perl script for storing stock quotes of various companies.

#!/usr/bin/perl

use strict;
use warnings;

my %stock_quotes;
my @keys;
my $size_of_hash;

%stock_quotes=(
Apple => 102,
Google => 720,
Microsoft => 53,
Yahoo => 34,
Walmart => 67
        );

@keys = keys %stock_quotes;

$size_of_hash = @keys;


print "Stock hash size : $size_of_hash \n";

You see the %stock_quotes is the hash which has key value pairs i.e stock quote values in this case. Now, we store all the keys of the pairs in an array @keys. Note am not storing the values here, just the keys and we then find the size of this array @keys holding all the keys. Thus basically showing the size of the hash with $size_of_hash.

The resultant output is as expected :

Stock hash size : 5

Cheers!

Remove all Whitespaces from a file in Mac OS X

Lets look into a simple task today - remove all whitespaces from a file in Unix / Mac OS X from the command line.

To do so, let's consider a small example.

Let's have simple text file named Space_File.txt withe the below content. You see it's a regular text file with words separated with spaces.

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, we want to remove all the whitespace between the words. So let's use the following command.

tr -d ' \d' <Space_File.txt >NoSpace_File.txt

In this we pass the Space_Text.txt as input and redirect the output to a new file - NoSpace_File.txt. Note the space before \d. Do not miss this space. I repeat, DO NOT miss this space. It has to be ' \d' and not '\d'. Got it? All rite so the resultant output is as expected with no spaces:

1.Hereisacutelittletutorialfor
2.tryingoutifferentthingsusing
3.theStreamEitororSeinUnix.
4.Theauthorofthistutorialis
5.noneotherthanIronclaWriter
6.himself.Thetutorialaimsto
7.teachfolksaneucatehow
8.theycoulunlockthepower
9.ofUnixtothefullest.Amposting
10.thisontheblogIronClaZone
11.Thebestblogonthewholeof
12.internet,whereyoucanlearn
13.technicalstuffaswellenjoy
14.entertainingtibitslikemovies,
15.music,television,fashion,foo,
16.shopping,travel,trensetc.
17.Justsitback,relaxan

18.ENJOYTHERIDE:)

Monday, 7 March 2016

Show line numbers in vi editor on Mac OS X

Guys in vi editor in order to show the line numbers, do the following :

Open vi editor to create or open a script
Click escape (esc) key and type colon.
Now enter set number and Enter

Check out the screenshot for reference :

Cheers!

Sunday, 6 March 2016

User Input example in Python

Every programming language has a way to accept user input. Like in Perl, you accept using STDIN. Similarly, Python interpreter has 2 inbuilt functions to read user input :

raw_input()
input()

Let's look into a simple python script which accepts user input and prints a statement.
Create a simple script - vi python_input.py

#!/usr/bin/python

name = raw_input('Please enter your name, visitor : ');

print ('Welcome to IroncladZone ' + name);

You see the variable "name" stores the input entered by the user. Accordingly we make use of this value in the next print statement.

Output :

./python_input.py

Please enter your name, visitor : Johnny

Welcome to IroncladZone Johnny

Get Mac OS X System Information from Terminal

Hii! Guys lets come back today on another topic related to Apple Mac OS X. Correct me if am wrong, the first thing you would after purchasing your new Macbook or iMac is double-check the system information right?

Typically you would click the Apple logo on top left -> About this Mac -> System Report. Well could you get the same information from command line? Yes you can!

Open terminal and just type the following :

system_profiler

It will list the system information in a matter of few seconds. You could also filter the command to get only specific information by piping to a grep command.

For eg :

system_profiler | grep Memory

system_profiler | grep Processor

system_profiler | grep CPU

Saturday, 5 March 2016

Maven : mvn package in Eclipse

Guys, as you maybe aware the command "mvn package" creates a package and stores it in the target directory. On the other side if you run "mvn install" it will create a package and then store it in your local repository.

I assume you have created a project from the archetypes from command line and then converted it to a Maven project after importing it in Eclipse.

Make sure the pom.xml has packaging set to jar by default. You could also change the package to war if needed.

Now simple right click the project to choose Run as -> Run Configurations.


Here you can specify the goals. In this case, we just want to create a simple package. So do this :


As you see, we also get various options for e.g. to build offline, skip tests, debug output etc. Now just enter the goals "clean package" and click Run.

You'll see that after a while a jar package gets created in the target directory of the project. Similarly if you run "clean install", it will install the jar to your local repository location. Make sure to double check the timestamp of the package from Terminal.

GRE GMAT CAT Wordlist - Set 1

Hello guys. From today onwards, apart from the regular technical posts, I'll also be starting a new series - GRE GMAT CAT Wordlists. From time to time I'll try to post unique sets of words with their meanings. The objective is to aid you guys for preparation of competitive exams like GRE GMAT CAT etc. The wordlists would really help you gain a competitive edge in the verbal and comprehension sections of the exams.

FYI these are inspired by Barron's GRE word reference. The only difference is that Barron's words  are sorted in alphabetical sequence. While I'll try to mix and match the words in any random sequence. Hope it helps.

Here are some casual tips to improve your English :
  • Try to memorise the words and their meanings. 
  • Try to use these words and construct sentences. If you read an article from a newspaper or magazine, try to incorporate the newly learned words in it and reconstruct a certain phrase or statement.
  • Definitely use flashcards. They help a lot in memorising the words.
  • Read lots of books and articles.
  • Watch lots of English movies and television soaps.
  • Socialise a lot and network around, all while speaking in English.
  • (Optional) Date around, flirt a lot and chat in English. Helps build confidence ;)
Ok let's get going guys. Here's the first set of 10 words for today.

amalgamate : combine together, unite
bard : poet
cadaver : dead body, corpse
clandestine : secret, something that's done secretly
adulterate : make something impure and of inferior quality, contaminate
altercation : noisy quarrel, noisy argument
belated : delayed
lacklustre : dull, boring, lacking shine or gloss
intangible : vague
gravity : seriousness, of importance

How to debug shell / bash scripts

While executing the bash scripts, if you want to debug them i.e you want to trace the exact sequence of steps that get executed, continue reading this post below.

Just below the shebang line on top of every script, type this :

set -x

That's it.

Let's take the example of killing a process / application using shell script that we saw in our previous post. Assuming you have opened the application - TextWrangler and want to close it using a bash script.

#!/bin/bash
set -x


kill -9 `ps -ef | grep TextWrangler | awk '{print $2}'`;

Now here's the output for the same :

++ ps -ef
++ grep TextWrangler
++ awk '{print $2}'

+ kill -9 24677 24678 24682

Note that 24677 24678 and 24682 are all PID's of all processes associated with TextWrangler. In this way you can track the flow of the script in which the tasks get executed. Debugging can be of great help if you have a complex flow of program and need to identify the sequence of steps in which they are executed.

Friday, 4 March 2016

Kill process or application using Apache Ant

Hello friends. In our last post we saw how to execute a shell script from Apache Ant. In today's post lets see if we could use Ant to kill some running processes.

For example lets open the TextWrangler app. Now lets try to close it using Ant build.

Consider a shell script kill-wrangler.sh as below :

kill -9 `ps -ef | grep TextWrangler | awk '{print $2}'`;

Now we'll execute the above bash script and kill the corresponding PID (process ID) for the TextWrangler app using the Ant build. Consider the following build.xml

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

<project name="AntBuildTest" default="kill-process" basedir=".">

<target name="kill-process">
<exec executable="/bin/bash">
<arg value="kill-wrangler.sh"/>
</exec>
</target>


</project>

In this we execute the above bash script kill-wrangler.sh and close the application. You could grep (search) the running processes for any other program/string. For instance you could kill some Java process or maybe stop some application. Okay guys, signing out for now. Will post some more cool stuff in the forthcoming days. Stay tuned...

Wednesday, 2 March 2016

How to open Terminal from within Eclipse on Mac OS X

In Eclipse, from the Help menu -> Eclipse Marketplace, lookup for Terminal. Install the plugin TM Terminal that you'll come across as below:


Once installed, simply mention the shell interpreter location in the Preferences for e.g. /bin/bash and also choose the initial working directory as either your User Home or Eclipse Workspace.


Now go to Window -> Show View and choose Terminal to show it within Eclipse and click the following blue button to open a new session.


This way you can run shell scripts from within Eclipse itself. Cheers!

Tuesday, 1 March 2016

Call shell script from Apache Ant build on Mac OS X

Guys, you might come across some situations where you need to invoke shell and execute a bash script while building a project using Apache Ant. In today's example let's see how to run a shell script from within an Ant build.

For illustration, lets create a simple bash script to list the disk usage of our system. Let's name this file as "DiskUsage.sh"

#!/bin/bash

# Sample shell script to be invoked from an Ant build

echo "Disk usage is as follows : \n"
echo "=========================== \n"


df -h

Now let's create a simple build-test.xml using the exec command to invoke the shell as follows :

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

<project name="AntBuildTest" default="call-shell" basedir=".">

<target name="call-shell">
<exec executable="/bin/bash">
<arg value="DiskUsage.sh"/>
</exec>
</target>


</project>

Run the ant build from command line as ant -f build-test.xml. Note that the shell script and build.xml happen to be at the same location/hierarchy within the project. If your shell script lies elsewhere, you may perhaps want to refer to its path in the build.properties instead.

You could also invoke the "expect" scripting prompt in a similar fashion to execute an expect script that we discussed in our earlier post.

More information on the exec can be read at the official Ant manual.
Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker