Tuesday, January 21, 2014

Macklemore & Ryan Lewis - Thrift Shop - Lyrics

[Intro: Brooklyn Grinnell]
"Hey Macklemore, can we go thrift shopping?"

What what, what, what
What what, what, what
What what, what, what
What what, what, what  |  Cha!
What what, what, what  |  Denim, badum, budadee, cha!
What what, what, what  |  Denim, badum, budadee, cha!
What what, what, what  |  Denim, badum, budadee, cha!
What what, what, what  |  Denim, badum, budadee, cha! (Oh!)
                       |  Denim, badum, budadee, cha!
                       |  Denim, badum, budadee, cha! (Oh!)
                       |  Denim, badum, budadee, cha!
                       |  Denim, badum, budadee, cha!
(Ow ow)

[Hook: Wanz]
I'm gonna pop some tags, only got twenty dollars in my pocket.
I, I'm, I'm hunting, looking for a come up, this is fucking awesome.

[Verse 1: Macklemore]
Now walk into the club like "What up?! I got a big cock!"
Nah, I'm just pumped, I bought some shit from a thrift shop. (Oh!)
Ice on the fringe is so damn frosty
The people like "Damn, that's a cold ass honky"
Rolling in hella deep, headed to the mezzanine
Dressed in all pink except my gator shoes, those are green (Oh!)
Draped in a leopard mink, girl standing next to me
Probably should've washed this, smells like R. Kelly sheets
(Pissssss...) But shit, it was 99 cents! (Bag it)
Fuck it, coppin' it, washin' it, 'bout to go and get some compliments
Passing up on those moccasins someone else has been walking in (Oh!)
Bummy and grungy, fuck it man, I am stunting and flossing and
Saving my money and I'm hella happy, that's a bargain, bitch (Oh!)
I'ma take your grandpa's style, I'ma take your grandpa's style
No for real, ask your grandpa, "Can I have his hand-me-downs?" (Thank you!)
Velour jumpsuit and some house slippers
Dookie brown leather jacket that I found digging (Woo!)
They had a broken keyboard (Ya), I bought a broken keyboard(Ya)
I bought a skeet blanket, then I bought a knee board (Oh!)
Hello, hello, my ace man, my mellow
John Wayne ain't got nothing on my fringe game, hell no (Oh!)
I could take some Pro Wings, make them cool, sell those
The sneaker heads would be like "Ah, he got the Velcros" (Oh!)

[Hook: Wanz]
I'm gonna pop some tags, only got twenty dollars in my pocket (Oh!)
I, I'm, I'm hunting, looking for a come up, this is fucking awesome (Ow, ow)
I'm gonna pop some tags, only got twenty dollars in my pocket (Oh!)
I, I'm, I'm hunting, looking for a come up, this is fucking awesome

[Verse 2: Macklemore]
What you know about rocking a wolf on your noggin?
What you knowing about wearing a fur fox skin? (Oh!)
I'm digging, I'm digging, I'm searching right through that luggage
One man's trash, that's another man's come up (Oh!)
Thank your granddad for donating that plaid button-
Up shirt, cause right now, I'm up in her skirt
I'm at the Goodwill, you can find me in the (Bins, bins)
I'm not, I'm not stuck on searchin' in that section (Mens, mens)
Your grammy, your aunty, your momma, your mammy
I'll take those flannel zebra jammies, second hand and I'll rock that motherfucker (ooo)
The built-in onesie with the socks on the motherfucker
I hit the party and they stop in that motherfucker (Oh!)
They be like "Oh that Gucci, that's hella tight"
I'm like "Yo, that's fifty dollars for a t-shirt"
Limited edition, let's do some simple addition
Fifty dollars for a t-shirt, that's just some ignorant bitch shit
I call that getting swindled and pimped, shit
I call that getting tricked by business
That shirt's hella dough
And having the same one as six other people in this club is a hella don't (Oh!)
Peep game, come take a look through my telescope
Trying to get girls from a brand? (Oh!)
Man you hella won't, man you hella won't
Goodwill poppin' tags, yeah haha

(Ow ow)

[Hook: Wanz]
I'm gonna pop some tags, only got twenty dollars in my pocket (Oh!)
I, I'm, I'm hunting, looking for a come up, this is fucking awesome (Oh!)

[Bridge: Wanz]
I wear your granddad's clothes, I look incredible
I'm in this big ass coat from that thrift shop down the road (ooop ooop)
I wear your granddad's clothes (Damn right), I look incredible (Ah come on man)
I'm in this big ass coat (Big ass coat man) from that thrift shop down the road (lets go, come on!)

[Hook: Wanz]
I'm gonna pop some tags, only got twenty dollars in my pocket (Oh!)
I, I'm, I'm hunting, looking for a come up, this is fucking awesome (Oh!)

[Outro: Brooklyn Grinnell]
"Is that your grandma's coat?"

Tuesday, February 5, 2013

PHP - cURL - Optimise Speed Reusing SSL Connections

Below is an example of using cURL to fetch multiple URLs that are using SSL and then reuse those connections to retrieve more data. This example fetches 2 URLs simultaneously which both open an SSL connection, then the next lot of 2 URLs reuse those connections to retrieve data thereby bypassing the SSL handshake.

