Skip to content

Instantly share code, notes, and snippets.

@wmhilton
wmhilton / storageQuota.js
Created Mar 13, 2017
StorageQuota polyfill
View storageQuota.js
// MIT License, Copyright William Hilton <wmhilton@gmail.com>
// Implement the proposed W3C Quota Management API (circa 2017)
navigator.storageQuota = {
get supportedTypes () {
let types = []
if (navigator.webkitTemporaryStorage) types.push('temporary')
if (navigator.webkitPersistentStorage) types.push('persistent')
return types
},
queryInfo (type) {
@wmhilton
wmhilton / git-log-alias.sh
Created May 21, 2014
git lg: the best git log alias
View git-log-alias.sh
#!/bin/bash
git config --global --unset alias.lg; git config --global alias.lg "log --graph --abbrev-commit --decorate --date=relative -10 --format=format:'%C(bold blue)%h%C(reset) %C(bold yellow)%d%C(reset) %C(white)%s%C(reset) %C(green)(%ar)%C(reset) %C(dim white)- %an%C(reset)'"
@wmhilton
wmhilton / ArduinoSerialBypass.ino
Created Jul 19, 2013
Use your Arduino as a direct USB to serial converter! Tested on an Arduino Duemilanove. Probably 3.3V TTL but worked for communicating with my supposedly 5V TTL HerkuleX servo at 115200 baud.
View ArduinoSerialBypass.ino
/*
* Arduino Serial Bypass - use an Arduino as a dumb USB 2 Serial Converter
*
* This code makes the Arduino not interfere with pins 0 and 1
* which are connected to RX and TX on the FTDI chip. This allows
* the data coming from the FTDI USB 2 Serial chip to flow directly
* to another device. Since RX and TX are labeled from the Arduino's
* point of view, don't cross the wires, but plug the device's
* RX wire into the RX pin 0 and the TX wire into the TX pin 0.
*
@wmhilton
wmhilton / NFT.sol
Last active Apr 8, 2021
NFTs 4 All - v1
View NFT.sol
// SPDX-License-Identifier: MIT
// by William Hilton (https://github.com/wmhilton)
// written using remix.ethereum.org
pragma solidity >=0.8.3 <0.9.0;
/**
* @dev ERC-721 interface for accepting safe transfers.
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
*/
interface ERC721TokenReceiver {
@wmhilton
wmhilton / vanilla-cookies.js
Created Jan 24, 2015
Vanilla Cookies - a dead simple yet full-featured JavaScript cookie library
View vanilla-cookies.js
// Vanilla Cookies - a dead simple yet full-featured JavaScript cookie library
// derived from http://stackoverflow.com/a/19189846
/*********************************************************
Gets the value of a cookie.
**********************************************************/
getCookie = function(sName)
{
var oCrumbles = document.cookie.split(';');
for(var i=0; i<oCrumbles.length;i++)
@wmhilton
wmhilton / index.html
Last active Jan 30, 2020
magic portal (isomorphic-git)
View index.html
<div>
<input id="repository" type="text" style="width: 50em" title="Tip: enter a private repo URL to see the credentialManager plugin prompt for a password.">
<button type="button" id="cloneButton">Clone</button>
</div>
<output id="log" style="white-space: pre; font-family: monospace;"></output>
<script src="https://unpkg.com/magic-portal"></script>
<script>
let worker = new Worker("./worker.js")
@wmhilton
wmhilton / index.html
Created Nov 25, 2018
worker-gist (isomorphic-git)
View index.html
<div>
<input id="repository" type="text" style="width: 50em" title="Tip: enter a private repo URL to see the credentialManager plugin prompt for a password.">
<button type="button" onClick="clone()" id="cloneButton">Clone</button>
</div>
<output id="log" style="white-space: pre; font-family: monospace;"></output>
<script src="./proxyReceiver.js"></script>
<script src="./proxySender.js"></script>
<script>
let worker = new Worker("./worker.js")
@wmhilton
wmhilton / AutoHotkey.ahk
Last active Jun 6, 2018
Hotkey to Toggle Screen Resolution
View AutoHotkey.ahk
#b::
Width := QueryScreenWidth()
if (Width = 3840) {
ChangeResolution(1920, 1080)
} else {
ChangeResolution(3840, 2160)
}
QueryScreenWidth()
{
@wmhilton
wmhilton / DatArchive.md
Last active Oct 26, 2017
Musings on BeakerBrowser compatibility
View DatArchive.md

Browser must have a global DatArchive object. https://beakerbrowser.com/docs/apis/dat.html

I think these ones could be supported in a client-side script using BrowserFS

  • new DatArchive(url)
  • DatArchive.create(opts?)
  • DatArchive.fork(url, opts?)
  • DatArchive.selectArchive(opts?)
  • DatArchive.resolveName(url)
  • url