Skip to content

Instantly share code, notes, and snippets.

View cpCharlesBoyd's full-sized avatar

Charles Boyd cpCharlesBoyd

View GitHub Profile
@cpCharlesBoyd
cpCharlesBoyd / parsedep.pl
Created June 18, 2013 20:59
parse output from ebuild depgraph
#!/usr/bin/env perl
use warnings;
use strict;
my $file = $ARGV[0];
if ( !defined($file) ) {
die 'must specify a file containing equery depgraph output';
}
@cpCharlesBoyd
cpCharlesBoyd / story.pl
Created April 16, 2013 14:37
the girl ran while the boy ate while the dog spoke while the cat jumped.
#!/usr/bin/perl
use warnings;
use strict;
my %HoA = (
'nouns' => [ 'girl', 'boy', 'dog', 'cat' ],
'verbs' => [ 'ran', 'ate', 'spoke', 'jumped'],
);
@cpCharlesBoyd
cpCharlesBoyd / YourAddonHook.pm
Last active January 14, 2016 19:32
An example of using cPanel standardized hooks that executes when an addon domain is created.
#!/usr/bin/env perl
package YourAddonModule;
use warnings;
use strict;
sub describe {
my $create_addon_hook =
{
#!/usr/bin/env perl
my @accounts = ();
chomp( my $num_accts_to_generate = <STDIN> );
# generate serveral accounts
foreach ( 1 .. $num_accts_to_generate ) {
my $cp_acct = generate_account();
print( "generated account $cp_acct->{'username'} with passsword $cp_acct->{'password'}","\n");
@cpCharlesBoyd
cpCharlesBoyd / .bashrc
Created February 1, 2013 19:26
part of my ~/.bashrc file
export TESTS=/opt/linux_tests
export PROJECT=$TESTS/projects
export PRODUCTION=$TESTS/production
export TS=/opt/testsuite
function backup { cp $1 ~/.backup/ ; }
function tidy { backup $1 ; perltidy $1 ; mv "$1.tdy" $1 ; }
function gitup { cd $TS ; git pull ; cd - ; cd $TESTS ; git pull ; cd - ; }
#!/usr/bin/env perl
use warnings;
use strict;
sub foo {
my $file_name = 'foo.txt';
my @lines = ( 'a', 'b', 'c', 'd' );
write_to_file($file_name, @lines);
}
@cpCharlesBoyd
cpCharlesBoyd / test_count.pl
Created November 16, 2012 22:40
Count number of test steps used by Test::More
#!/usr/bin/env perl
use warnings;
use strict;
my $file = $ARGV[0];
my $count = 0;
open my $FH, $file
@cpCharlesBoyd
cpCharlesBoyd / dkim.c
Created October 26, 2012 16:06
exim vulnerability in dkim_query_dns_txt()
int dkim_exim_query_dns_txt(char *name, char *answer) {
dns_answer dnsa;
dns_scan dnss;
dns_record *rr;
if (dns_lookup(&dnsa, (uschar *)name, T_TXT, NULL) != DNS_SUCCEED) return PDKIM_FAIL;
/* Search for TXT record */
for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
rr != NULL;
@cpCharlesBoyd
cpCharlesBoyd / xmlapi-json.php
Created October 2, 2012 19:22
Using XMLAPI-PHP with JSON output, simple example
<?php
include("../xmlapi.php");
$ip = '__IP__';
$root_hash = '__ROOT_HASH__';
$xmlapi = new xmlapi($ip);
$xmlapi->hash_auth("root",$root_hash);
$xmlapi->set_output('json');