Skip to content

Instantly share code, notes, and snippets.

View renatocron's full-sized avatar

Renato Santos renatocron

  • eokoe
  • Sao Paulo, Brazil
View GitHub Profile
SELECT
p.name,
c.id as cliente_id,
coalesce(cp.value, p.initial_value) as value
FROM preferences p,
clientes c
LEFT JOIN clientes_preferences cp ON cp.cliente_id = c.id AND cp.preference_id = c.id
where c.id=180 and p.name='NOTIFY_COMMENTS_POSTS_CREATED';
/*
@renatocron
renatocron / mojo.pl
Created September 24, 2020 23:30
mojo-pretty-user-agent
package Mojo::Transaction::Role::PrettyDebug {
use Mojo::Base -role;
use Mojo::Util 'term_escape';
use DDP;
use constant PRETTY => $ENV{TRACE} || $ENV{MOJO_CLIENT_PRETTY_DEBUG} || 0;
after client_read => sub {
my ($self, $chunk) = @_;
my $url = $self->req->url->to_abs;
$t->get_ok(
'/me/audios/' . $event_id,
{'x-api-key' => $session}
)->status_is(200)->json_has('/audios/0/waveform', 'has waveform')->json_has('/audios/0/bytes', 'row 0 has bytes')
->json_is('/audios/0/id', $audio_1->id, 'row 0 is the right id')
->json_is('/audios/1/id', $audio_2_dup->id, 'row 1 is the right id')
->json_is('/audios/0/event_sequence', 1, 'row 0 is the right sequence')
->json_is('/audios/1/event_sequence', 2, 'row 1 is the right sequence')
->json_is('/audios/2', undef, 'row 2 does not exists')
->json_is('/audios/0/audio_duration', '16s', 'row 0 duration')
package TouchBase::Schema::ResultSet::Voucher;
use common::sense;
use Moose;
use namespace::autoclean;
extends 'DBIx::Class::ResultSet';
with 'TouchBase::Role::Verification';
with 'TouchBase::Role::Verification::TransactionalActions::DBIC';
with 'TouchBase::Schema::Role::ResultsetFind';
package TouchBase::Schema::ResultSet::Voucher;
use common::sense;
use Moose;
use namespace::autoclean;
extends 'DBIx::Class::ResultSet';
with 'TouchBase::Role::Verification';
with 'TouchBase::Role::Verification::TransactionalActions::DBIC';
with 'TouchBase::Schema::Role::ResultsetFind';
use strict;
use warnings;
use Benchmark qw/timethese cmpthese :hireswallclock/;
use Redis;
use Redis::hiredis;
my $r2 = Redis->new;
my $r = Redis::hiredis->new();
$r->connect( '127.0.0.1', 6379 );
sub test_callback {
my $promise = Mojo::Promise->new();
my $req = Mojo::Message::Request->new;
my $id = Mojo::IOLoop->server(
{ address => '127.0.0.1' } => sub {
my ( $loop, $stream ) = @_;
$stream->on(
#!/usr/bin/env perl
use strict;
use Mojo::Promise;
use Mojo::IOLoop::Subprocess;
use Mojo::UserAgent;
my $subprocess = Mojo::IOLoop::Subprocess->new;
$subprocess->run(
sub {
my $subprocess = shift;
package MojoX::InsistentPromise;
use strict;
use Carp;
use Mojo::IOLoop;
use Mojo::Promise;
my @retry_timing = (0, 0.5, 1, 3, 7, 13, 21, 34, 55, 60, 120);
use Scalar::Util 'weaken';
#!/usr/bin/env perl
use common::sense;
use DDP;
use Mojo::Promise;
use Mojo::IOLoop::Subprocess;
use Mojo::UserAgent;
my $subprocess = Mojo::IOLoop::Subprocess->new;
$subprocess->run(
sub {