<?php
//Number of SSL connections to use
$connections = 2;

//Array of URLs to retrieve using https
$urls = array();
$urls[] = 'https://www.googleapis.com/plus/v1/people/105381197794279347286?fields=displayName%2Cgender%2CobjectType&key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM';
$urls[] = 'https://www.googleapis.com/plus/v1/people/105381197794279347286?fields=displayName%2Cgender%2CobjectType&key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM';
$urls[] = 'https://www.googleapis.com/plus/v1/people/105381197794279347286?fields=displayName%2Cgender%2CobjectType&key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM';
$urls[] = 'https://www.googleapis.com/plus/v1/people/105381197794279347286?fields=displayName%2Cgender%2CobjectType&key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM';
$urls[] = 'https://www.googleapis.com/plus/v1/people/105381197794279347286?fields=displayName%2Cgender%2CobjectType&key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM';
$urls[] = 'https://www.googleapis.com/plus/v1/people/105381197794279347286?fields=displayName%2Cgender%2CobjectType&key=AIzaSyCFj15TpkchL4OUhLD1Q2zgxQnMb7v3XaM';

//Number of times to reuse each SSL connection (6/2 = 3)
$reuse = count($urls) / $connections;

//Array used to store multiple cURL handles for each SSL connection
$handle = array();

//Array used to store all returned page data
$result = array();

//Log file used to see that only 2 SSL conections are being used
//$logfh = fopen("curl.log", 'a+');

//Loop for each SSL connection
for($r=0;$r<$reuse;$r++) {
  //Loop for each reuse of the SSL connection
  for($c=0;$c<$connections;$c++) {
    //Initialise a cURL session using the urls
    $handle[$c] = curl_init($urls[($r*$connections)+$c]);

    //Set any options you want here
    curl_setopt($handle[$c], CURLOPT_HTTPHEADER, array('x-origin: https://developers.google.com'));
    curl_setopt($handle[$c], CURLOPT_RETURNTRANSFER, true);
    //Turns on detailed info for the log
    //curl_setopt($handle[$c], CURLOPT_VERBOSE, true);
    //Send the output to the log file
    //curl_setopt($handle[$c], CURLOPT_STDERR, $logfh);

    static $multi = NULL;
    if (empty($multi)) {
      //Initialise a multi cURL session if one does not already exist
      $multi = curl_multi_init();
    }

    //Add the single cURL handle to the mutli cURL handle
    curl_multi_add_handle($multi, $handle[$c]);
  }

  $running = NULL;
  do {
    //Execute all handles in $multi until all are completed
    curl_multi_exec($multi, $running);
  } while($running > 0);

  for($i=0;$i<$connections;$i++) {
    //Do something with each result
    $result[] = curl_multi_getcontent($handle[$i]);
    //Remove the single cURL handle from the multi cURL handle
    curl_multi_remove_handle($multi, $handle[$i]);
  }
}
//Dump the result which will show my public profile info 6 times
var_dump($result);
?>

Output: This will output 6 arrays, one for each of the pages we retrieved. It will contain some public information from my Google+ profile.

Note: If you use the curl.log you must ensure you have the correct permissions on the file.

Sunday, April 15, 2012

Javascript - Object.keys Browser Compatibility

For Object.keys compatibility in all browsers add this code before using Object.keys.

if (!Object.keys) Object.keys = function(o) {
  if (o !== Object(o))
    throw new TypeError('Object.keys called on a non-object');
  var k=[],p;
  for (p in o) if (Object.prototype.hasOwnProperty.call(o,p)) k.push(p);
  return k;
}

You can now use Object.keys as normal such as Object.keys(myObject).length

Wednesday, May 25, 2011

JavaScript - AJAX / SJAX - Submit Form Data to PHP Script

Below is a function I use to submit form data (POST) to a PHP script using Asynchronous / Synchronous JavaScript And XML.

function runSQL(div, script, data) {
  var
ajax = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest;
  if (div != "") {
    ajax.onreadystatechange = function () {
     if (ajax.readyState == 4) {document.getElementById(div).innerHTML = ajax.responseText}; //AJAX
    };
  }
  ajax.open("POST", script, div != '' ? true : false);
  if (data) {ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")};
  ajax.send(data ? data : null);
  if (div == "") {
    return ajax.responseText; //SJAX
  } else {
    return
;
  }
}

Example of AJAX call:

runSQL('DIV_Content', 'sql.php', 'action=getContents&page=Home&custom=1');

Example of SJAX call:

result = runSQL('', 'sql.php', 'action=getContents&page=Home&custom=1');
//Do something with result

Note: Using AJAX allows the JavaScript to continue executing however using SJAX forces JavaScript to wait for the result before continuing. This is useful if you need to do something with the result such as use it in a calculation elsewhere in JavaScript whereas the AJAX result can just be returned straight to the HTML div element as is, once it is ready.

Thursday, May 19, 2011

jQuery - Tables - Show and Hide Columns

You can hide and show columns in a table by specifying a column index where 1 is the first column in the table.

function toggleColumn(column) {
  $('#iTable tr *:nth-child('+ column +')').toggle();
}

Note: iTable is the name of the HTML table.
Note: The * is used to ensure you show / hide both the TH and TD tags.