Skip to content

Instantly share code, notes, and snippets.

@alexpgates
alexpgates / Use DayOne Journal data with php
Created April 6, 2011 20:05
Use DayOne data with php.
<?php
// DayOne is a nice little journaling app for iOS / Mac (available via App Store).
// This code requires php_class_lib available here: https://github.com/jsjohnst/php_class_lib
include('php_class_lib/classes/parsers/plist/PlistParser.inc');
// grab filenames for all of your journal entries
$entries = array();
if ($handle = opendir('/path/to/your/Journal.dayone/entries')) {
@alexpgates
alexpgates / wp-page-migrate.php
Last active November 6, 2015 17:05
Simple WP Page Migrations
<?php
/**
* Plugin Name: wp-page-migrate
* Description: Edit the plugin to define your pages. Activate this plugin to add the pages to your WP install.
* Version: 0.0.1
* Author: Alex P. Gates
*
* This is a simple plugin that, when activated, creates pages on a WordPress site if they don't already exist.
* This is useful for keeping local / staging / production in sync and for keeping pages in sync when working
* with lots of custom page templates with multiple people on the same project.
# Use this to avoid syncing wp-uploads directory when working locally on a WordPress website
# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpe?g|gif|ico)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
@alexpgates
alexpgates / Manually validate Stripe webhooks in Laravel 5.5
Last active October 5, 2017 13:50
I use this method on a StripeWebhook model. Based on the guide here: https://stripe.com/docs/webhooks#verify-manually
public function isValid(\Illuminate\Http\Request $request){
// Grab the Stripe-Signature header
$header_signature = $request->header('Stripe-Signature');
// sets variables $t and $v1 with their values, (and any other elements that stripe may pass along that we'll ignore)
foreach(explode(',', $header_signature) as $key => $val){
$prefix = str_before($val, '=');
$$prefix = str_after($val, '=');
}
@alexpgates
alexpgates / validate-stripe-webhook-laravel5.5.php
Last active October 5, 2017 13:55
isValid() method in my StripeWebhook model
<?php
public function isValid(\Illuminate\Http\Request $request){
// Grab the Stripe-Signature header
$header_signature = $request->header('Stripe-Signature');
// sets variables $t and $v1 with their values, (and any other elements that stripe may pass along that we'll ignore)
foreach(explode(',', $header_signature) as $key => $val){
$prefix = str_before($val, '=');
#!/bin/bash
NAME=${PWD##*/}
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS \`$NAME\`"
@alexpgates
alexpgates / gist:f592c199f212aca43ddd6087572a5d37
Created October 23, 2019 23:58
Alias to nicely list latest branches
alias branches="git for-each-ref --count=15 --sort=-committerdate refs/heads/ --format='%(color:blue)%(committerdate:relative): %(color:green)%(refname:short)'"
@alexpgates
alexpgates / composer_versions_cheatsheet.md
Created November 13, 2019 16:02 — forked from calebporzio/composer_versions_cheatsheet.md
Composer version symbol cheatsheet
...
"require": {
    "vendor/package": "1.3.2", // exactly 1.3.2 (exact)

    // >, <, >=, <= | specify upper / lower bounds
    "vendor/package": ">=1.3.2", // anything above or equal to 1.3.2
    "vendor/package": "<1.3.2", // anything below 1.3.2

 // * | wildcard
@alexpgates
alexpgates / .zshrc
Created January 12, 2021 15:31
As a cow if your remote Horizon queue is running
alias cow='ssh your-app "cd ~/your-app.com/current && php artisan horizon:status" | cowsay | lolcat'