Skip to content

Instantly share code, notes, and snippets.

View opendevnet's full-sized avatar

Open Development Network opendevnet

  • Ottawa, Canada
View GitHub Profile
#!/usr/bin/env perl
use v5.22;
use experimental qw/ refaliasing postderef / ;
use Pegex;
my $data = do { local $/; <DATA> } ;
my $grammar = q[
%grammar thing
%version 0.0.1
# Converting to both perl5 and perl6 to see differences and similarities.
# Note that if you have a perl > 5.14.* the -E switch enables
# say, unicode, etc. which makes perl5 a bit more like perl6
# for oneliners anyway. Is using the -p switch cheating?
#------------------------------------------------------------
# 1. Print the third column of the line in a file.
# a.
perl6 -n -e '.split(" ")[2].say' file.txt
@opendevnet
opendevnet / ip2country.pl
Last active December 17, 2015 04:28
Find country of origin for systems wanting access to your shell accounts.
#!/usr/bin/env perl
use 5.14.0 ;
use Geo::IP::PurePerl;
use autodie ;
my $gi = Geo::IP::PurePerl->new(GEOIP_STANDARD);
# /tmp/ips.txt is created from firewall
# rules and/or /var/log/auth.log with e.g.
sub escape ($str) {
# Puts a slash before non-alphanumeric characters
S:g[<-alpha -digit>] = "\\$/" given $str
}
say escape 'foo#bar?'; # foo\#bar\?
{
sub escape ($str) {
# Writes each non-alphanumeric character in its hexadecimal escape
class HangpersonGame
def initialize(word)
@word = word
@guesses = ""
@wrong_guesses = ""
end
attr_accessor :word, :guesses, :wrong_guesses
package Surfz ;
use Function::Parameters ;
use base 'Sub::Attributes';
fun new :ClassMethod {
my $class = shift;
my $self = {};
bless $self, $class;
return $self;