Skip to content

Instantly share code, notes, and snippets.

@jeremykendall
jeremykendall / sphp
Created May 8, 2018 14:58
Naive OSX brew PHP switcher
#!/usr/bin/env bash
set -u
set -e
set -o pipefail
if [ $# -ne 1 ]; then
echo "Usage: sphp [phpversion]"
exit 1
fi
@jeremykendall
jeremykendall / docker-compose.yml
Created December 16, 2016 02:18
My jankie, but functional, PHP/MySQL/nginx docker env
version: '2'
services:
nginx:
build:
context: ./
dockerfile: ./resources/nginx/nginx.dockerfile
volumes:
- ./:/var/www/html
- ./resources/nginx/default.conf:/etc/nginx/conf.d/default.conf
@jeremykendall
jeremykendall / HalSerializer.php
Created October 25, 2016 15:53
Quick and dirty Fractal HAL serializer
<?php
/**
* The MIT License (MIT)
* Copyright (c) 2016 Alegion (http://www.alegion.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
<h1>Super Awesome Session-Based Rate Limiter</h1>
<?php
session_start();
$blocked = false;
$message = "You may pass.";
$now = new \DateTime();
$attempts = isset($_SESSION['attempts']) ? $_SESSION['attempts'] : [];
@jeremykendall
jeremykendall / set-cookie.php
Created September 28, 2016 13:40
Pseudo-code for exercise one
@jeremykendall
jeremykendall / scratch-pad.cql
Last active June 23, 2016 14:54
OSMI Graph Query Scratchpad
// Top 10 self diagnoses WITHOUT a corresponding professional diagnosis
MATCH (selfDiagnosis:Disorder)<-[:SELF_DIAGNOSIS]-(p:Person)
WHERE NOT (p)-[:PROFESSIONAL_DIAGNOSIS]->()
RETURN selfDiagnosis.name, COUNT(p) AS diagnoses
ORDER BY diagnoses DESC
LIMIT 10;
// Top 10 Diagnoses: Self-diagnoses vs MD-diagnoses
MATCH (d:Disorder)<-[sd:SELF_DIAGNOSIS]-()
WITH d, COUNT(sd) AS selfDiagnoses
@jeremykendall
jeremykendall / debug.log
Created June 16, 2016 14:59
Troubleshooting Neo4j Spatial Warnings in debug.log
# ... snip ...
2016-06-16 14:03:13.208+0000 INFO [o.n.k.i.DiagnosticsManager] JIT compiler: HotSpot 64-Bit Tiered Compilers
2016-06-16 14:03:13.208+0000 INFO [o.n.k.i.DiagnosticsManager] VM Arguments: [-XX:+UseG1GC, -XX:-OmitStackTraceInFastThrow, -XX:hashCode=5, -XX:+AlwaysPreTouch, -XX:+UnlockExperimentalVMOptions, -XX:+TrustFinalNonStaticFields, -XX:+DisableExplicitGC, -Dunsupported.dbms.udc.source=tarball, -Dfile.encoding=UTF-8]
2016-06-16 14:03:13.209+0000 INFO [o.n.k.i.DiagnosticsManager] Java classpath:
2016-06-16 14:03:13.212+0000 INFO [o.n.k.i.DiagnosticsManager] [bootstrap] /usr/lib/jvm/jdk1.8.0_45/jre/lib/jsse.jar
2016-06-16 14:03:13.213+0000 INFO [o.n.k.i.DiagnosticsManager] [classpath + loader.0] file:/opt/neo4j-enterprise-3.0.2/lib/neo4j-management-3.0.2.jar
2016-06-16 14:03:13.213+0000 INFO [o.n.k.i.DiagnosticsManager] [classpath + loader.0] file:/opt/neo4j-enterprise-3.0.2/lib/neo4j-unsafe-3.0.2.jar
2016-06-16 14:03:13.213+0000 INFO [o.n.k.i.DiagnosticsManager] [classpath + loader.0
Verifying that "jeremykendall.id" is my Blockstack ID. https://onename.com/jeremykendall
@jeremykendall
jeremykendall / ContactList.vue
Last active April 30, 2016 19:55
Vue component data n00b issues
<template>
<div>
<div class="row">
<div class="col-md-12">
<div class="filter fdiv" id="filter">
<button type="button" v-on:click="toggleSelectAll" class="btn btn-primary">
<span v-if="selectAllActive"><i class="fa fa-check-square"></i> <span class="micit-button-label">Deselect</span> all</span>
<span v-else><i class="fa fa-square"></i> <span class="micit-button-label">Select</span> all</span>
</button>
<div class="btn-group" role="group">
@jeremykendall
jeremykendall / router.php
Created February 17, 2016 23:17
Built in PHP web server routing issue
<?php
// This goes in app root
$_SERVER['SCRIPT_NAME'] = 'index.php';
include 'public/index.php';