Skip to content

Instantly share code, notes, and snippets.

@mmollick
mmollick / Access Token Request
Last active February 9, 2016 15:48
NeverBounce Curl Examples
curl -X POST -u <API USERNAME>:<API SECRET KEY> https://api.neverbounce.com/v3/access_token\
-d grant_type=client_credentials\
-d scope=basic+user
Verifying that +mmollick is my blockchain ID. https://onename.com/mmollick
<?php
/**
* Shorten large numbers into abbreviations (i.e. 15,000 = 15K, 1,500 = 1.5K)
*
* @param int $number Number to shorten
* @return String A number with a symbol
*/
function numberAbbreviation($number) {
$abbrevs = array(12 => "T", 9 => "B", 6 => "M", 3 => "K", 0 => "");
@mmollick
mmollick / URL Regex test
Last active August 29, 2015 14:06
URL regex
<?php
/**
*
* http://regex101.com/r/xT3wZ9/1
*
*/
$url = "http://www.neowin.net/forum/topic/1229911-i-need-a-reg-ex-for-urls/";
$regex = "/(^https?:\/\/?)?([w]{3}|[a-z0-9]+\.)?([a-z0-9]+)(\.[a-z\.]{2,6}+)(\/[a-z0-9\-\_\/]+)+(\.[a-z0-9]+)?(\?[a-z0-9\=\-\_\&\+]*)?/i";
$url_parts = preg_match($regex, $url);