Skip to content

Instantly share code, notes, and snippets.

use ojo;
my $s = oO( q{http://}
. join(q{:}, @ARGV)
. q{@api.twitter.com/1/statuses/friends_timeline.json}
)->json;
foreach (@$s) {
print Oo($_->{user}{screen_name}, q{: }, $_->{text});
my @links =
map { $_ =~ s/\.$//; $_ }
@dotandimet
dotandimet / gist:643649
Created October 24, 2010 16:21
why does decode hang in perl -d ?
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::JSON;
my $str = qq{[
{
"text" : "
@dotandimet
dotandimet / gist:832561
Created February 17, 2011 20:09
mojo response streaming with redirection
#!/usr/bin/env perl
use warnings;
use strict;
use Test::More;
use Test::Mojo;
use Mojolicious::Lite;
post '/foo' => sub {
my $self = shift;
@dotandimet
dotandimet / gist:857366
Created March 6, 2011 15:51
test for Mojo::Loader arbitrary code execution
#!/usr/bin/env perl
use warnings;
use strict;
# Mojo::Loader executes arbitray code - via vti
# perl -MMojo::Loader -e 'Mojo::Loader->load(qq{Mojo::Loader;print "nice feature!"})'
# http://twitter.com/#!/vtivti/status/44408695613952000
use Test::More tests => 2;
@dotandimet
dotandimet / capture.fcgi
Created August 21, 2011 07:29
Trying to use FCGI and output capture together
#!/usr/bin/perl
use warnings;
use strict;
use CGI::Fast;
use Capture::Tiny qw(capture);
use IPC::Run3 qw(run3);
my $cmd = 'date';
@dotandimet
dotandimet / gist:1164933
Created August 23, 2011 11:55
Trying to understand DBIx::Class::CDBICompat
package Unity::DBI;
use base qw/DBIx::Class::CDBICompat/;
package Unity::Cluster;
use base 'Unity::DBI';
__PACKAGE__->table('u_clusters');
__PACKAGE__->table_alias('u_clusters');
__PACKAGE__->sequence('obj_id');
__PACKAGE__->columns(Primary => qw/id/);
@dotandimet
dotandimet / json_vs_mojo_json_true_false.t
Created October 25, 2012 15:20
tests to compare how JSON and Mojo::JSON generate true and false values in JSON
#!/usr/bin/env perl
use JSON;
use Mojo::JSON;
use Test::More tests => 6;
my $j = JSON->new;
my $mj = Mojo::JSON->new;
@dotandimet
dotandimet / gist:5496319
Created May 1, 2013 16:21
jQuery hack to switch fargo outline item direction if it contains hebrew text.
$('.concord-text')
.each(function(t){
if ($(this).text().match(/[אבגדהוזחטיכלמנסעפצקרשת]/)) {
$(this).attr('dir', 'rtl');
};
});
@dotandimet
dotandimet / gist:6595595
Created September 17, 2013 15:05
Tie::LevelDB and binary files
use File::Slurp;
use Tie::LevelDB;
my $file_name = shift; # give the script an image file argument - preferably a PNG.
my $db = new Tie::LevelDB::DB("db/");
my $buffer;
read_file( $file_name, binmode => ':raw', buf_ref => \$buffer );
@dotandimet
dotandimet / gist:7417509
Created November 11, 2013 18:05
Bug that drove me nuts, a reference to an array in the callback prevents process_feeds from emptying it...
# can you spot the bug below?
sub load_and_go {
my $self = shift;
$self->render_later();
my $subs = $self->backend->feeds->find({xmlUrl => $self->param('src')})->all;
$self->process_feeds(
$subs,
sub {
$self->redirect_to(