Skip to content

Instantly share code, notes, and snippets.

View danjohnson95's full-sized avatar

Dan danjohnson95

View GitHub Profile
@danjohnson95
danjohnson95 / 1kb-challenge.html
Last active November 13, 2025 08:44
A Formula 1 style reaction game, coming in at under 1kb
<!-- http://pico.lat/Y6Gez --><style>body{background:#111;color:#fff;text-align:center}#l{display:flex;justify-content:center;gap:10px;margin:30px 0}#l p{width:60px;height:60px;border-radius:50%;background:#333;border:2px solid #666}.on{background:red!important}#r{font-size:24px}#i{color:#888;margin:10px 0}</style><div id=l><p><p><p><p><p></div><div id=i>Press any key to start</div><div id=r></div><script>let t,s,f=0,d=document,q="getElementById",ht="innerHTML",fE="forEach",kd="onkeydown",cN="className",m=Math,dt=Date,sT=setTimeout,res=d[q]("r"),inf=d[q]("i");function st(){if(s)return;s=1,f=0,res[ht]="",inf[ht]="Wait for lights...";let e=d.querySelectorAll("#l p");e[fE]((t=>t[cN]=""));let n=0;!function r(){n<5?(e[n++][cN]="on",sT(r,800*m.random()+400)):sT((()=>{f||(e[fE]((t=>t[cN]="")),inf[ht]="GO! Press any key!",t=dt.now(),d[kd]=()=>{if(f)return;f=1,s=0;let e=dt.now()-t;res[ht]=e+"ms",inf[ht]="Press any key to restart",d[kd]=st})}),2e3*m.random()+1e3)}()}d[kd]=st;</script>
@danjohnson95
danjohnson95 / iphone-stock.js
Created October 1, 2024 14:26
iphone-stock.js
const stores = {
"R363": "Aberdeen, Union Square",
"R482": "Basingstoke, Festival Place",
"R335": "Bath, SouthGate",
"R313": "Belfast, Victoria Square",
"R118": "Birmingham, Birmingham",
"R244": "Brighton, Churchill Square",
"R252": "Bristol, Bristol",
"R393": "Bristol, Cribbs Causeway",
"R496": "Bromley, Bromley",

Keybase proof

I hereby claim:

  • I am danjohnson95 on github.
  • I am danjohnson95 (https://keybase.io/danjohnson95) on keybase.
  • I have a public key ASBHLBFALXyBeCgpuq2usiZ0g7F7e51CbPnvWTYdC1q_Ngo

To claim this, I am signing this object:

@danjohnson95
danjohnson95 / commit-msg
Created October 6, 2017 13:39
A git hook for enforcing a commit message standard
#!/bin/bash
#
# The link to the wiki page detailing these standards
url='https://github.com/designmynight/dmn/wiki/Semantic-Commit-Messages'
# The regular expression in which the commit message should match
regex='^(fix|feat|chore|refactor|test|style|docs)(:\s)([\S].{1,60}[\S])'
# What we'll say
error_msg="Aborting commit due to incorrect message format.\nPlease see $url"
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Contracts\ProductDataInterface;
use App\Models\Product;
class ProductServiceProvider extends ServiceProvider
{
/**
* Bind the ProductDataInterface to the implementation
<?php namespace App\Contracts;
interface ProductDataInterface
{
/**
* Sets the title of the product
* @param string $title
* @return $this
*/
public function setTitle($title);
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Contracts\ProductDataInterface;
class Product extends Model implements ProductDataInterface
{
protected $table = "products";
/**
<?php namespace App\Repos;
use App\Contracts\ProductDataInterface;
class ProductRepository
{
/**
* An instance of the Product model
* @var \App\Contracts\ProductDataInterface
*/
<?php namespace App\Http\Controllers;
use App\Repos\ProductRepository;
class ProductController extends Controller
{
/**
* An instance of the Product Repository
* @var \App\Repos\ProductRepository
*/
@danjohnson95
danjohnson95 / search.js
Created February 15, 2017 16:24
Node search engine
var http = require('http');
module.exports = function(){
var server;
var port = 3050;
startServer = function(){
server = http.createServer(handleRequest);
server.listen(port);