This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple commandline twitter script. | |
# Reads a line from STDIN and updates twitter. | |
# This doesn't work anymore, because of OAuth. | |
# Net::Twitter does support OAuth so it could be rewitten to make it work | |
# Created by Peter Stuifzand <[email protected]> | |
use strict; | |
use warnings; | |
use Net::Twitter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Replace many spaces with one in Vim | |
" With help from Al: http://stackoverflow.com/questions/1228100/substituting-zero-width-match-in-vim-script | |
function JustOneSpace() | |
" Get the current contents of the current line | |
let current_line = getline(".") | |
" Get the current cursor position | |
let cursor_position = getpos(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127.0.0.1:5000 | |
Start Time: Wed Apr 13 2011 00:20:59 GMT+0200 (CEST) | |
t=1302646859860 [st=0] +SOCKET_ALIVE [dt=4] | |
--> source_dependency = {"id":210,"type":4} | |
t=1302646859860 [st=0] +TCP_CONNECT [dt=0] | |
--> address_list = ["127.0.0.1:5000"] | |
t=1302646859860 [st=0] TCP_CONNECT_ATTEMPT [dt=0] | |
--> address = "127.0.0.1:5000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Data::Dumper; | |
use Parse::RecDescent; | |
$Parse::RecDescent::skip = ''; | |
my $grammar = q{ | |
line: ip ws '-' ws user ws datetime ws request ws status ws responsesize | |
ws referrer ws useragent "\n" | |
{ $return = { | |
ip => $item[1], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# Name: logtail.pl | |
# Description Shows the HTTP status of the last few requests in the logfile | |
# Usage: tail -f apachelogfile.log | perl logtail.pl | |
# Date: Wed Apr 13 16:31:35 CEST 2011 | |
# Author: Peter Stuifzand | |
# License: GPL3+ | |
use strict; | |
use Parse::AccessLogEntry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.10.1; | |
use strict; | |
use Marpa::XS; | |
my $grammar = Marpa::XS::Grammar->new({ | |
actions => 'Action', | |
start => 'Parser', | |
rules => [ | |
{ lhs => 'Parser', rhs => [ qw/Expression/ ], action => 'Parser' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use 5.10.1; | |
use strict; | |
use File::Slurp 'read_file'; | |
use Marpa::XS; | |
my %tokens = ( | |
AT => qr/^\@/, | |
LP => qr/^\(/, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Marpa::XS; | |
use Data::Dumper; | |
my $grammar = Marpa::XS::Grammar->new( | |
{ start => 'Expression', | |
actions => 'My_Actions', | |
rules => [ | |
# This rebuilds the tree | |
{ lhs => 'Expression', rhs => [qw/Term/], action => 'Return_0' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.14.2; | |
use List::Util 'sum'; | |
# power a n = a if n == 1 | |
# power a n = power (power a 2) (n/2) if n is even | |
# power a n = (power (power a 2) (n/2)) * a if n is odd | |
sub power { | |
my ($op, $a, $n) = @_; | |
if ($n == 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Marpa::XS; | |
use MarpaX::Simple::Lexer; | |
use IO::String; | |
my $grammar = Marpa::XS::Grammar->new( { | |
start => 'Parser', | |
rules => [ | |
[ 'Parser' => [ 'X' ] ], | |
], | |
terminals => [qw/X/], |
OlderNewer