Skip to content

Instantly share code, notes, and snippets.

View sgnix's full-sized avatar
🟧

Stefan G. sgnix

🟧
View GitHub Profile
javascript:location.href='https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&prodversion='+(navigator.appVersion.match(/Chrome\/(\S+)/)[1])+'&x=id%'+'3D'+(document.querySelector('a[href^="https://chrome.google.com/webstore/report/"]').pathname.match(/[^\/]+\/*$/)[0])+'%'+'26installsource%'+'3Dondemand%'+'26uc';

Keybase proof

I hereby claim:

  • I am sgnix on github.
  • I am sge (https://keybase.io/sge) on keybase.
  • I have a public key whose fingerprint is A798 AAE6 09DF 1C43 D9DE ECDF A531 6999 151B 3BAC

To claim this, I am signing this object:

@sgnix
sgnix / validate.pl
Last active February 7, 2019 18:35
Oddity in Params::ValidationCompiler
use strict;
use warnings;
use Types::Standard qw/Int Str/;
use Params::ValidationCompiler qw( validation_for );
sub foo {
my ($num) = validation_for(
params => [
{ type => Str }
@sgnix
sgnix / asdf
Created February 2, 2018 19:41
Verifying my Blockstack ID is secured with the address 1GgERwbnszgZMeb4G837tMAA5aqPR49Y1V https://explorer.blockstack.org/address/1GgERwbnszgZMeb4G837tMAA5aqPR49Y1V
package Kelp::Config;
use strict;
use warnings;
use base 'Kelp';
sub new {
my $self = shift->SUPER::new(@_);
$self->_load_config();
return $self;
get '/fortunes' => sub {
my $self = shift;
$sth1->execute();
my $fortunes = $sth1->fetchall_arrayref({});
push @$fortunes, { id => 0, message => 'Additional fortune added at request time.' };
$self->template( 'fortunes', { fortunes => [ sort { $a->{message} cmp $b->{message} } @$fortunes] } );
};
@sgnix
sgnix / switch-screens.pl
Created June 12, 2014 05:35
Monitor switcher using xrandr
#!/usr/bin/env perl
use strict;
use warnings;
my $xrandr = '/usr/bin/xrandr';
my $LVDS = 'LVDS-1';
my @a = `$xrandr -q`;
my %connected = ();
@sgnix
sgnix / kelp_dbi.pl
Last active December 20, 2015 17:38
Connecting to DBI in Kelp
package MyApp;
use Kelp::Base 'Kelp';
use DBI;
# Lazy attribute with DBI handle
attr _dbh => sub {
$_[0]->_dbi_connect;
};
# Private sub to connect
get '/put/:x/:y' => sub {
my ( $self, $x, $y ) = @_;
{ x => $x, y => $y };
};
@sgnix
sgnix / gist:1861129
Created February 18, 2012 22:07
Validate::Tiny 1
my %rules = (
fields => [ 'name', 'email', 'pass' ], # What fields
filters => [
name => sub { ... }, # Filter name
email => sub { ... }, # Filter email
pass => sub { ... } # Filter pass
],
checks => [
name => sub { ... }, # Check if name is good
email => sub { ... }, # Check email