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
# $self->query_to_where({name => "Bruce"}, {name => "eq"}) => ["name = ?"], ["Bruce"] | |
# $self->query_to_where({name => "Bruce"}, {name => "like"}) => ["name LIKE '%?%'"], ["Bruce"] | |
# $self->query_to_where({age => ">=42"}, {age => "num"}) => ["name >= ?"], [42] | |
sub query_to_where { | |
my ($self, $q, $rules) = @_; | |
my (@where, @bind); | |
for my $col (sort keys %$rules) { | |
if (!length $q->{$col} // '') { | |
1; # next |
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 Mojo::Cursor; | |
=head1 NAME | |
Mojo::Cursor - General purpose async iterator | |
=head1 DESCRIPTION | |
L<Mojo::Cursor> is a class for instantiating an iterator object. |
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
(function() { | |
/* | |
var swagger = new SwaggerClient({swagger: "2.0", info: {}, paths: {}}); | |
swagger.listPets({limit: 10}, function(err, xhr) { | |
console.log(xhr.code, xhr.body); | |
}); | |
*/ | |
window.SwaggerClient = function(spec) { | |
var self = this; |
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/perl | |
# Usage: echo -en "1.1.0.1\n127.0.0.1\n" | sudo /usr/bin/perl stdinping | |
# A lot of this code is mostly copy/paste/modify from Net::Ping | |
BEGIN { | |
# Make sure we don't load code that is not owned by root | |
$^X eq "/usr/bin/perl" or die "Invalid perl: $^X\n"; | |
my @perl_stat = stat $^X; | |
unshift @INC, sub { | |
my ($code, $module) = @_; |
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 Mojo::IOLoop::Tail; | |
use Mojo::Base "Mojo::IOLoop::Stream"; | |
has check_timeout => 0.01; | |
sub close { | |
my $self = shift; | |
return unless my $handle = $self->{handle}; | |
seek $handle, 0, 1; |
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
# See also | |
# http://www.perlmonks.org/bare/?node_id=881003 | |
# http://www.freebsd.org/cgi/man.cgi?query=getpeereid | |
use strict; | |
use warnings; | |
use IO::Socket::UNIX; | |
use Socket qw( SO_PEERCRED SOL_SOCKET ); | |
if (@ARGV) { | |
IO::Socket::UNIX->new(Peer => $ARGV[0], Type => SOCK_STREAM, Timeout => 10) or die $@; |
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
plugin 'OAuth2', { | |
google => { | |
key => 'public app id from google', | |
secret => 'private secret from google', | |
}, | |
}; |
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
Object.prototype.emit = function(name, d) { | |
this.dispatchEvent(new CustomEvent(name, { detail: d })); | |
return this; | |
}; | |
Object.prototype.on = function(name, cb) { | |
this.addEventListener(name, cb, false); | |
return cb; | |
}; | |
Object.prototype.once = function(name, cb) { | |
var wrapper = function() { |
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 | |
EXPRESSION=${1:-"tcp port 22"}; | |
DEVICE="wlan0"; | |
while tcpdump -p -c 1 -i $DEVICE "$EXPRESSION"; do | |
iwconfig $DEVICE power off; | |
sleep 600; | |
iwconfig $DEVICE power on; | |
done |
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
git remote update | |
git rebase origin/master | |
# no diff | |
git tag v5.17 | |
perl Makefile.PL; make manifest; make dist | |
1) make sure master is in a good state | |
2) tag release | |
3) perl Makefile.PL; make manifest; make dist | |
4) upload release, ...optional... |