Skip to content

Instantly share code, notes, and snippets.

<?php
function sanitize_phone( $phone, $international = false ) {
$format = "/(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/";
$alt_format = '/^(\+\s*)?((0{0,2}1{1,3}[^\d]+)?\(?\s*([2-9][0-9]{2})\s*[^\d]?\s*([2-9][0-9]{2})\s*[^\d]?\s*([\d]{4})){1}(\s*([[:alpha:]#][^\d]*\d.*))?$/';
// Trim & Clean extension
$phone = trim( $phone );
$phone = preg_replace( '/\s+(#|x|ext(ension)?)\.?:?\s*(\d+)/', ' ext \3', $phone );
/*!
* @description Grunt@!!!!!
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
@lamguy
lamguy / Linux Static IP
Created September 23, 2015 15:37 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@lamguy
lamguy / array_rotating.php
Created September 29, 2015 15:14
PHP rotating in array
<?php
function rotate($object, $object_uid, $property, $array, $field_index='uid', $return_field = "name")
{
global $db;
$return_data = false;
$rotating_array = array();
$next_value = false;
$next_label = false;
@lamguy
lamguy / PHPExcel_Basics.md
Created October 29, 2015 16:30 — forked from r-sal/PHPExcel_Basics.md
PHPExcel Notes and code snippets

Basics

Creating a new PHPExcel Object.

    $this->PHPExcel = new PHPExcel();

Working with sheets

Creating a new sheet:

@lamguy
lamguy / pivot.sql
Created February 10, 2016 16:46
MySQL Rows to Columns
-- http://stratosprovatopoulos.com/web-development/mysql/mysql-dynamically-convert-rows-to-columns/
SET group_concat_max_len=20000;
SET @a = 0;
SET @b = 0;
set @num := 0;
SET @regno := '';
SET @line1 = CONCAT (
@lamguy
lamguy / nginx.conf
Created August 25, 2017 14:53 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@lamguy
lamguy / gsma.php
Last active September 1, 2017 18:29
<?php
$url = 'https://devicecheck.gsma.com/imeirtl/detailedblwithmodelinfo';
//INITIATE cURL
$ch = curl_init($url);
//CREATE PAYLOAD
$payload = array(
@lamguy
lamguy / RequestGSMA.php
Created October 26, 2017 18:28
Request GSMA
<?php
$imei = "354408064463695";
$apiKey = 'C31xxx950';
$password = 'paxxx#d';
$salt = 'Dxxx';
$orgID = 187;
$secret = 'GSxxxion';
$signatureHash = hash("sh256", $apiKey . $password . $imei);
@lamguy
lamguy / default
Created January 18, 2018 13:59 — forked from dtomasi/default
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}