Skip to content

Instantly share code, notes, and snippets.

View leejo's full-sized avatar
🏂

Lee J leejo

🏂
View GitHub Profile
if [type] == "syslog" {
grok {
match => {
message => "%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST:hostname} (%{SYSLOGHOST:remote} )?%{DATA:program}(?:\[%{POSINT:pid}\])?: (%{YEAR}/%{MONTHNUM}/%{MONTHDAY} %{TIME} )?%{GREEDYDATA:message_no_ts}"
}
add_tag => [ "%{[tag]}","syslog","%{[program]}" ]
}
date {
# we use the value of timestamp in the @timestamp field
match => [ "timestamp","MMM dd HH:mm:ss","MMM d HH:mm:ss" ]
I have bigballofmud.pl that calls (requires) many littleballsofmud.pl,
none of which use strict and have many globals (there is no way i can
add use strict to any of these... yet). I want to add a new littleballofmud.pl,
but of course want to use strict. I still need to access the global
vars from bigballofmud.pl (and again, can't modify it to pass args)
but want littleballofmud.pl to be testable outside of bigballofmud.pl
under full strict *not* using globals.
My solution is this in littleballofmud.pl:
@leejo
leejo / gist:b24ddb077b8b226569f7
Created September 23, 2014 12:02
Mojolicious TT Renderer Config
116 my $renderer = Mojolicious::Plugin::TtRenderer::Engine->build(
117 mojo => $self,
118 template_options => {
119 INTERPOLATE => 0,
120 RELATIVE => 1,
121 ABSOLUTE => 1,
122 COMPILE_DIR => $compile_dir,
123 COMPILE_EXT => $compile_ext,
124 INCLUDE_PATH => [ qw/
125 templates
@leejo
leejo / dnytp5.21.8
Created January 21, 2015 11:21
cpanm log output with Devel::NYTProf (perl 5.21.8)
cpanm (App::cpanminus) 1.7001 on perl 5.021008 built for darwin-2level
Work directory is /Users/leejohnson/.cpanm/work/1421839145.42553
You have make /usr/bin/make
You have /opt/local/bin/wget
You have /usr/bin/tar: bsdtar 2.8.3 - libarchive 2.8.3
You have /usr/bin/unzip
Searching Devel::NYTProf on cpanmetadb ...
--> Working on Devel::NYTProf
Fetching http://www.cpan.org/authors/id/T/TI/TIMB/Devel-NYTProf-5.06.tar.gz
-> OK
@leejo
leejo / bof
Created February 5, 2015 13:41
bug or feature
[leejohnson@lees-macbook-air J0 C10206 14:40:37 * lee/make_this_work]
*/Users/leejohnson/working/mojolicious-plugin-oauth2-server/examples > perl -E 'my @array = (); say shift(@array)'
[leejohnson@lees-macbook-air J0 C10207 14:41:36 * lee/make_this_work]
*/Users/leejohnson/working/mojolicious-plugin-oauth2-server/examples > perl -E 'my @array = (); say shift(())'
Not an ARRAY reference at -e line 1.
@leejo
leejo / moo_coerce
Last active August 29, 2015 14:24
Trying to convert a MySQL date / timestamp to a DateTime object with Moo + Type::Tiny. Failing. Badly. Any clues?
#!perl
use strict;
use warnings;
package Type::Tester;
use Moo;
use Type::Library -base, -declare => qw/DateTime/;
@leejo
leejo / mojo_swagger_authorization.markdown
Last active August 29, 2015 14:27
Mojo + Swagger2 + Authorization

In swagger.yaml - note use of x-mojo-privilege key under the route method, leave this blank for routes that don't require a privilege to access:

paths:
    /foo:
        get:
            x-mojo-controller: "MyApp::API::Foo"
            x-mojo-around-action: "MyApp::API::check_api_priv"
            x-mojo-privilege: "get:foo"
            operationId: get
@leejo
leejo / example.pl
Last active November 5, 2015 10:29
routes using a root
#!/usr/bin/env perl
# in reality this would be in a separate file
package ExampleApp;
# automatically enables "strict", "warnings", "utf8" and perl 5.10 features
use Mojo::Base qw( Mojolicious );
sub startup {
my ( $self ) = @_;
@leejo
leejo / route_issue
Last active February 1, 2016 13:52
Route ordering change
We have two routes, defined in this order:
```
$r->route('/cause/:cause_id/campaigns/:type/:paginate/:page/',
type=>[qw(active archived)],
paginate => [qw(page)],
cause_id => qr/\d+/,
page => qr/\d+/)
->to(
paginate => [qw(page)])->to(
@leejo
leejo / route_query
Created February 2, 2016 08:51
Route ordering with default stash values
This is the minimal test case i could reduce to showing the "issue"
it seems the route ordering doesn't matter in all cases until we start
adding default stash values in the `->to` block. i don't know if this
is known behaviour, but it caught us out recently and something to be
aware of:
```perl
#!/usr/bin/env perl