Skip to content

Instantly share code, notes, and snippets.

View ovntatar's full-sized avatar

Ovidiu N. Tatar ovntatar

View GitHub Profile
@ovntatar
ovntatar / get_arguments.pl
Last active December 17, 2015 01:59
Hash as subroutine argument!
#!/usr/bin/env perl
sub getArguments { ref( $_[0] ) ? shift() : ( @_ % 2 ) ? {} : {@_}; };
@ovntatar
ovntatar / get_cpanminus.sh
Last active December 17, 2015 01:59
get cpanminus
#!/bin/bash
curl https://raw.github.com/miyagawa/cpanminus/master/cpanm > cpanm
mv cpanm ~/
chmod 755 ~/cpanm
echo "PERL5LIB=~/perl5/lib/perl5/" >> ~/.bashrc
echo "export PERL5LIB" >> ~/.bashrc
source ~/.bashrc
@ovntatar
ovntatar / tmpl.sh
Created May 7, 2013 13:19
Bash template
#!/bin/bash
#
#
# SCRIPT: $0
# AUTHOR: ovntatar
# DATE: $date
#
# PURPOSE: The script bash template
#
#
@ovntatar
ovntatar / replace_string_recursively.sh
Created May 7, 2013 14:34
Replace a string in all the files recursively!
#!/bin/bash
find . -type f | xargs perl -pi -e 's/OLD_VALUES/NEW_VALUE/g'
@ovntatar
ovntatar / GetModuleVersion
Created May 13, 2013 20:15
Get Module Version
perl -MReadonly -e 'print "$Readonly::VERSION\n"'
@ovntatar
ovntatar / CheckMD5Sum.pl
Last active December 31, 2015 12:19
Check MD5 sum recursive
#!perl
use strict;
use warnings;
use File::Find;
use Digest::MD5;
@ARGV=grep { -d or !warn "`$_': not a directory!\n" } @ARGV;
die "Usage: $0 <dir> [<dirs>]" unless @ARGV;
@ovntatar
ovntatar / Replace.pl
Created December 16, 2013 11:20
Replace String
#!perl -s -i.bak -wpl
# Usage: change_file -old='old' -new='new' [f1 f2 ...]
s/$old/$new/g;
@ovntatar
ovntatar / lwp_callback.pl
Created December 16, 2013 11:31
LWP Callback
#!perl
use warnings;
use strict;
$|++;
use DDP;
use LWP;
@ovntatar
ovntatar / Counting_words.pl
Created December 16, 2013 15:14
Counting words in a file
#!perl
# perl script.pl < file.txt
use warnings;
use strict;
my %seen=();
while(<>) {
@ovntatar
ovntatar / Progressbar.sh
Created December 16, 2013 15:45
Shell progressbar ..
#!/bin/bash
searchfor="Hallo" # something to search for
tempfile="search.log" # temporary logfile
echo -n "Searching for $searchfor. "
grep -rl $searchfor / 2>/dev/null 1>>$tempfile &