Skip to content

Instantly share code, notes, and snippets.

View ruz's full-sized avatar

Ruslan Zakirov ruz

View GitHub Profile
my $tmp = $heads{$hc}{subheads};
foreach my $sc (
sort { $tmp->{$a}{sort} <=> $tmp->{$b}{sort} } keys %$tmp
) {
next unless scalar @{$tmp->{$sc}{data}};
subset Direction of Str where any(@directions) {
has %!abbreviations = ...;
has %!opposite = ...;
method opposite {...}
}
@ruz
ruz / Templates.pm
Created August 21, 2011 00:03
Devel::Cover skipping nested anon subs
package Templates;
my $code = sub { 'foo' };
*simple = sub { return $code->(@_) };
1;
@ruz
ruz / gist:1356744
Created November 11, 2011 00:29
Postgres data correlation problem
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect('dbi:Pg:dbname=test', 'postgres', undef, { RaiseError => 1 });
$dbh->do(q{DROP TABLE IF EXISTS test});
$dbh->do(q{
CREATE TABLE test (
id INT NOT NULL PRIMARY KEY,
use strict;
use warnings;
package Bar;
use MyBase;
1;
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 8f6e190..f1050c2 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1069,6 +1069,9 @@ of the From (evaluated in order of Reply-To:, From:, Sender)
sub ParseSenderAddressFromHead {
my $head = shift;
+ use Data::Dumper;
+ $RT::Logger->error( Dumper $head );
use 5.010;
use strict;
use warnings;
my $rec = rec();
$rec->alternative( 'XX', undef, 2 );
while (1) {
say $rec->earleme_complete;
say $rec->exhausted? "exhausted" : "please continue";
}
use 5.014;
use strict;
use warnings;
use Marpa::R2;
use MarpaX::Repa::Lexer;
use MarpaX::Repa::Actions;
my %RE;
$RE{'WSP'} = qr{[ \t]};
@ruz
ruz / gtrans2.pl
Created September 5, 2013 21:35
#!/usr/bin/env perl
# By: Jeremiah LaRocco, Nikolay Mishin (refactoring)
# Use translate.google.com to translate between languages.
# Sample run:
#gtrans.pl --from en --to ru --text "This is a test"
use Modern::Perl;
use LWP::UserAgent;
use Getopt::Long;
@ruz
ruz / 0_reuse_code.js
Created December 3, 2013 12:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console