Skip to content

Instantly share code, notes, and snippets.

View cowens's full-sized avatar

Chas. J. Owens IV cowens

  • Martinsburg, WV
View GitHub Profile
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;
my %h = map { $_ => $_ } 1 .. 10;
my %subs = (
#!/usr/bin/perl
use strict;
use warnings;
use Carp;
use List::Util qw/first/;
use Benchmark;
sub benchmark {
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;
my $r;
my @a = qw/ aaa bbb aaa bbb aaa /;
my @b = qw/ fff fff fff fff fff /;
#!/usr/bin/perl
use strict;
use warnings;
sub bsearch {
my $item = shift;
my @a = @_;
my $offset = 0;
@cowens
cowens / scp
Last active August 29, 2015 13:59
Simple wrapper for scp to add : on the end of known and suspected hosts
#!/bin/bash
SCP=/usr/bin/scp
declare -a hosts=(
host1
host2
host3
)
#!/usr/bin/perl
use strict;
use warnings;
my $filename = shift;
if (my ($target, $path) = $filename =~ /((?:[^@]+@)?[^:]+):(.*)/) {
open my $fh, "-|", "ssh", $target, "cat", $path or die "$!";
while (<$fh>) {
#!/usr/bin/perl
use strict;
use warnings;
@ARGV = map {
/((?:[^@]+@)?[^:]+):(.*)/ ? "ssh $1 cat $2 |" : $_
} @ARGV;
while (<>) {
use strict;
use warnings;
use Benchmark;
my $s = "aaaa 192.168.0.1 sdf";
my %subs = (
norm => sub {
return scalar $s =~ /(a)(a)(a)(a)/;
### Keybase proof
I hereby claim:
* I am cowens on github.
* I am cowens (https://keybase.io/cowens) on keybase.
* I have a public key whose fingerprint is 55A3 0C7F 506A F8C1 667B 94B9 E39B D92B 39CB 08BA
To claim this, I am signing this object:
@cowens
cowens / gist:e4f5c67c57b1590a38aa
Created April 15, 2015 17:15
Example of running out of room with print
mkdir ram
sudo mount -t tmpfs -osize=4k tmpfs ram
perl -le 'open $f, ">", "ram/f"; $i = 0; while (print $f "x") { $i++ }; print "ran out of room after $i bytes"'