Skip to content

Instantly share code, notes, and snippets.

View ovntatar's full-sized avatar

Ovidiu N. Tatar ovntatar

View GitHub Profile
@ovntatar
ovntatar / DataStructure,pl
Created December 17, 2013 14:40
Tree data structure
#!perl
# Tree (PERL)
# ordering option -- Preorder - Inorder - Postorder
$tree=["Root", ["Grandma",["Mam",["Me"],["Brother"]],["Dad",["test"]],],];
sub FamRec {
my $Person=$_[0];
print "-".$$Person[0]."\n";
@ovntatar
ovntatar / ping.sh
Created December 17, 2013 14:42
simple icmp loop
#!/bin/bash
# simple icmp loop
while true
do
ping -w2 -s 1550 $1 > /dev/null
if [ $? -ne 0 ]:then
echo "--- icmp request failed -- $(date) ---" >> /var/log/icmp.log
fi
done < IPLIST
@ovntatar
ovntatar / telnet.sh
Last active December 31, 2015 15:19
# simple cisco equipment - telnet client
#!/bin/bash
# simple cisco equipment - telnet client - required IpList and commands files
echo "==============================="
echo " Please enter you pass! "
echo "==============================="
read -s -p "password: " pw
printf "%b" "\n"
cmd=`cat commands`
@ovntatar
ovntatar / cmp.sh
Created December 17, 2013 14:47
Compare lines in the same file
#!/bin/bash
#Compare lines in the same file
while read A
do
read B
((i+=2))
[ "$A" != "$B" ] && echo "$A == $B Lines $((i-1)) and $i are different"
done < file1.txt
@ovntatar
ovntatar / ShellSnippets.sh
Last active March 24, 2023 07:38
Shell Snippets
#!/bin/bash
#run task sequential
time for i in `seq 1 5`;do sleep 1; done
#run task in parallel
time for i in `seq 1 5`;do sleep 1 & done ; wait
@ovntatar
ovntatar / Snippets.awk
Created December 17, 2013 14:54
AWK Snippets
#SED If a line begins with an [A-Z], append it to the previous line
$cat File
\z No
True at end of string only.
\Z No
True at end of string or before optional newline.
$sed -e :a -e '$!N;s/\n[A-Z]//;ta' -e 'P;D' File
@ovntatar
ovntatar / getModulePath.pl
Created January 9, 2014 13:53
Where is my Perl module installed?
perl -MGitHub::Jobs -e 'print $INC{"GitHub/Jobs.pm"}' or perldoc -l GitHub::Jobs
@ovntatar
ovntatar / startPerlInteractive.pl
Created January 9, 2014 13:54
Perl Interactive console
perl -d -e 1
@ovntatar
ovntatar / IsParamValueInt.pm
Created January 16, 2014 21:42
Check if parameter value is integer
package WWW::XXXX;
use Scalar::Util qw(looks_like_number);
use Moo;
has number => (
is => 'rw',
isa => sub { die "$_[0] is not int" unless looks_like_number $_[0] },
);
@ovntatar
ovntatar / get_Http_Response_code.pm
Created January 17, 2014 08:11
Check Website with http get request
package My::UserAgent
use Mojo::UserAgent;
use Moo;
has _ua => (
is => 'ro',
lazy => 1,
init_arg => 0,
default => sub {