Skip to content

Instantly share code, notes, and snippets.

View nanis's full-sized avatar

A. Sinan Unur nanis

View GitHub Profile
@nanis
nanis / download-tpp.pl
Last active November 8, 2015 18:06
A quick'n'dirty Perl script to download the entire TPP and combine it into a single PDF document
#!/usr/bin/env perl
=for comment
Office of the Unites States Trade Representative released the full text of the
Trans-Pacific Partnership trade agreement on November 5, 2015. For some reason,
it was released in 239 individual PDF documents, instead of a single file.
ToC at https://ustr.gov/trade-agreements/free-trade-agreements/trans-pacific-partnership/tpp-full-text
@nanis
nanis / random_real.c
Created August 14, 2015 21:12
Originally at http://mumble.net/~campbell/tmp/random_real.c Saved here for reference (as allowed by the copyright statement)
/*
* Uniform random floats: How to generate a double-precision
* floating-point number in [0, 1] uniformly at random given a uniform
* random source of bits.
*
* Copyright (c) 2014, Taylor R Campbell
*
* Verbatim copying and distribution of this entire article are
* permitted worldwide, without royalty, in any medium, provided
* this notice, and the copyright notice, are preserved.
@nanis
nanis / stefik.quorum
Created June 12, 2015 15:48
See http://www.nu42.com/2015/06/quorum-creators-cannot-write-quorum.html This is the Quorum code in Stefik et al. 2011 and Stefik & Siebert 2013//
/*
http://www.nu42.com/2015/06/quorum-creators-cannot-write-quorum.html
Quorum is a programming language created by Stefik et al. In a 2011 paper, the authors infamously proclaimed:
Results showed that while Quorum users were afforded significantly
greater accuracy compared to those using Perl and Randomo, Perl users
were unable to write programs more accurately than those using a
language designed by chance.
@nanis
nanis / gugu
Last active August 29, 2015 14:22
#!/usr/bin/env perl
use v5.20;
=for commentary
This is my second entry in brian d foy's "Be Better than Quorum" challenge
See L<http://www.learning-perl.com/2015/06/learning-perl-challenge-be-better-than-quorum/>
I went for baroqueness with this one.
@nanis
nanis / ququ
Created June 4, 2015 15:35
My first entry in brian d foy's "Be better than Quorum challange"
#!/usr/bin/env perl
use v5.20;
=for commentary
See L<http://www.learning-perl.com/2015/06/learning-perl-challenge-be-better-than-quorum/>
I know there will be reasonable entries, so here's one for variety ;-)
-- Sinan
@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);