Skip to content

Instantly share code, notes, and snippets.

@jbeales
jbeales / barchart.rb
Created Oct 14, 2020 — forked from ttscoff/barchart.rb
Command line bar chart from JSON data (for GeekTool, et al)
View barchart.rb
#!/usr/bin/env ruby
# encoding: utf-8
# Brett Terpstra 2013, WTF license <http://www.wtfpl.net/txt/copying/>
# Outputs a vertical bar chart from date-based JSON data
# Requires the JSON rubygem: `[sudo] gem install json`
require 'date'
require 'open-uri'
require 'rubygems'
require 'json'
@jbeales
jbeales / HasRemovableGlobalScopes.php
Last active May 19, 2019
A trait that makes it easier to remove Global Scopes from Laravel models. See https://johnbeales.com/2019/remove-model-global-scopes-laravel-nova/ for details.
View HasRemovableGlobalScopes.php
<?php
namespace App\Concerns;
use Closure;
use Illuminate\Database\Eloquent\Scope;
use Illuminate\Support\Arr;
trait HasRemovableGlobalScopes {
@jbeales
jbeales / export-directory-repos.sh
Last active Oct 17, 2018
A bash script to separate directories from within a large git repository into their own repository, maintaining relevant history
View export-directory-repos.sh
#!/bin/bash
# Enter the paths in the main repo to the subdirectories you want to extract
# Separate paths with spaces or newlines
repos=(
artwork
checklists
code/comingsoon
code/utility
)
@jbeales
jbeales / usps-abbreviations.php
Last active Feb 4, 2020
The official USPS abbreviations used in City & Street names, as a PHP array.
View usps-abbreviations.php
<?php
// based on: http://pe.usps.gov/text/pub28/28apc_002.htm
$usps_abbreviations = [
'ALLEY' => 'ALY',
'ANNEX' => 'ANX',
'ARCADE' => 'ARC',
'AVENUE' => 'AVE',
'BAYOO' => 'BYU',
'BEACH' => 'BCH',