Skip to content

Instantly share code, notes, and snippets.

@tap52384
tap52384 / erlangc.php
Created December 18, 2015 21:38
PHP class for calculating the Erlang-C Formula as explained here: http://mitan.co.uk/erlang/elgcmath.htm
<?php
/**
* Time unit defaults to seconds to follow the example shown here:
* http://mitan.co.uk/erlang/elgcmath.htm
* exp calculates e to some specified exponent:
* https://secure.php.net/manual/en/function.exp.php
* factorial function for php:
* http://www.hackingwithphp.com/4/18/0/recursive-functions
* Basically, all calculated values are private.
@tap52384
tap52384 / gist:ef643e7158f2b670a19e
Last active December 22, 2015 03:14 — forked from alkos333/gist:1771618
Read URL GET variable (Javascript)
// Given a query string "?to=email&why=because&first=John&Last=smith"
// getUrlVar("to") will return "email"
// getUrlVar("last") will return "smith"
// 'unescape' is now deprecated for security reasons, so it is replaced here by decodeURIComponent
// MDN proof: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape
// Slightly more concise and improved version based on http://www.jquery4u.com/snippets/url-parameters-jquery/
function getUrlVar(key){
var result = new RegExp(key + '=([^&]*)', 'i').exec(window.location.search);
return result && decodeURIComponent( result[ 1 ] ) || '';
@tap52384
tap52384 / php_html_validator.php
Last active January 15, 2016 15:12
Uses the official w3c validator to validate HTML snippets. The results are returned as a JSON string. Could be refactored, but it works as is.
/**
* Sends an HTML snippet to the W3C validator and returns the result as JSON.
* @param string $html HTML code
* @return string
* @link https://github.com/validator/validator/wiki/Service:-Input:-POST-body
* @link https://gist.github.com/tap52384/60cc27fd0a76869cc38b#file-php_html_validator-php
*/
public static function validateHtml($html = '')
{
$default = array(

Installation

This procedure is tested on Mac OS X 10.14.0 with Xcode Developer Tools installed (xCode).

PHP 5.6, 7.0, 7.1, and 7.2 installed with Homebrew following the instructions here.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

@tap52384
tap52384 / whois.php
Created March 8, 2018 20:52
PHP code to get WHOIS information of a domain
<?php
/*************************************************************************
php easy :: whois lookup script
==========================================================================
Author: php easy code, www.phpeasycode.com
Web Site: http://www.phpeasycode.com
Contact: webmaster@phpeasycode.com
*************************************************************************/
$domain = $_GET['domain'];
@tap52384
tap52384 / readme.md
Last active January 10, 2023 23:38
Bootcamp via Virtualbox 5.2 on macOS Mojave
@tap52384
tap52384 / index.js
Last active August 23, 2023 16:44
Pre-Request Script for Generating JWTs (Postman)
/*
https://jwt.io/introduction/
In its compact form, JSON Web Tokens consist of three parts separated by dots (.), which are:
Header
Payload
Signature
Therefore, a JWT typically looks like the following.
@tap52384
tap52384 / getgrav.sh
Last active September 25, 2018 15:42
Installs multiple versions of PHP on macOS
#!/bin/bash
APACHE_CONF=/usr/local/etc/httpd/httpd.conf
# Checks whether Homebrew is installed or not
function checkBrew {
installed brew
BREW_INSTALLED=$?
}
@tap52384
tap52384 / .gitconfig
Created October 11, 2018 12:26
.gitconfig
[user]
name = name
email = email
[core]
excludesfile = /Users/username/.gitignore_global
autocrlf = input
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
@tap52384
tap52384 / README.md
Last active August 1, 2023 10:10
Install Windows on External Drive for macOS