Skip to content

Instantly share code, notes, and snippets.

View joshdutcher's full-sized avatar

Josh Dutcher joshdutcher

View GitHub Profile

Keybase proof

I hereby claim:

  • I am joshdutcher on github.
  • I am joshdutcher (https://keybase.io/joshdutcher) on keybase.
  • I have a public key ASA454ROyuy0-4VTJYJxAQcL52rgBip3bkhSO4pAVJnz3go

To claim this, I am signing this object:

@joshdutcher
joshdutcher / rubicon_recon.php
Created April 5, 2016 14:15
Rubicon reconciliation API call
// of course there is actually more to the code than this but here's the relevant part
function getRubiconRecon($date,$freq) {
$key = "************************************";
$secret = "************************************";
$url = "https://api.rubiconproject.com";
$acct = "*****";
$request = "/sellers/api/reports/v1/$acct?columns=Site_Name,Site_ID,Performance_NetworkImps,Performance_FillRate,Traffic_Impressions,Performance_NetworkRevenue,Performance_ECPM,SiteData_KeywordMapped&source=standard&start=$date&end=$date";
$options = array('timeout' => '30', 'auth' => new Requests_Auth_Basic(array($key, $secret)), 'filename' => 'rubicon_body.txt');
$headers = array('Accept' => 'application/json', 'Content-Type' => 'application/json');
@joshdutcher
joshdutcher / debug.php
Last active March 28, 2019 16:12
pretty function for debugging php arrays, objects, variables. etc
function debug($content, $comments=false) {
$backtrace = debug_backtrace();
$calling_file = $backtrace[0]['file'];
$calling_line = $backtrace[0]['line'];
if ($comments) {
// prints the content inside an html comment, requiring user to view source to read it
$prefix = "<!--" . "\r\n" . $calling_file . " line " . $calling_line . "\r\n";
$suffix = "\r\n" . "-->" . "\r\n";
} else {
@joshdutcher
joshdutcher / time_elapsed.php
Last active October 23, 2015 14:32
time_elapsed() - function to track php script execution time. To find where the code is slow.
function time_elapsed() {
$backtrace = debug_backtrace();
$calling_file = $backtrace[0]['file'];
$calling_line = $backtrace[0]['line'];
$call_string = $calling_file . ' line ' . $calling_line . '<br/>';
static $last = null;
$now = microtime(true);