Skip to content

Instantly share code, notes, and snippets.

View nanis's full-sized avatar

A. Sinan Unur nanis

View GitHub Profile
@nanis
nanis / fixlt.pl
Created March 8, 2015 16:43
Fix malformed XML using Perl's XML::Parser
#!/usr/bin/env perl
=for purpose
See http://www.nu42.com/2015/03/fix-malformed-xml-with-perl-xml-parser.html
for motivation. This script is the simplest possible implementation of an
idea. Not tested. Likely to contain bugs ;-)
=cut
@nanis
nanis / ie10screenshot.pl
Last active August 29, 2015 14:10
Revised script for taking Internet Explorer screenshots using Perl and Win32::OLE
#!/usr/bin/env perl
use 5.020; # hey, why not?
use warnings;
use Const::Fast;
use Win32::GuiTest qw(
GetForegroundWindow
SetForegroundWindow
GetScreenRes
@nanis
nanis / iescreenshot.pl
Created December 5, 2014 14:08
Internet Explorer screenshot using Perl and Win32::OLE
#!/usr/bin/env perl
use strict; use warnings;
use feature 'say';
use Const::Fast;
use Imager;
use Imager::Screenshot qw( screenshot );
use Win32::GuiTest qw( SetForegroundWindow );
use Win32::OLE qw(EVENTS valof);
@nanis
nanis / mplatforms.pl
Last active August 29, 2015 14:05
Extract information from CPANTesters' Platforms By YEAR/MONTH
#!/usr/bin/env perl
# This is a very quick and dirty script to parse information from the page
#
# http://stats.cpantesters.org/mplatforms.html
#
# This one works on a locally downloaded copy, the regex patterns used are
# the first one's that popped into my head.
#
# I hereby release this code snippet to the public domain.
@nanis
nanis / imgxform.pl
Created July 11, 2014 00:22
Fun with image transformations in Perl: American Gothic in the palette of Mona Lisa: Rearrange the pixels
#!/usr/bin/env perl
use 5.020; # just because
use strict;
use warnings;
use Const::Fast;
use GD;
GD::Image->trueColor(1);
@nanis
nanis / melodious-castlet.pl
Last active December 22, 2015 02:08
Pick a project name by combining two randomly picked words from a word list. Usage: `melodious-castlet.pl /usr/share/dict/words`
#!/usr/bin/env perl
# Copyright (C) 2013 A. Sinan Unur
# http://www.perlfoundation.org/artistic_license_2_0
use 5.012;
use strict;
use warnings;
use warnings qw(FATAL utf8);
use open qw(:std :utf8);
@nanis
nanis / turbo-hipster.pl
Created May 20, 2013 17:05
Traverse a tree and put together a dependency graph (using GraphViz2) based on use/require statements and the first namespace in module files. Take into account script files with no extension and ignore possible Perl in certain files. Detects a Perl file by trying to construct a PPI::Document using that file. Replaces "::" in package names with …
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use File::Basename qw(basename);
use File::Find;
use GraphViz2;
use Log::Handler;
@nanis
nanis / chubby-wings.pl
Created May 18, 2013 17:02
Search a tree, find strings in Perl code, check if there is SQL in them, extract tables.
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use File::Find;
use PPI;
use SQL::Statement;
@nanis
nanis / irritated-gnome.pl
Last active December 17, 2015 10:59
Walk through a directory, extract modules referenced in use/require statements for each Perl file, and output information in JSON format so it can be fed to create a nice graph using d3js.
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use open qw(:std utf8);
# This is where a patched version of Module::Extract::Use lives
# The patched version adds a 'content' accessor to M::E::U::Item objects
@nanis
nanis / build-fedfun-1997-2011.pl
Created February 22, 2013 17:02
Perl source code to clean up U.S. Federal Government Payroll data from <http://www.census.gov//govs/apes/>. Currently, it ignores the Department of Homeland Security. Dollar amounts are adjusted to 2011 dollars using the CPI. Other indexes maybe more appropriate.
#!/usr/bin/env perl
# Author: A. Sinan Unur
# Copyright (C) 2013
# License: This is free software. You can use it under the terms
# of Artistic License 2.0 <http://opensource.org/licenses/Artistic-2.0>
# In particular:
# (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT
# HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A