Skip to content

Instantly share code, notes, and snippets.

@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);
<?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 => "");
Verifying that +mmollick is my blockchain ID. https://onename.com/mmollick
@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
@mmollick
mmollick / Single Verification Request
Last active February 9, 2016 15:49
NeverBounce Curl Example
curl -X POST https://api.neverbounce.com/v3/single\
-d access_token=<ACCESS TOKEN>\
-d email=<EMAIL>
@mmollick
mmollick / release.sh
Last active March 18, 2016 16:44
A bash script that builds and packages our application. It automatically commits and tags it enforcing semver
#!/bin/bash
printHelp () {
printf "This utility will create the proper release commit to be used for deployment\n"
printf "Options:\n"
printf " -v|--version Explicitly define the version number\n"
printf " -M|--major Bump the major version number\n"
printf " -m|--minor Bump the minor version number\n"
printf " -p|--patch Bump the patch version number\n"
printf " -r|--rebundle Forces Gulp & Webpack compilation\n"
<?php
ini_set('memory_limit', '1024M');
/**
* show a status bar in the console
*
* <code>
* for($x=1;$x<=100;$x++){
*
* show_status($x, 100);
@mmollick
mmollick / direct_input.php
Created June 21, 2016 13:43
Example of direct input
<?php
// Get file contents
$input = file_get_contents(__DIR__ . '/file.csv');
// Start job
$ch = curl_init('https://api.neverbounce.com/v3/bulk');
$data = [
"access_token" => $access_token,
"input" => $input,
"input_location" => 1,
@mmollick
mmollick / exampleSelection.md
Last active September 7, 2016 15:12
Extract javascript object components

Heres an example of what a match will look like

/**
     * Request timeout in milliseconds
     * After this threshold is reached the result is assumed unknown. This is likely
     * a trouble host that will take extra time to resolve.
     */
    timeout: {
 default: 30000,
@mmollick
mmollick / setup.sh
Created March 2, 2017 18:39 — forked from bradp/setup.sh
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install