This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| perl -MGitHub::Jobs -e 'print $INC{"GitHub/Jobs.pm"}' or perldoc -l GitHub::Jobs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| perl -d -e 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] }, | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package My::UserAgent | |
| use Mojo::UserAgent; | |
| use Moo; | |
| has _ua => ( | |
| is => 'ro', | |
| lazy => 1, | |
| init_arg => 0, | |
| default => sub { |