This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $depth = terminal_color_depth(); | |
print "My terminal has " . $depth . " colors\n"; | |
sub terminal_color_depth { | |
# If we're not attached to an STDOUT don't go any further | |
if (!-t STDOUT) { | |
return 8; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Benchmark qw(cmpthese); | |
use Getopt::Long; | |
use strict; | |
my $short = 0; | |
my $long = 0; | |
my $iterations = 3000000; | |
GetOptions( | |
"long" => \$long, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Scott's vimrc file | |
set autoindent " auto indent the next line when you hit enter | |
set backspace=2 " Backspace over everything in insert mode | |
set tabstop=4 " Tabs display as three spaces | |
set shiftwidth=4 " Shiftwidth is X for < and > moves | |
set softtabstop=4 " Soft tab stop | |
set noexpandtab " Don't expand tabs in insert mode | |
set ruler " Show what line/char you're on | |
set t_Co=256 " use 256 colors | |
set exrc " Enable reading .vimrc in the current dir to complement global one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists("random_bytes")) { | |
function random_bytes($bytes = 16) | |
{ | |
$ret = ''; | |
if (function_exists("mcrypt_create_ivz")) { | |
$ret = mcrypt_create_iv($bytes); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function qw($str,$return_hash = false) { | |
$str = trim($str); | |
// Word characters are any printable char | |
$words = str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); | |
if ($return_hash) { | |
$ret = array(); | |
$num = sizeof($words); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns boolean if a function is an associative array | |
* | |
* @param array $array An array to test | |
* | |
* @return boolean | |
*/ | |
public static function is_assoc_array($array) { | |
if (!is_array($array)) { return false; } | |
// $array = array() is not associative |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function args($item = '') { | |
// Throw away the first one (name of script) | |
$args = array_slice($GLOBALS['argv'],1); | |
$ret = array(); | |
for ($i = 0; $i < sizeof($args); $i++) { | |
// If the item starts with "-" it's a key. Ignore items that are single dash words (-debug) | |
if (preg_match("/^--?([a-zA-Z_]\w*)/",$args[$i],$m) && !preg_match("/^-\w\w/",$args[$i])) { | |
$key = $m[1]; | |
// If the next item does not start with "--" it's the value for this item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create the client object | |
// $url = "https://scott.internal.web-ster.com/api/json-rpc/"; | |
// $j = new jsonrpc_client($url); | |
// Run the echo_data() function | |
// $a = $j->echo_data('one','two'); | |
// if $a === null, there was some sort of error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use Getopt::Long; | |
use Time::HiRes qw(time sleep); | |
use Net::SNMP; | |
#use Data::Dump::Color; | |
my $debug = 0; | |
my $delay = 3; # Default delay is 3 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package JSON::RPC::Client::Lite; | |
use HTTP::Tiny; | |
use vars '$AUTOLOAD'; | |
use JSON; | |
#use Data::Dump::Color; | |
sub new { | |
my ($class,$url,$opts) = @_; |
OlderNewer