Skip to content

Instantly share code, notes, and snippets.

View mrenvoize's full-sized avatar
🏠
Working from home

Martin Renvoize mrenvoize

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am mrenvoize on github.
  • I am ashimema (https://keybase.io/ashimema) on keybase.
  • I have a public key ASCxW5ClmJOS6r7dfZF5N86yz0XI6o17D6ysBmwYhaQVUwo

To claim this, I am signing this object:

@mrenvoize
mrenvoize / resultset.pm
Created July 3, 2018 11:04
Chainable filters
=head3 filter_by_last_issued
Koha::Patrons->filter_by_last_issued( { after => DateTime, before => DateTime } );
Returns patrons filtered by whether their last issue falls betwen the passed limits.
=head4 arguments hashref
=over 4
diff --git a/misc/translator/po/ar-Arab-staff-prog.po b/misc/translator/po/ar-Arab-staff-prog.po
index ab5f709633..48541970fa 100644
--- a/misc/translator/po/ar-Arab-staff-prog.po
+++ b/misc/translator/po/ar-Arab-staff-prog.po
@@ -412,7 +412,7 @@ msgid ""
"%s %s %s %s %s %s %s %sCirculation %sCatalog %sPatrons %sAcquisitions "
"%sAccounts %sSerials %s %s %s "
msgstr ""
-"%s %s %s %s %s %s %s %sالإعارة %sالفهرس %المستفيدين %sالتزويد %sالحسابات %"
+"%s %s %s %s %s %s %s %sالإعارة %sالفهرس %المستفيدين %sالتزويد %sالحسابات %%"
@mrenvoize
mrenvoize / clean_borrowers.pl
Created June 19, 2018 18:15
example of complicated patron filtering
#!/usr/bin/perl
# Copyright 2018, PTFS Europe.
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if (TableExists('deletedbiblio') && TableExists('deletedbiblioitems') && TableExists('deletedbiblio_metadata')) {
$dbh->do( "ALTER TABLE biblio ADD COLUMN deleted_on datetime DEFAULT NULL" ) or warn $DBI::errstr;
$dbh->do( "ALTER TABLE biblioitems ADD COLUMN deleted_on datetime DEFAULT NULL" ) or warn $DBI::errstr;
$dbh->do( "ALTER TABLE biblio_metadata ADD COLUMN deleted_on datetime DEFAULT NULL" ) or warn $DBI::errstr;
$dbh->do( "ALTER TABLE items ADD COLUMN deleted_on datetime DEFAULT NULL" ) or warn $DBI::errstr;
# Need to disable foreign keys on deletedbiblio_metadata to avoid cascading deletes from deletedbiblio
# Bug 17196 introduced a mismatch in foreign keys of deletedbiblio_metadata, so any key must be dropped
@mrenvoize
mrenvoize / Controller-Priority.pm
Created January 5, 2018 08:57
Multi-create Fun
my $list_changeResult = $c->db->resultset('ListChange')->create(
{
list_id => $list_id,
request => [{requester_id => $requester_id, assignee_id => $assignee_id, status => 'new'}],
message => {
buffer_id => $list_id,
user_id => $requester_id,
text => "Priority tag '$tag' was removed from the system.",
important => 1
}
@mrenvoize
mrenvoize / Notifications.pm
Created August 24, 2017 16:07
paging example
package Rebus::Controller::Notification;
use Mojo::Base 'Mojolicious::Controller';
sub list {
my $c = shift->openapi->valid_input or return;
my $input = $c->validation->output;
my $output = [];
my $rows = $input->{limit} // 14;
package Rebus;
use Mojo::Base 'Mojolicious';
use Mojo::Pg;
use Rebus::Schema;
use strict;
use warnings;
# Every app should have a version
package Mojo::JSON::Patch;
use Mojo::Base 'Mojo::JSON::Pointer';
use Carp 'croak';
use Mojo::Path;
sub set {
my $self = shift;
my $path = Mojo::Path->new(shift);
my $val = shift;
@mrenvoize
mrenvoize / List.pm
Created January 18, 2017 08:58
Boolean Filter for DBIx::Class Result Object
=head1 FILTERED COLUMNS
=head2 suppressed
Type: Boolean
=cut
__PACKAGE__->filter_column(
suppressed => {
filter_to_storage => sub { $_[1] ? 1 : 0 },
filter_from_storage => sub { $_[1] ? Mojo::JSON->true : Mojo::JSON->false }
}