Skip to content

Instantly share code, notes, and snippets.

@dynax60
dynax60 / cisco-backup.pl
Created May 6, 2010 04:24
Cisco backup
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use YAML;
use FindBin qw/$Bin/;
use Net::Telnet::Cisco;
++$|;
umask 012;
$0 =~ s{.*/}{};
@dynax60
dynax60 / genpas.pl
Created June 18, 2010 09:43
Password generation tool
#!/usr/bin/perl
use common::sense;
use Text::Password::Pronounceable;
printf "%s\n", Text::Password::Pronounceable->generate(6,10);
@dynax60
dynax60 / gvrpad.c
Created June 18, 2010 12:14
gvrpad - GVRP Announcement Daemon. http://www.knossos.net.nz/gvrpad.html
--- gvrpad.c 2007-06-12 04:28:04.000000000 +0400
+++ gvrpad.c.orig 2010-06-21 12:21:54.000000000 +0400
@@ -417,6 +417,7 @@
int exclude = 0;
int interval = 0;
int leaveint = 0;
+ ether_addr addr;
FILE *f;
/*
@dynax60
dynax60 / MyMail.pm
Created June 23, 2010 11:06
Simple mail sender on perl :)
package MyMail;
use common::sense;
use MIME::Lite;
use MIME::Words qw(:all);
use Data::Dumper;
use Carp qw(croak);
sub _defaults {
@dynax60
dynax60 / guess.pl
Created July 7, 2010 06:05
Mikrotik and Nano stations detector
#!/usr/bin/perl
use Mojo::Client;
BEGIN {
my %nano;
my %mktk;
my %failed;
}
my $client = Mojo::Client->new;
any '/fast-ping' => sub {
my $self = shift;
my $request = $self->req->json || return $self->render_json( { 'status' => 'Request error' } );
my $remote_addr = $self->tx->remote_address;
app->log->info("$remote_addr requested ".Dumper($request));
my $prefix = $request->{'prefix'};
return $self->render_json( { 'status' => 'Have no network prefix in request, nothing to do!' } ) unless $prefix;
@dynax60
dynax60 / arping.pl
Created August 9, 2010 09:04
Non-blocked arping sample using POE
#!/usr/bin/perl
use strict;
use warnings;
use POE qw(Wheel::Run Filter::Reference);
sub MAX_CONCURRENT_TASKS () { 25 }
use Net::Netmask;
use Data::Dumper;
#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::ByteStream 'b';
use Mojo::JSON;
use utf8;
...
our $dbh = DBI->connect("dbi:mysql:dbname=cli;host=localhost",
@dynax60
dynax60 / gist:544979
Created August 23, 2010 07:12
Decode bytestream on $dbh->selectall_arrayref result
use Mojo::ByteStream 'b';
...
$rows = $dbh->selectall_arrayref(q{ .. });
# Decode bytestream to string for each item in arrays
grep { grep { $_ = b($_)->decode('UTF-8') } @$_ } grep { $_ } @$rows ;
@dynax60
dynax60 / gist:547379
Created August 24, 2010 11:13
Mysql client charset
#!/usr/bin/perl
use DBI;
our $dbh = DBI->connect("dbi:mysql:dbname=mydb;host=localhost",
'user', 'pass',
{ PrintError => 0, RaiseError => 1, mysql_enable_utf8 => 1 });
for (@{ $dbh->selectall_arrayref(q{
SHOW VARIABLES LIKE 'character\_set\_%' }) } ) {