Skip to content

Instantly share code, notes, and snippets.

View jberger's full-sized avatar

Joel Berger jberger

View GitHub Profile
jberger /
Last active April 30, 2024 19:30
use Mojolicious::Lite -signatures;
hook after_build_tx => sub ($tx, @) {
$tx->req->content->on(body => sub ($) {
my $url = $tx->req->url;
return unless $url->path eq '/long_ok';
app->log->debug("max message size extended for $url");
jberger /
Last active May 9, 2024 17:54
Create User Without Password
# create user with a disabled password
adduser myusername --disabled-password
# optionally login as them and create authorized_keys
# su - myusername
# mkdir --mode=0700 .ssh
# echo 'key' > .ssh/authorized_keys
# chmod 0600 .ssh/authorized_keys
# ^d
diff --git a/src/util.ts b/src/util.ts
index c6e68b3..23e9b93 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -130,6 +130,14 @@ export function decodeURIComponentSafe(value: string): string | null {
+export function defaultObject<Type>(defaultValue: Type): Record<string, Type> {
+ return new Proxy({}, {
export function defaultObject(defaultValue) {
return new Proxy({}, {
get: function(target, name) {
return target.hasOwnProperty(name) ? target[name] : defaultValue;
package Mojolicious::Plugin::RequestNegotiation;
use Mojo::Base 'Mojolicious::Plugin';
use Carp ();
sub register {
my ($plugin, $app, $conf) = @_;
$app->helper(sent => \&_sent);
$app->helper(when_sent => \&_when_sent);
use Mojo::Base -strict;
use Mojo::DOM;
my $html = q!<img src='/__swift/themes/admin_default/images/mimeico_blank.gif' valign='middle' style='position: relative; top: -1px;'> <a href=''><strong>prometheus.20200605.yml</strong></a>!;
my $dom = Mojo::DOM->new($html);
my $anchor = $dom->at('a');
my $href = $anchor->{href};
jberger / tpf_cat_statement.txt
Last active September 3, 2021 06:21
Proposed statement pausing the TPF CAT
When embarking on community moderation and when claiming the authority to mete out judgements, clear policy and procedure is
key to keep the moral authority to do so and to protect all of the parties involved.
Effective immediately, The Perl Foundation (TPF)'s Community Affairs Team (CAT) will not accept any incoming reports nor issue
any rulings until such time as:
a) a set of policies can be created to govern it
b) that policy is voted on and accepted by the TPF governing board
c) the policy, reporting procedure, and CAT board membership are clearly posted on the TPF's main website
Once this is done we hope to rebuild a sense of trust within the Perl Community and to act to keep it safe and welcoming.
use Mojo::Base -strict, -signatures;
use Mojo::UserAgent;
use Mojolicious;
my $mock = Mojolicious->new;
$mock->routes->any('/' => sub ($c) { $c->render(data => $c->req->body) });
my @content = (qw(this is a test));
use Mojo::Base -strict, -signatures;
use Mojo::UserAgent;
my @content = (qw(this is a test));
my $iterator = sub { shift @content };
# Build a normal transaction
my $ua = Mojo::UserAgent->new;
my $tx = $ua->build_tx(GET => '');
jberger / graphite
Last active September 26, 2023 15:05
A little graphite CLI tool
#!/usr/bin/env perl
use Mojo::Base -strict;
use Getopt::Long qw(:config gnu_getopt no_auto_abbrev no_ignore_case);
use Mojo::Date;
use Mojo::URL;
use Mojo::UserAgent;
use Mojo::Util 'tablify';