Skip to content

Instantly share code, notes, and snippets.

View geilt's full-sized avatar

Alexander Conroy geilt

View GitHub Profile
/*
global navigator
*/
function checkAudio(){
var iOS = [ 'iPad', 'iPhone', 'iPod' ].indexOf( navigator.platform ) >= 0;
var microphone, speakers;
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
console.error( 'checkAudio', "enumerateDevices() not supported.");
@geilt
geilt / dotnotation.php
Last active June 30, 2017 18:23
Get Dot Notation Values with Caching.
<?php
/**
* This class assumes it is in some kind of framework.
* It has 'data' passed in, then the $this->var function will get data either in the $this->data object if $name is string
* or it will return from an object passed in.
* It converts the object into an array and keeps a copy in cache for later use so the json_encode and json_decode is not called
* multiple times.
*/
class View {
@geilt
geilt / moment-helper.js
Last active June 12, 2017 06:00
Convert Timezones in and out of System in a simple way!
//https://gist.github.com/NTICompass/9375143
/**
* Gets Date based on PHP formats into Moment Format.
* @param {[type]} m [description]
* @return {[type]} [description]
*/
(function(m){
/*
* PHP => moment.js
*
@geilt
geilt / favorites.php
Created November 22, 2016 18:44
Favorites System
<?php
// Create page in Wordpress called "Favorites"
// Access by calling /favorites?add_favorite=post_id, /favorites?remove_favorite=post_id
// in PHP this would be $link = '/favorites?add_favorite=' . get_the_ID();
//page-favorites.php
if(is_user_logged_in()){
$favorites = get_user_meta(get_current_user_id(), 'favorites', true);
if(!empty($_GET['add_favorite'])){
if(empty($favorites)) $favorites = array();
$key = array_search($_GET['add_favorite'], $favorites);
add_lead - adds a new lead to the vicidial_list table with several fields and options
NOTE: api user for this function must have modify_leads set to 1 and user_level
must be set to 8 or higher
REQUIRED FIELDS-
phone_number - must be all numbers, 6-16 digits
phone_code - must be all numbers, 1-4 digits, defaults to 1 if not set
list_id - must be all numbers, 3-12 digits, defaults to 999 if not set
source - description of what originated the API call (maximum 20 characters)
@geilt
geilt / Vagrant
Last active August 29, 2015 14:24
Vagrant bootstrap
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
adv: {
findOne: function(args){
return Loan.findOne(args)
.populate('broker')
.populate('borrower')
.populate('createdBy')
.populate('updatedBy')
.populate('notes')
.populate('investors')
@geilt
geilt / gist:97889b63b1951d40bb4e
Last active August 29, 2015 14:06
Combining Tables in Waterline with Promises.
function findArgs(params, callback) {
params.args.sort = { key : 1, order: 0};
var type = '';
if(params.args.hasOwnProperty('type')) {
type = params.args.type;
delete params.args.type;
}
var finder = Meta.find(params.args)
.then( function(meta) {
@geilt
geilt / highlight-menu
Created September 12, 2014 17:25
Highlight a menu item based on URL. Modify to your needs
/**
* Highlight Current Menu Item
*/
var currentLocation = window.location.pathname;
$('#top-menu a').each( function(){
if( $(this).attr('href') == currentLocation ){
$(this).closest('li').addClass('active');
$(this).closest('.main_menu').addClass('active');
}
});
@geilt
geilt / social-share.php
Last active December 6, 2021 19:18
Social Share
//Example with Wordpress
$url = get_the_permalink();
$image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumb' );
$description = get_the_excerpt();
$title = get_the_title();
echo get_share_link($url, $image, $title, $description, 'facebook');
echo get_share_link($url, $image, $title, $description, 'twitter');
echo get_share_link($url, $image, $title, $description, 'reddit');