Skip to content

Instantly share code, notes, and snippets.

@reneeb
reneeb / gist:8176476
Last active January 1, 2016 17:19
Sample XML output OTRS unittests
<?xml version="1.0" encoding="utf-8" ?>
<otrs_test>
<Summary>
<Item Name="Database">MySQL 5.5.34</Item>
<Item Name="Host">yourhost.example.com</Item>
<Item Name="OS">Linux</Item>
<Item Name="Perl">5.14.2</Item>
<Item Name="Product">OTRS 3.3.1</Item>
<Item Name="TestNotOk">1</Item>
<Item Name="TestOk">16</Item>
#!/usr/bin/perl
use strict;
use warnings;
use Rex;
use Rex::Commands::Cloud;
use IO::All;
use HTTP::Tiny;
@reneeb
reneeb / gist:8433316
Last active January 3, 2016 07:59
GenericAgent sample
# --
# Kernel/System/GenericAgent/ReopenOldTickets.pm - generic agent notifications
# Copyright (C) 2014 Perl-Services.de, http://perl-services.de
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::System::GenericAgent::ReopenOldTickets;
for my $info ( $hostname, $kernel, $uptime, $ifconfig, $route, $memory, $disk ) {
print $file sprintf "%s\n%s\n", '=' x 70, $info;
}
@reneeb
reneeb / gist:8463526
Last active January 3, 2016 12:29
Open tickets at a specific time
SELECT th.id, ticket_id AS searched_id
FROM ticket_history th
INNER JOIN ticket_state ts ON ts.id = th.state_id
INNER JOIN ticket_state_type tst ON tst.id = ts.type_id
WHERE tst.name IN('open', 'new', 'pending reminder', 'pending auto')
HAVING th.id = (
SELECT MAX(id)
FROM ticket_history
WHERE create_time <= '2014-12-31 23:59:59'
AND ticket_id = searched_id
@reneeb
reneeb / gist:8519123
Created January 20, 2014 12:27
TicketUpdate
#!/usr/bin/perl
use strict;
use warnings;
use SOAP::Lite;
my $soap = SOAP::Lite
->uri( 'http://www.perl-services.de/TicketConnector' ) # namespace configured in webservice (transport protocol)
->proxy('http://localhost/otrs/nph-genericinterface.pl/Webservice/Extern' ) # <HTTP_type>://<domain>/<script_path>/nph-genericinterface.pl/Webservice/<NameOfWebservice>
SELECT t.customer_id, t.title, ta.time_unit, dfv.value_text FROM time_accounting ta INNER JOIN ticket t ON t.id = ta.ticket_id LEFT OUTER JOIN dynamic_field_value dfv ON dfv.object_id = ta.article_id LEFT OUTER JOIN dynamic_field df ON dfv.field_id = df.id WHERE ta.create_time BETWEEN '2011-05-31 00:00:00' AND '2014-12-31 23:59:59';
reneeb@perl-services:~/community$ perl -E ' open $wfh, ">", "large_file.txt"; say $wfh $_ for 0 .. 1_000_000; close $wfh; open my $fh, "<","large_file.txt"; my $line; for ( ;<$fh>; ) { $line = $. } say $.; <STDIN>'
1000001
=> 18083 reneeb 20 0 29924 3952 1972 S 0,0 0,1 0:00.50 perl
reneeb@perl-services:~/community$ perl -E ' open $wfh, ">", "large_file.txt"; say $wfh $_ for 0 .. 1_000_000; close $wfh; open my $fh, "<","large_file.txt"; my $line; for ( <$fh> ) { $line = $. } say $.; <STDIN>'
1000001
=> 18101 reneeb 20 0 174m 148m 1988 S 0,0 1,9 0:00.70 perl
my $seq = FastaSeq->new(id => 'A1');
$seq->seq('atcg');
#print Dumper $seq;
my $in = ReadFasta->new(infile => 't/test.fa');
my $s = $in->next_seq();
print ">", $s->id, " ", $s->descr, "\n";
print $s->seq, "\n";
my $in = ReadFasta->new(infile => 't/test.fa');
my $s = $in->next_seq();
print ">", $s->id, " ", $s->descr, "\n";
print $s->seq, "\n";
$in->next_line;
$s = $in->next_seq();
print ">", $s->id, " ", $s->descr, "\n";