Skip to content

Instantly share code, notes, and snippets.

John P. Bloch johnpbloch

View GitHub Profile
@johnpbloch
johnpbloch / powerline-jpb.base.bash
Created Aug 4, 2017
My custom theme for bash_it based on powerline multiline
View powerline-jpb.base.bash
. "$BASH_IT/themes/powerline-multiline/powerline-multiline.base.bash"
function __powerline_docker_compose_prompt {
local prompt
if docker-compose config &>/dev/null
then
prompt+="${DOCKER_CHAR}"
else
return
fi
View native.php
<?php
// Let's get a list of Post IDs that have given post meta item matching a pattern, but we only want unique values
// And we want the items ordered correctly so that keys aren't skipping numbers, etc.
$post_ids = array_values( array_unique( wp_list_pluck( array_filter( (new WP_Query(['posts_per_page' => -1]))->posts, function($post) {
return (bool) preg_match( '/some-pattern/i', $post->some_meta_value );
} ), 'ID' ) );
@johnpbloch
johnpbloch / Dockerfile
Created Nov 5, 2016
Kibana with Sense installed
View Dockerfile
FROM kibana:4.5
RUN gosu kibana /opt/kibana/bin/kibana plugin --install elastic/sense
View arr.php
<?php
// Assuming https://wiki.php.net/rfc/arrow_functions makes it into PHP core, we can do this:
class Arr extends ArrayObject
{
static function make($array)
{
return new self($array);
}
View date-diff.php
<?php
/** @var int $start The start timestamp */
/** @var int $end The end timestamp */
$days = ceil( abs( $end - $start ) / DAY_IN_SECONDS );
if ( date( 'Ymd', $start ) !== date( 'Ymd', $end ) ) {
$days += 1;
}
View manifest.json
{
"name": "10up",
"hostname": [
"10up.dev",
"www.10up.dev"
],
"maintainers": [
{
"name": "Taylor Lovett",
"email": "taylor.lovett@10up.com"
View composer.json
{
"name": "johnpbloch/test-4",
"license": "MIT",
"authors": [
{
"name": "John P Bloch",
"email": "me@johnpbloch.com"
}
],
"repositories":[
You can’t perform that action at this time.