Skip to content

Instantly share code, notes, and snippets.

View lancegliser's full-sized avatar

Lance Gliser lancegliser

View GitHub Profile
@lancegliser
lancegliser / marketing-platform-example.php
Last active November 19, 2015 22:26
Using the emfluence marketing platform php api library
<?php
$api = new Emfl_Platform_API($api_key);
$data = array();
$data['groupIDs'] = !empty($_POST['groups'])? $_POST['groups'] : '';
$data['originalSource'] = trim( $_POST['source'] );
$data['firstName'] = !empty( $_POST['first_name'] )? trim( $_POST['first_name'] ) : '';
$data['lastName'] = !empty( $_POST['last_name'] )? trim( $_POST['last_name'] ) : '';
$data['title'] = !empty( $_POST['title'] )? trim( $_POST['title'] ) : '';
@lancegliser
lancegliser / getPagedApi.js
Created October 16, 2016 03:03
Pulls down a full paged api using promises and recursive functions. Mostly written against Angular's $http
function getAllPagedData(url){
var data = [];
var page = 1;
return _getPage(page);
function _getPage(page){
return $http.get(url, {params: {format: 'json', page: page}})
.then(function(result){
data = data.concat(result.results);
if( result.next ){
@lancegliser
lancegliser / holdButtonDirective.js
Last active October 21, 2016 20:03
AngularJS Hold Button Directive with feedback
app.directive('holdButton', function($parse, $interval) {
//The framerate of the progress bar, progression will be evaluated every 5ms.
var tickDelay = 10;
var minFill = 5;
return {
restrict: 'A',
scope: {
holdButtonSuccess: '&'
}
@lancegliser
lancegliser / emfluence-marketing-platform.module
Last active October 21, 2016 20:04
A custom Drupal module using the emfluence Marketing Platform api php helper library along with webform based forms.
<?php
/**
* Definitions
*/
define('EMFLUENCE_PLATFORM_API_KEY', 'ff342fde-a672-9fbb-d5aa-0f87487f1682');
define('EMFLUENCE_PLATFORM_ALL_USERS_LIST_ID', 0000);
define('EMFLUENCE_PLATFORM_SUBSCRIBERS_LIST_ID', 000000);
@lancegliser
lancegliser / app.js
Last active October 21, 2016 20:05
Example OAuth consumer code for emailer.emfluence.com. This was extracted from a functioning angularjs 1.3 based site.
// Define route for consuming the returning token, and attach our interceptor
app.config([
'$routeProvider',
'$httpProvider',
'$controllerProvider',
'$compileProvider',
'$filterProvider',
'$locationProvider',
'$sceDelegateProvider',
'$provide',
@lancegliser
lancegliser / bulk-operation-loop.php
Created February 24, 2017 19:32
Runs a given batch operation as many times as possible in a given time span adjusting for execution rate dynamically
<?php
/**
* This controller will run up to the alloted seconds fitting as many operations as possible
* @param int $seconds
* @return array
*/
public function bulk_operation($seconds = NULL, $identifier)
{
$execution_time_limit = $seconds != NULL? $seconds : ini_get('max_execution_time');
/**
* Provides data that can be used to ensure location.reload() behaves the same
* with regard to x and y position across browsers
*
* Introduced because IE goes scroll 0 using window.location.reload, but stays in place for F5.
*
* @param {boolean} [forcedReload]
* Causes the page to always be reloaded from the server if true
*
* @see restoreToSamePosition
@lancegliser
lancegliser / map-windows-shared-drives.php
Last active September 25, 2017 22:12
A better alternative available through COM objects to the madness of using exec('net stat')
<?php
/**
* Creates a temporary network share drive connection to the share
* using windows COM object for the executing PHP identity as a different user
*
* @param string $letter
* @param string $path
* @param string $user
* @param string $password
@lancegliser
lancegliser / vanilla-redux.js
Created October 4, 2017 23:32
An example of using Redux, without the need for React, Vue, Angular, or even a build process
/* globals Redux, settings */
jQuery(document).ready(function(){
reduxSearch(settings);
});
function reduxSearch(settings){
/**
* Constants
@lancegliser
lancegliser / .jshintignore
Last active October 12, 2017 18:55
NPM build scripts for building in place .min files: stylelint, cssnano, jshint, cssnano
**/*.min.js
/libraries