Skip to content

Instantly share code, notes, and snippets.

View apollwebservices's full-sized avatar

apollwebservices

View GitHub Profile
//IMPORTANT - install this before: npm i child-process-promise --save-dev
/*
put this in your package.json script:
"install-collection": "node install-collection.js"
npm run install-collection <user>.<collection>
*/
/*jshint esversion: 6 */
const exec = require('child-process-promise').exec;
@apollwebservices
apollwebservices / sanitize_phone.php
Last active June 20, 2017 16:26 — forked from wpsmith/sanitize_phone.php
Sanitize & Format US Phone Numbers
<?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 );
@apollwebservices
apollwebservices / track_links.js
Last active October 8, 2018 16:48
Track Downloads & Outbound Links in Google Analytics
@apollwebservices
apollwebservices / fonts.less
Created August 29, 2016 20:59
Conbraco Branded Font Set
@font-face {
font-family: "Mission Gothic_Black Italic";
src: url("@{custom-font-url}Mission Gothic Black Italic_web.eot");
src: url("@{custom-font-url}Mission Gothic Black Italic_web.eot?#iefix") format("embedded-opentype"),
url("@{custom-font-url}Mission Gothic Black Italic_web.woff") format("woff"),
url("@{custom-font-url}Mission Gothic Black Italic_web.ttf") format("truetype"),
url("@{custom-font-url}Mission Gothic Black Italic_web.svg#svgFontName") format("svg");
font-weight: normal;
font-style: normal;
}
@apollwebservices
apollwebservices / spaces.less
Last active November 11, 2016 19:50
Used to modify the default spacing (margin/padding) between objects
// Should be used to modify the default spacing between objects (not between nodes of * the same object)
// spacing helpers
// p,m = padding,margin
// a,t,r,b,l,h,v = all,top,right,bottom,left,horizontal,vertical
// xs,s,m,l,n = extra-small(@xs),small(@s),medium(@m),large(@l),extra-large(@xl),none(0px)
@xs: 5px;
@s: 10px;
@m: 20px;
@l: 40px;
@xl: 60px;
@apollwebservices
apollwebservices / block_align.less
Last active November 11, 2016 19:49
Vertical and Horizontal Alignment
.vertical-align() {
display: block;
position: absolute;
top: 50%;
transform: perspective(1px) translateY(-50%);
}
.vertical-horizontal-align() {
display: block;
position: absolute;
@apollwebservices
apollwebservices / breakpoint_variables.less
Last active August 29, 2016 19:42
Easy Media Queries Shortcodes w/ Testing Tags
// Breakpoint Variables
// ------------------------- Source: http://blog.scur.pl/2012/06/variable-media-queries-less-css/
@highdensity: ~"only screen and (-webkit-min-device-pixel-ratio: 1.5)",
~"only screen and (min--moz-device-pixel-ratio: 1.5)",
~"only screen and (-o-min-device-pixel-ratio: 3/2)",
~"only screen and (min-device-pixel-ratio: 1.5)";
@mobile: ~"only screen and (max-width: 529px)";
@tablet: ~"only screen and (min-width: 530px) and (max-width: 949px)";
@desktop: ~"only screen and (min-width: 950px) and (max-width: 1128px)";
@desktop-xl: ~"only screen and (min-width: 1129px)";
@apollwebservices
apollwebservices / replace.sql
Created August 25, 2016 16:38
UPDATE and REPLACE part of a string
UPDATE table SET field = REPLACE(field, 'oldstring', 'newstring');
@apollwebservices
apollwebservices / smoothscroll.js
Last active August 25, 2016 16:39
Smooth Scrolling To Internal Links
/**
* Catch all internal links and smooth scroll on click
*/
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash),
$this = $(this),
offset = $this.data('offset') || 0,
duration = $this.data('duration') || 0.8;
@apollwebservices
apollwebservices / equal_heights.js
Created August 25, 2016 13:23
Equal Column Heights
/**
* Equal Heights
*/
var resizeElements = function(selector) {
if (selector != '') {
$(selector).each(function() {
var maxHeight = 0;
$(this).children().each(function() {
if (maxHeight < $(this).height()) {