Skip to content

Instantly share code, notes, and snippets.

View kublermdk's full-sized avatar

Michael Kubler kublermdk

View GitHub Profile
@kublermdk
kublermdk / yii2-mongodb-srv-support-test.php
Created October 28, 2019 10:21
A PHP command line script for checking the REGEX of the mongodb+srv support
<?php
/**
* @return string database name
*/
function getDefaultDatabaseName($dsn)
{
if (preg_match('/^mongodb(:|\+srv:)\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
// Updated Pattern: /^mongodb(:|\+srv:)\\/\\/.+\\/([^?&]+)/s
// Original Pattern: '/^mongodb:\\/\\/.+\\/([^?&]+)/s'
@kublermdk
kublermdk / Example Customer and Customer Transaction.js
Last active May 10, 2020 09:23
An example of a Customer and Customer Transaction for the article "Advanced Filtering with MongoDB Aggregation Pipelines"
{
"customer": {
"_id": "5eb3d000af2f5c073c089cd2", // ObjectId
"name": "Michael Kubler",
"dateOfBirth": 467683200, // Unix time
"state": "SA",
"gender": "male",
"status": "active",
"createdAt": 1588760101, // Unix time
"updatedAt": 1588760914 // Unix time
@kublermdk
kublermdk / ExampleGeneralMongoDBAggregations.js
Created May 10, 2020 09:09
An example of the MongoDB Aggregation pipelines and commands used for some general filters. View
// -----------------------------------------------------------------
// Applying aggregation pipeline #1 Customer - HAVE
// -----------------------------------------------------------------
db.command({
"aggregate": "app.customer",
"pipeline": [{
"$match": {
"$and": [{
// -- Ensure the customers we are selecting are active and have a Firebase token so we can send them a push notification
"status": "active",
@kublermdk
kublermdk / exampleGoogleAutoMLPrediction.php
Created October 6, 2020 17:15
Example Google AutoML Prediction with a Google Cloud Storage source
<?php
// --------------------------------------------------
// Example Google Cloud AutoML Prediction
// --------------------------------------------------
// @author Michael Kubler
// @date 2020-10-07th
// This is a cut down gist of what you need to
// make a Google Cloud AutoML (Auto Machine Learning)
// prediction request, based off an already uploaded

Keybase proof

I hereby claim:

  • I am kublermdk on github.
  • I am kublermdk (https://keybase.io/kublermdk) on keybase.
  • I have a public key whose fingerprint is A4E7 8586 B2E9 C893 899E A0E6 C1C8 2A76 4A27 EB4F

To claim this, I am signing this object:

@kublermdk
kublermdk / stripe-mock-install.sh
Last active November 7, 2022 09:44
Stripe Mock Installer for Vagrant VM
#!/bin/bash
## ============================
## Stripe Mock Install
## ============================
# @license http://opensource.org/licenses/BSD-3-Clause
# The Go language is used for the Stripe Mock server
# Can't just run > "sudo apt-get install golang"
# The Ubuntu default is go v1.6 which isn't supported, you get an error about sort.Slice e.g:
# src/github.com/stripe/stripe-mock/server/server.go:478: undefined: sort.Slice
@kublermdk
kublermdk / stripe-mock-php-sdk-client-setup.php
Last active November 7, 2022 09:44
Setting up the Stripe PHP SDK to use the stripe-mock server
<?php
include_once './vendor/autoload.php';
use Stripe\ApiRequestor;
use Stripe\Stripe;
// ---------------------------------------
// Stripe Mock Setup
// ---------------------------------------
@kublermdk
kublermdk / GoogleStorageAdapter.php
Last active November 7, 2022 09:43
Update Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter to support VISIBILITY_NOT_SET
<?php
namespace app\adaptors;
use Google\Cloud\Storage\Acl;
use League\Flysystem\AdapterInterface;
/**
* @package app\adaptors\GoogleStorageAdapter
* Updated by Michael Kubler @kublermdk to support VISIBILITY_NOT_SET
@kublermdk
kublermdk / GoogleCloudFilesystem.php
Created January 28, 2022 09:45
Update creocoder\flysystem\GoogleCloudFilesystem to support the GoogleStorageAdapter which allows VISIBILITY_NOT_SET
<?php
/**
* @link https://github.com/creocoder/yii2-flysystem
* @copyright Copyright (c) 2015 Alexander Kochetov
* @license http://opensource.org/licenses/BSD-3-Clause
*
* Updated by Michael Kubler @kublermdk to support VISIBILITY_NOT_SET by using the different Google Storage Adapter
*/
namespace app\adaptors;