Skip to content

Instantly share code, notes, and snippets.

View whymarrh's full-sized avatar

Whymarrh Whitby whymarrh

View GitHub Profile
@whymarrh
whymarrh / status.bash
Created November 25, 2013 01:28
Display unsigned exit status as signed value.
perl -e 'exit -1'
perl -e "print unpack('c', pack('C', $?)), \$/"
@whymarrh
whymarrh / manifest.json
Last active July 24, 2016 16:44
Minimal 'New Tab' page - a Chrome extension. See adamschwartz/chrome-new-tab.
{
"name": "Minimal New Tab",
"version": "0.0.0",
"manifest_version": 2,
"description": "A minimalist New Tab page.",
"chrome_url_overrides" : {
"newtab": "newtab.html"
}
}
@whymarrh
whymarrh / build.xml
Created November 16, 2013 03:36
Simple Ant build file.
<!--
Directory structure:
.
├── build.xml
├── libs
└── src
   └── foo
   └── bar
@whymarrh
whymarrh / last.bash
Last active December 26, 2015 20:08
Print unique days on which I have used a machine.
#!/usr/bin/env bash
last | grep $(whoami) | tr -s ' ' | cut -d ' ' -f3 -f4 -f5 | uniq
@whymarrh
whymarrh / schema.sqlite3.sql
Last active December 26, 2015 17:29
Schema for ABA Lookup database. See issue #94.
-- PRAGMAs
PRAGMA foreign_keys = ON;
-- User
CREATE TABLE account(
id TEXT PRIMARY KEY,
user_id TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
password_reset_code TEXT NULL,
email TEXT UNIQUE NOT NULL,
@whymarrh
whymarrh / dotcss.js
Last active December 25, 2015 12:59
Custom styles for everyone - $HOME/.css
DOMTokenList.prototype.add.apply(
window.document.documentElement.classList,
window.location.host.substring(0, window.location.host.lastIndexOf('.')).split('.')
);
@whymarrh
whymarrh / test-pa11y.bash
Created August 3, 2013 21:36
Run nature/pa11y against an array of app routes.
#!/usr/bin/env bash
# servers
jeeves="localhost:7211"
alfred="localhost:7212"
abyss="/dev/null"
cd "public"
php -S "$jeeves" &> "$abyss" &
@whymarrh
whymarrh / BaseTestCase.php
Last active February 8, 2018 17:58
Assert HTML validity with PHPUnit.
<?php
use PHPUnit_Framework_Exception;
use PHPUnit_Framework_TestCase;
use SimpleXMLElement;
class BaseTestCase extends PHPUnit_Framework_TestCase
{
/**
* Show as much error information as possible
@whymarrh
whymarrh / inline.php
Last active December 16, 2015 23:49
In-lines CSS, JavaScript, and images.
#!/usr/bin/env php
<?php
define(SUCCESS, 0);
define(ERROR, 1);
if (count($argv) != 2) {
printf("usage: %s <filename>\n", basename($argv[0]));
exit(ERROR);
}
@whymarrh
whymarrh / tends.c
Created March 16, 2013 22:59
A cool "tends to" operator in C (not actually).
#include <stdio.h>
#define as while
// as seen on Stack Overflow
// http://stackoverflow.com/q/1642028
int main(int argc, char **argv) {
int x = 42;
as (x --> 0) {