Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jbeales
jbeales / barchart.rb
Created October 14, 2020 12:03 — forked from ttscoff/barchart.rb
Command line bar chart from JSON data (for GeekTool, et al)
#!/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 17:18
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.
<?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 October 17, 2018 19:27
A bash script to separate directories from within a large git repository into their own repository, maintaining relevant history
#!/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 February 4, 2020 01:30
The official USPS abbreviations used in City & Street names, as a PHP array.
<?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',