Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jeremeamia's full-sized avatar
🌵
WFH in AZ

Jeremy Lindblom jeremeamia

🌵
WFH in AZ
View GitHub Profile
@jeremeamia
jeremeamia / keybase.md
Created June 10, 2021 23:39
Keybase proof

Keybase proof

I hereby claim:

  • I am jeremeamia on github.
  • I am jeremeamia (https://keybase.io/jeremeamia) on keybase.
  • I have a public key ASCBfb8yAYogwzk5U3UqoPp1oPzXnIUTnCk-9QG7IeIJTQo

To claim this, I am signing this object:

@jeremeamia
jeremeamia / parse-slack-request.php
Created June 8, 2021 17:48
Quick and dirty Slack request parsing in PHP
<?php
function parse_slack_request(string $body): array
{
if (empty($body)) {
return [];
}
if ($body[0] === '{') {
$data = json_decode($body, true);
@jeremeamia
jeremeamia / recursive-glob.php
Created April 8, 2020 22:41
Recursive Glob implementation
function glob_recursive(string $dir, string $pattern, int $flags = GLOB_BRACE): Iterator
{
$path = realpath($dir);
if ($path === false) {
throw new RuntimeException("Invalid dir: {$dir}");
}
$glob = function (string $path) use ($pattern, $flags, &$glob) {
yield from glob("{$path}/{$pattern}", $flags);
foreach (new DirectoryIterator($path) as $file) {
@jeremeamia
jeremeamia / main.go
Last active January 24, 2020 00:30
Golang support for "path" struct tag fro resolving URLs
package main
import (
"fmt"
"reflect"
"strings"
)
type MyUrlParams struct {
UserId string `path:"user",json:"-"`
@jeremeamia
jeremeamia / php-library-building.md
Created November 28, 2018 09:24
List of resources to help with building libraries
@jeremeamia
jeremeamia / fn.php
Last active April 19, 2017 18:15
Functional PHP tomfoolery
<?php
namespace fn {
use Closure as Fn;
use InvalidArgumentException as IAE;
const SKIP = "\0...\0";
/**
* @param callable $fn
@jeremeamia
jeremeamia / laravel-flysystem-aws.php
Created May 29, 2015 22:03
Code needed for Laravel for S3 Flysystem integration
<?php
/**
* Create an instance of the Amazon S3 driver.
*
* @param array $config
* @return \Illuminate\Contracts\Filesystem\Cloud
*/
public function createS3Driver(array $config)
{
@jeremeamia
jeremeamia / binding-test.php
Last active August 29, 2015 14:15
PHP closure bindings... yeah, I know...
<?php
// Require composer autoloader after installing superclosure 2.0.
require '/vendor/autoload.php';
class ClosureCreator
{
public function getClosures()
{
$f1 = function () {};
@jeremeamia
jeremeamia / Marshaler.php
Last active August 29, 2015 14:07
Idea for DynamoDB helper that supports the new document data model.
<?php
namespace Aws\DynamoDb;
/**
* Marshals JSON documents or array representations of JSON documents into the
* parameter structure required by DynamoDB. Also allows for unmarshaling. Does
* not support binary (B) or set (*S) types, since they are not supported
* explicitly in JSON.
*/
class Marshaler