Skip to content

Instantly share code, notes, and snippets.

View crmpicco's full-sized avatar
🏴󠁧󠁢󠁳󠁣󠁴󠁿
Blahem

Craig R Morton crmpicco

🏴󠁧󠁢󠁳󠁣󠁴󠁿
Blahem
View GitHub Profile
@crmpicco
crmpicco / course.coffee
Created January 8, 2016 13:30
CoffeeScript Scoping Issue
$ = window.jQuery = require("jquery")
Course =
init: ->
$('.js-product-overlay').on 'click', (e) =>
@viewProductClickHandler(e, MediaDetection)
@preSelectItemSize()
@crmpicco
crmpicco / ImpageImporterSpec.php
Created March 3, 2016 13:39
it_imports_image_assets
function it_imports_image_assets(
Filesystem $filesystem,
EntityManager $entityManager,
Finder $finder,
SplFileInfo $file1,
SplFileInfo $file2
) {
$imageImportPath = '/var/www/crmpicco/app/files/images/rfc-1872/';
$filesystem->exists($imageImportPath)->willReturn(true);
@crmpicco
crmpicco / .bash_profile
Created July 8, 2016 07:32
Git autocomplete on Mac OSX El Capitan
CRMPiccos-MacBook:portfolio crmpicco$ cat ~/.bash_profile
alias ll='ls -lG'
alias composer="php /usr/local/bin/composer.phar"
if [ -f `brew --prefix`/usr/local/git/contrib/completion/git-completion.bash ]; then
. `brew --prefix`/usr/local/git/contrib/completion/git-completion.bash
fi
CRMPiccos-MacBook:portfolio crmpicco$ locate git-completion.bash
/usr/local/git/contrib/completion/git-completion.bash
@crmpicco
crmpicco / PdoExceptionListener.php
Created July 22, 2016 06:04
An exception listener to pickup PDOExceptions thrown in the codebase.
<?php
/**
* An exception listener to pickup PDOExceptions thrown in the codebase.
*
* @author Craig R Morton <crmpicco@aol.com>
* @date 22-07-2016
*/
namespace AppBundle\EventListener;
@crmpicco
crmpicco / isoCodeToCountry.php
Created August 16, 2017 15:34
isoCodeToCountry
function isoCodeToCountry($code)
{
$code = strtoupper($code);
$countryList = array(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
@crmpicco
crmpicco / ga_event_to_multiplue_trackers.js
Created December 11, 2017 15:39
Google Analytics - Send event to multiple trackers
if ("ga" in window) {
// we have multiple trackers, one for region and one for global, so we need to iterate over each
// tracker and send the event data to each
trackers = ga.getAll();
$.each(trackers, function(i, tracker) {
if (tracker) {
tracker.send('event', category, action, label);
}
});
}
@crmpicco
crmpicco / SubscriptionDaysPastDue.php
Created March 20, 2018 07:45
Get Subscription Days Past Due
$subscriptionRenewalDate = \DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', $subscription->currentTermEnd));
$now = new \DateTime('now');
$daysPastDue = $now->diff($subscriptionRenewalDate)->format('%a');
@crmpicco
crmpicco / getBraintreeSubscriptions.php
Created July 9, 2018 07:55
getBraintreeSubscriptions
/**
*
* @param string $filepath
* @return array
*/
private function getBraintreeSubscriptions(string $filepath) : array
{
// open the exported Braintree CSV file
$subscriptions = [];
if (false !== ($handle = fopen($filepath, 'r'))) {
@crmpicco
crmpicco / braintree-paypal-api-v3-hide-pp.js
Created August 1, 2018 03:21
Braintree PayPal API v3 hidePrettyPayPal
'use strict';
var paypalButton = document.getElementById('paypal');
var paypalEmail = document.getElementById('bt-pp-email');
var paypalCancel = document.getElementById('braintree-paypal-loggedin');
function displayPrettyPayPal(payload) {
paypalEmail.innerHTML = payload.details.email;
$('#braintree-paypal-loggedin').fadeIn('slow');
}
@crmpicco
crmpicco / braintree-paypal-loggedin.html
Last active August 1, 2018 05:38
Braintree JS v3 markup
<div id="braintree-paypal-loggedin"
style='
display: block;
max-width: 500px;
overflow: hidden;
padding: 16px;
background-image: url("https://checkout.paypal.com/pwpp/2.15.7/images/paypal-small.svg"), none;
background-position: 20px 50%; background-repeat: no-repeat;
background-size: 13px 15px;
border-top: 1px solid rgb(209, 212, 214);