Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
coreymcmahon / helpers.php
Last active Apr 4, 2021
Generate a "version number" for a PHP/Laravel application
View helpers.php
<?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 Mar 17, 2021
Generate a client_secret for "Sign in with Apple"
View SignInWithApple.php
<?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 Jan 17, 2021
Check the current version of an Android app in the Google Play Store
View GooglePlay.php
<?php
/**
* @author Corey Mcmahon <corey@foodkit.io>
* @date: 15 January 2021
*/
declare(strict_types=1);
namespace Foodkit\AppStores;
@coreymcmahon
coreymcmahon / ITunes.php
Created Jan 17, 2021
Check the current version of an iOS app in the iTunes store
View ITunes.php
<?php
/**
* @author Corey Mcmahon <corey@foodkit.io>
* @date: 15 January 2021
*/
declare(strict_types=1);
namespace Foodkit\AppStores;
View reset-postgres-sequences.sql
-- 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 Apr 23, 2019
Example logging configuration for Laravel, going to stdout.
View logging.php
<?php
return [
'default' => env('LOG_CHANNEL', 'stack'),
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
@coreymcmahon
coreymcmahon / docker-compose.yml
Created Apr 23, 2019
Example Docker Compose file for a Laravel application.
View docker-compose.yml
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 Apr 28, 2019
Demonstration of a Laravel console command.
View CleanTempCommand.php
<?php
namespace App;
use Illuminate\Console\Command;
class CleanTempCommand extends Command
{
protected $signature = "app:clean-temp";
@coreymcmahon
coreymcmahon / CleanTempCommand.php
Created Apr 18, 2019
Demonstration of a Symfony console command.
View CleanTempCommand.php
<?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 Aug 18, 2018
Frontend interviewee technical task - Test data
View product.json
{
"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,