Skip to content

Instantly share code, notes, and snippets.

View davebarnwell's full-sized avatar

Dave Barnwell davebarnwell

View GitHub Profile
@davebarnwell
davebarnwell / index.html
Last active October 24, 2022 14:35
add bar graph as background to html table column
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML table with bar graph background in one or more columns</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="grid">
<!-- ROW -->
@davebarnwell
davebarnwell / Colour.php
Last active December 15, 2022 09:30
Algorithm to create heatmap colors
View Colour.php
<?php
class Colour
{
/**
* Maps a float value to a CSS HSL color
*
* 0 : blue
@davebarnwell
davebarnwell / uk_post_code.html
Created October 16, 2021 14:53 — forked from frontweb/uk_post_code.html
Plot a UK post code on Google Maps
View uk_post_code.html
<html>
<head>
<title>UK Post Code</title>
<style type="text/css">
#map_canvas { width:300px; height:200px; }
</style>
<script type="text/javascript">
function initialize() {
@davebarnwell
davebarnwell / deploy.sh
Created October 7, 2021 14:10 — forked from cagartner/deploy.sh
Laravel Push deploy Github actions example
View deploy.sh
#!/bin/sh
set -e
vendor/bin/phpunit
(git push) || true
git checkout production
git merge master
View LogAfterRequest.php
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Log;
class LogAfterRequest {
public function handle($request, \Closure $next)
{
return $next($request);
}
@davebarnwell
davebarnwell / pass-slots.md
Created May 6, 2020 14:25 — forked from loilo/pass-slots.md
Vue: Pass Slots through from Parent to Child Components
View pass-slots.md

Vue: Pass Slots through from Parent to Child Components

The Situation

  • We've got some components A, B and C which provide different slots.
    const A = {
      template: `<div><slot name="a">Default A Content</slot></div>`
    }

const B = {

@davebarnwell
davebarnwell / http-status-codes.md
Last active February 11, 2019 10:21 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes
View http-status-codes.md

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@davebarnwell
davebarnwell / README.md
Last active September 7, 2018 09:37
PHPUnit seed
View README.md

base PHPUnit directory structure

Assumes following dir structure

  ./vendor                  # composer pulling in phpunit
  ./tests                   # directory containing tests namespace prefix \Test\...
  ./tests/run.sh            # This script
  ./tests/phpunit.xml.dist  # PHPUnit xml config
 ./tests/bootstrap.php # bootstrap for php Tests
View BBC-Radio.m3u
#EXTM3U
#EXTINF:-1,BBC - Radio 1
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p
#EXTINF:-1,BBC - Radio 2
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p
#EXTINF:-1,BBC - Radio 3
http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-aac-lc-a/format/pls/vpid/bbc_radio_three.pls
#EXTINF:-1,BBC - Radio 4
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p
#EXTINF:-1,BBC - Radio 5 live
@davebarnwell
davebarnwell / StrCSV.php
Last active April 24, 2018 16:18
get and put CSVs from a string instead of a file
View StrCSV.php
<?php
class StrCSV
public function strPutCsv($input, $delimiter = ',', $enclosure = '"')
{
// Open a memory "file" for read/write...
$fp = fopen('php://memory', 'r+');
// ... write the $input array to the "file" using fputcsv()...
fputcsv($fp, $input, $delimiter, $enclosure);
// ... rewind the "file" so we can read what we just wrote...
rewind($fp);