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
#!/bin/sh | |
in_files="--directory=../lib --directory=../root/admin --directory=../root/public" | |
out_file="../lib/MyApp/I18N/messages.pot" | |
po_dir="../lib/MyApp/I18N" | |
msg_up() { | |
po_file=$po_dir/$1.po | |
if [ -f $po_file ] | |
then |
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
get '/post/:slug' => sub { | |
my $self = shift; | |
my $post = $self->db->posts->find_by_slug( $self->stash('slug') ); | |
return $self->render_not_found unless $post; | |
# ... | |
} |
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/env perl | |
use Mojolicious::Lite; | |
get '/divide/:dividend/by/:divisor' => sub { | |
my $self = shift; | |
my $dividend = $self->param('dividend'); | |
my $divisor = $self->param('divisor'); | |
return $self->render_not_found | |
unless $dividend =~ /^\d+$/ && $divisor =~ /^\d+$/; |
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
my $delay = Mojo::IOLoop->delay; | |
for my $url ('mojolicio.us', 'cpan.org') { | |
$delay->begin; | |
$ua->get($url => sub { | |
my ($ua, $tx) = @_; | |
$delay->end( | |
$tx->res->dom->at('title')->text | |
); | |
}); | |
} |
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
package My::Search::Product; | |
use Elastic::Doc; | |
has 'name' => ( | |
is => 'rw', | |
isa => 'Str', | |
boost => 3, | |
analyzer => 'my_spanish', | |
); |
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
my $results = $products | |
->queryb([map {$_=>$query} qw/name brand brands tags/]) | |
->filterb( status => 'avail' ) | |
->search; |
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
my $results = $products->queryb({ | |
-qs => { | |
query => $query, | |
fields => ['name','brands','tags','variant'], | |
default_operator => 'AND', | |
fuzzy_min_sim => 0.7, | |
fuzzy_prefix_length => 2, | |
lenient => 1, | |
#minimum_should_match => 3, | |
} |
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
has 'name' => ( | |
is => 'rw', | |
isa => 'Str', | |
boost => 5, | |
analyzer => 'my_clean', | |
multi => {. | |
stem => { boost => 2, analyzer => 'my_spanish' }, | |
sound => { boost => 1, analyzer => 'sound_like' }, | |
} | |
); |
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
====== | |
Query: | |
====== | |
{ | |
"fields" : [ | |
"_parent", | |
"_routing", | |
"_source" | |
], | |
"from" : 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
{ // part of _source | |
price: { | |
_mean: 8.05, | |
carrefour: { | |
_mean: 8.05, | |
4ff30e2fc27e955902000009: { | |
p: 8.05 | |
}, | |
4ff30e2fc27e955902000008: { | |
p: 8.05 |