NPM update all globally installed packages

npm update -g

22 December 2018 · Shafiq Alibhai

Import a Resource to Terraform Module

The example below will import an AWS instance into a terraform module: terraform import module.foo.aws_instance.bar i-abcd1234

24 October 2018 · Shafiq Alibhai

Install ruby gem files

Install the gems on the destination machine from the local files: cd /path/to/gems gem install --force --local *.gem

27 September 2018 · Shafiq Alibhai

One liner: To get available virtual memory

vmstat -s -SM | grep "free memory" | awk -F" " '{print$1}'

10 December 2011 · Shafiq Alibhai

Perl – system load

To find the system load use the following perl snippet : System load of last one minute : my $system_load = exec('<a class="zem_slink" title="Uptime" rel="wikipedia" href="http://en.wikipedia.org/wiki/Uptime">uptime</a> | awk -F "load average: " \'{ print $2 }\' | cut -d, -f1'); my $system_load = qx('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f1'); System load of last 5 minutes : my $system_load = exec('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f2'); my $system_load = qx('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f2'); System load of last 15 minutes : my $system_load = exec('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f3'); my $system_load = qx('uptime | awk -F "load average: " \'{ print $2 }\' | cut -d, -f3');

7 September 2010 · Shafiq Alibhai

Perl – How to Read a Text File into a Variable – 6 ways to do it

6 Ways to Read a Text File into a Variable If you are working with large file(s) you might consider using File::Slurp. It is much fast than the conventional: { local $/=undef; open FILE, "myfile" or die "Couldn't open file: $!"; binmode FILE; $string = &lt;FILE>; close FILE; } { local $/=undef; open FILE, "myfile" or die "Couldn't open file: $!"; $string = &lt;FILE>; close FILE; } open FILE, "myfile" or die "Couldn't open file: $!"; $string = join("", &lt;FILE>); close FILE; open FILE, "myfile" or die "Couldn't open file: $!"; while (&lt;FILE>){ $string .= $_; } close FILE; open( FH, "sample.txt") || die("Error: $!\n"); read(FH, $data, 2000); close FH; The format for the read function is: ...

15 March 2010 · Shafiq Alibhai