Skip to content

Instantly share code, notes, and snippets.

View blwsh's full-sized avatar
🔋
Focusing

Ben blwsh

🔋
Focusing
View GitHub Profile
@blwsh
blwsh / better-docker-local-dev.md
Last active October 21, 2020 02:55
An elegant solution to installing docker dependencies twice

If you use a production docker image for your local dev environment it’s very likely one of the builds stages is running a command which installs your dependencies such as npm install, composer install or go get.

Now you don’t want to adjust your production docker image but at the same time, your dependency installs can take a long time and you really don’t want to run the command twice.

An easy solution would be to tell docker to not mount the directory into the container with the rest of your project code but then you don’t get all the useful information provided by your IDE.

Enter docker cp and volume overrides.

Using docker cp and overriding the volume we wish to copy from the container allows us to pull directories such as node_modules out of the built docker image. This is great because it means we don’t need to run our installs twice. It also has the added benefit of reflecting your production environment files better and eliminates the issue of slightly different language versions and in turn, dif

@blwsh
blwsh / j.js
Created December 6, 2019 00:42
window.history.pushState(null, null, 'https://hud.ac/login');
document.write(`<!DOCTYPE html ><html lang="en" dir="ltr"><head><meta http-equiv="X-UA-Compatible" content="IE=Edge" /><meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=yes" /><meta name="description" /><meta name="author" /><meta http-equiv="Content-type" content="text/html; charset=utf-8" /><meta http-equiv="Expires" content="0" /><link rel="shortcut icon" href="https://www.hud.ac.uk/siteassets/images/favicon.ico" /><title> MyHud Login</title><link rel="stylesheet" type="text/css" href="/_layouts/15/1033/styles/Themable/corev15.css?rev=2bpHeX9U8DH09TB5zpJcsQ%3D%3D"/> <script type="text/javascript" src="/_layouts/15/init.debug.js?rev=y6LuQV9XUYvZmmaOw942CQ%3D%3D"></script> <script type="text/javascript" src="/ScriptResource.axd?d=4JmGQv5zMzF5rY-ZMAnDSpUGBrdVB_7nPJuFHMI33yvaPB3mNpqlhDPmafYCK4TPusnGP1TmU2ke9-56oisNwwj1oDI9CxXlEE4BZVbzqCP6_NFgA1IRI59pNVdokeV6fZpeA3xqkiu6dtiM3sQS3P0Fy10yQGKmIUbqw35IlKiEpK0PjhPyxo-OppYTmE
package main
import (
"bufio"
"encoding/csv"
"fmt"
"io"
"log"
"os"
"time"
<?php
function renderRow($row) {
echo "<tr>";
array_walk($row, function($column) { echo "<td>$column</td>"; });
echo "</tr>";
}
// Variables.
$table = 'test';
@blwsh
blwsh / readme.md
Last active April 24, 2021 05:58
Readable Language Translators Spec

Spec

Question 2 (50%)

Create your own more advanced interpreted programming language called MYPL. You must do this using the already written TLM as a base. In other words starting from the components of TLM, build up your own language and interpreter. Your language must have the following enhancements:

@blwsh
blwsh / DynamicOverrideClass.php
Created December 20, 2018 20:33
PHP class that can combine multiple classes and override any of their properties and methods
<?php
/**
* Created by PhpStorm.
* User: ben
* Date: 20/12/2018
* Time: 19:07
*/
use Exception;