Skip to content

Instantly share code, notes, and snippets.

View digitalsweetspot's full-sized avatar

Jon Hopewell digitalsweetspot

View GitHub Profile
@digitalsweetspot
digitalsweetspot / gist:3292218
Created August 8, 2012 05:00
[PHP] getDays - helper function to generate a list of "day" option fields for use in an html select list
function getDays($day = 0) {
$numDays = 31;
$x = 1;
$output = '<option value="">DD</option>' . "\n";
while ($x <= $numDays) {
if($x < 10) { $x = "0".$x; }
$output .= '<option ';
if($day == $x) { $output .= 'selected="selected"'; }
@digitalsweetspot
digitalsweetspot / gist:3292229
Created August 8, 2012 05:04
[PHP] getMonths - helper function to generate a list of "month" option fields for use in an html select list
function getMonths($month = 0) {
$numMonths = 12;
$x = 1;
$output = '<option value="">MM</option>' . "\n";
while ($x <= $numMonths) {
if($x < 10) { $x = "0".$x; }
$output .= '<option ';
if($month == $x) { $output .= 'selected="selected"'; }
@digitalsweetspot
digitalsweetspot / gist:3292336
Created August 8, 2012 05:17
[PHP] getYears - helper function to generate a list of "year" option fields for use in an html select list
function getYears($past = 99, $future = 0, $year = 0) {
$yr = date("Y") + $future;
$numYearSub = $past + $future;
$x = 0;
$output = '<option value="">YYYY</option>' . "\n";
while ($x <= $numYearSub) {
$output .= '<option ';
if($year == $yr) { $output .= 'selected="selected"'; }
@digitalsweetspot
digitalsweetspot / gist:3292448
Created August 8, 2012 05:32
[PHP] getStates - helper function to generate a list of US "state" option fields for use in an html select list
function getStates($state) {
$stateList = array("AL"=>"Alabama","AZ"=>"Arizona","AR"=>"Arkansas","CA"=>"California","CO"=>"Colorado","CT"=>"Connecticut","DC"=>"District of Columbia","DE"=>"Delaware","FL"=>"Florida","GA"=>"Georgia","ID"=>"Idaho","IL"=>"Illinois","IN"=>"Indiana","IA"=>"Iowa","KS"=>"Kansas","KY"=>"Kentucky","LA"=>"Louisiana","ME"=>"Maine","MD"=>"Maryland","MA"=>"Massachusetts","MI"=>"Michigan","MN"=>"Minnesota","MS"=>"Mississippi","MO"=>"Missouri","MT"=>"Montana","NE"=>"Nebraska","NV"=>"Nevada","NH"=>"New Hampshire","NJ"=>"New Jersey","NM"=>"New Mexico","NY"=>"New York","NC"=>"North Carolina","ND"=>"North Dakota","OH"=>"Ohio","OK"=>"Oklahoma","OR"=>"Oregon","PA"=>"Pennsylvania","RI"=>"Rhode Island","SC"=>"South Carolina","SD"=>"South Dakota","TN"=>"Tennessee","TX"=>"Texas","UT"=>"Utah","VT"=>"Vermont","VI"=>"Virgin Islands","VA"=>"Virginia","WA"=>"Washington","WV"=>"West Virginia","WI"=>"Wisconsin","WY"=>"Wyoming");
// $stateList = array("AL"=>"AL","AZ"=>"AZ","AR"=>"AR","CA"=>"CA","CO"=>"CO"
@digitalsweetspot
digitalsweetspot / gist:3292506
Created August 8, 2012 05:46
handy bash command for removing ".svn" directories from the current directory as well as all child directories
find . -name ".svn" -exec rm -rf '{}' \;
@digitalsweetspot
digitalsweetspot / checkPolicyServer
Created June 24, 2014 15:40
handy command line script for checking a policy server
python -c 'print "<policy-file-request/>%c" % 0' | nc xxx.xxx.xxx.xxx 843
@digitalsweetspot
digitalsweetspot / gist:778a257eff9a7cb766f8
Created September 22, 2015 19:25
mongo shell connect to mongoDB primary node in replica set (with authentication)
/*
* connects mongo shell to the primary node of a replica set
* without first knowing the primary node ip
*
* note: authentication is optional; based on configuration
*
* @[replicaset-name]
* name of the replica set
*
* @[node-ip]