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
dbmopen(%db, "calllog", 0777);
print "START-OF-LOG: 3.0\n";
@keys = keys %db;
for $k (sort @keys) {
$rec = $db{$k};
($freq, $mode, $date, $time, $exch1, $call, $exch2) = split(",", $rec);
write;
#!/usr/bin/perl
sub chomp {
$_[0] =~ s/[\r\n]+//;
}
sub get_time {
$label = shift;
local(@now); @now = localtime;
$now[5] += 1900;
#!/usr/bin/perl
use strict;
no warnings;
${} = 5;
$} = 10;
print "${}\n";
@cowens
cowens / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@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"'
### 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:
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)/;
#!/usr/bin/perl
use strict;
use warnings;
@ARGV = map {
/((?:[^@]+@)?[^:]+):(.*)/ ? "ssh $1 cat $2 |" : $_
} @ARGV;
while (<>) {
#!/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>) {
@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
)