Skip to content

Instantly share code, notes, and snippets.

View coreymcmahon's full-sized avatar

Corey McMahon coreymcmahon

View GitHub Profile
@coreymcmahon
coreymcmahon / helpers.php
Last active April 4, 2021 07:42
Generate a "version number" for a PHP/Laravel application
<?php
use Carbon\Carbon;
use Illuminate\Support\Arr;
if (!function_exists('version')) {
/**
* Attempts to determine the current version of the application, based on `version` set in config/app.php and either
* the file public/version.html (which should be created during the build process) or by exec'ing Git commands directly
* at runtime. This results in a string of the format `<app-version>-<hash> (<last-modified>)`
@coreymcmahon
coreymcmahon / SignInWithApple.php
Created March 17, 2021 04:28
Generate a client_secret for "Sign in with Apple"
<?php
declare(strict_types=1);
use Lcobucci\JWT\Signer\Ecdsa\Sha256;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Encoding\UnixTimestampDates;
use Lcobucci\JWT\Decoder;
use Lcobucci\JWT\Encoder;
use Lcobucci\JWT\Encoding\CannotDecodeContent;
@coreymcmahon
coreymcmahon / GooglePlay.php
Created January 17, 2021 05:34
Check the current version of an Android app in the Google Play Store
<?php
/**
* @author Corey Mcmahon <[email protected]>
* @date: 15 January 2021
*/
declare(strict_types=1);
namespace Foodkit\AppStores;
@coreymcmahon
coreymcmahon / ITunes.php
Created January 17, 2021 05:31
Check the current version of an iOS app in the iTunes store
<?php
/**
* @author Corey Mcmahon <[email protected]>
* @date: 15 January 2021
*/
declare(strict_types=1);
namespace Foodkit\AppStores;
@coreymcmahon
coreymcmahon / reset-postgres-sequences.sql
Last active June 16, 2020 05:52
Reset Postgres sequences
-- Get all relations from database
SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
@coreymcmahon
coreymcmahon / logging.php
Created April 23, 2019 14:13
Example logging configuration for Laravel, going to stdout.
<?php
return [
'default' => env('LOG_CHANNEL', 'stack'),
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
@coreymcmahon
coreymcmahon / docker-compose.yml
Created April 23, 2019 13:34
Example Docker Compose file for a Laravel application.
version: '3.7'
services:
# foodkit php api
app:
container_name: foodkit.app
build:
context: ./docker/app
dockerfile: Dockerfile
image: foodkitapp.io/app
init: true
@coreymcmahon
coreymcmahon / CleanTempCommand.php
Last active April 28, 2019 05:28
Demonstration of a Laravel console command.
<?php
namespace App;
use Illuminate\Console\Command;
class CleanTempCommand extends Command
{
protected $signature = "app:clean-temp";
@coreymcmahon
coreymcmahon / CleanTempCommand.php
Created April 18, 2019 06:42
Demonstration of a Symfony console command.
<?php
namespace App;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CleanTempCommand extends Command
{
@coreymcmahon
coreymcmahon / product.json
Created August 18, 2018 06:23
Frontend interviewee technical task - Test data
{
"id": 14557,
"name": "Flat White",
"price": 125,
"before_sale_price": null,
"description": "Freshly-ground beans and steamed milk",
"full_description": "Freshly-ground beans and steamed milk",
"order": 1,
"category": {
"id": 1727,