Skip to content

Instantly share code, notes, and snippets.

View niczak's full-sized avatar

Nicholas Kreidberg niczak

  • Exacta Systems
  • Minneapolis, MN
  • X @niczak
View GitHub Profile
@niczak
niczak / gist:9677281
Created March 21, 2014 00:49
Fix Airplay Audio
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
<DirectoryMatch ^.*/wp-admin/>
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /etc/httpd/.wppass
Require valid-user
</DirectoryMatch>
function formatBytes($size, $precision = 2)
{
$base = log($size, 1024);
$suffixes = array('', 'k', 'M', 'G', 'T');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}
@niczak
niczak / format_date.php
Created December 7, 2010 00:37
Functions to add ordinal suffix to day values and convert integer months to string.
<?php
// Add ordinal suffix to day
function fnDay_Format($iday)
{
if(empty($iday))
die("No parameter passed to function.");
else
$iday = intval($iday);
@niczak
niczak / randomfile.php
Created December 27, 2010 22:46
Randomizes image file names in current directory for use w/ digital frames that don't support shuffle.
<?php
/*
randomfile.php
A quickie script that will take all images in
current directory, back them up to ./Orig and
rename all files in parent directory w/ random
numbers.
Written: 12/27/2010 - Nicholas Kreidberg
Revised: 12/27/2010 - Nicholas Kreidberg
@niczak
niczak / link_twitter.html
Created January 4, 2011 19:47
Two lines of JavaScript to convert @ names to Twitter profile links.
@niczak
niczak / gist:841548
Created February 24, 2011 01:02
Convert PostgreSQL timestamp to human readable date.
<?php
// Convert PostgreSQL timestamp to human readable date
function fnDisplay_Timestamp($sDT)
{
// Assuming $sDT is in format: YYYY-MM-DD HH:MM:SS.MS
if(empty($sDT))
fnErr("No parameter passed to fnDisplay_Timestamp() function.");
$aDT = explode(' ', $sDT);
@niczak
niczak / gist:842553
Created February 24, 2011 17:56
A function that will generate and return an HTML select element.
<?php
/*
Here is an example function call, array abbreviated for the example.
$afields = array("Jan"=>"January", "Feb"=>"February", "Mar"=>"March);
echo fnDisplay_DropDown($afields, "Months", "Mar", "required");
Results in:
<select name="Months" class="required">
<option value="Jan">January</option>
<option value="Feb">February</option>
@niczak
niczak / gist:852100
Created March 3, 2011 00:42
Function that sanitizes incoming $_POST data for insertion into MySQL/PostgreSQL.
<?php
////////////////////////////////////////////////////
// Written By: Nicholas Kreidberg //
// Revised By: Nicholas Kreidberg //
// Revised On: 10/01/2010 //
// Desc: fnSanitizePost() takes a $_POST array & //
// sanitizes all strings for insertion into a db. //
// Call: $aclean_post = fnSanitizePost($_POST); //
////////////////////////////////////////////////////
@niczak
niczak / gist:856945
Created March 6, 2011 01:59
Apache Virtual Host Config w/ MAMP
#
# Ports to listen on
#
Listen 8888
#
# Use name-based virtual hosting.
#