Skip to content

Instantly share code, notes, and snippets.

View ramsey's full-sized avatar

Ben Ramsey ramsey

View GitHub Profile
@ramsey
ramsey / signature.html
Created January 26, 2016 18:21
Signature box capturing signature as SVG paths
<!DOCTYPE html>
<!-- saved from url=(0036)http://mcc.id.au/2010/signature.html -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Signature capture</title>
<style>
body { font-family: Helvetica, sans-serif }
@ramsey
ramsey / refresh_bot.sh
Created June 3, 2016 13:01
Wldgrlc Twitter Bot
#!/bin/bash
ebooks archive ramsey corpus/ramsey.json
ebooks consume corpus/ramsey.json
git add model/ramsey.model
git commit -m "Updating model"
git push origin master
echo "Great! Now run 'ebooks start'."
@ramsey
ramsey / BarTrait.php
Last active September 8, 2016 22:16
Trait method collisions
<?php
namespace MyTraits;
trait BarTrait
{
use BazTrait;
public function bar()
{
return $this->baz() . ' : bar';
@ramsey
ramsey / google-font-download-woff2.php
Created September 13, 2016 17:08
Downloads the .woff2 formats of the specified Google Font for the specified language types. This also creates the appropriate CSS for the downloaded font files
<?php
/**
* Downloads the .woff2 formats of the specified Google Font for the specified
* language types. This also creates the appropriate CSS for the downloaded
* font files
*
* Usage:
* php google-font-download.php 'Open Sans' ['latin-ext,latin' [/path/to/write/to]]
*/
@ramsey
ramsey / variadic-generics.php
Created October 13, 2016 17:38
You may type-hint on variadic functions in PHP to enforce type on elements in the array
<?php
class Foo {}
$f1 = new Foo();
$f2 = new Foo();
$bar = function (Foo ...$foo) {
foreach ($foo as $f) {
echo get_class($f) . "\n";
}
@ramsey
ramsey / uuid.php
Created October 26, 2016 23:37
Creating an ordered time UUID alongside a timestamp-first COMB UUID.
<?php
// composer require ramsey/uuid moontoast/math
require_once 'vendor/autoload.php';
use Ramsey\Uuid\Codec\OrderedTimeCodec;
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
use Ramsey\Uuid\Generator\CombGenerator;
use Ramsey\Uuid\UuidFactory;
@ramsey
ramsey / pip-cache-notes.md
Last active April 4, 2017 20:30
pip cache issue

Thinking this to be a powerline issue related to powerline/powerline#1494, I originally posted the following at powerline/powerline#1494 (comment)

Thanks so much to Trent Harvey and @ZyX-I for their help working through this. (Twitter thread.)


I just encountered this problem. I'm not sure what causes it, since I've been using my terminal configuration for years without this issue. I did not install or upgrade any software today. Rebooting my machine did not fix it.

I'm running:

Running Xhgui With Tideways Through a Docker Container

Run Xhgui Docker Container

cd ~
git clone https://github.com/perftools/xhgui.git
docker run --name xhgui -d -p 8880:80 -P -v "$HOME/xhgui":/var/www/xhgui clarencep/xhgui
docker exec xhgui bash -c 'cd /var/www/xhgui && \
    curl --silent https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer | php -- --quiet && \
@ramsey
ramsey / cycle-list.php
Created September 1, 2017 13:31 — forked from chartjes/cycle-list.php
My PHP script for creating a Twitter list where people cycle on and off it based on 30 days of interaction
<?php
require "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
// You can get all these via https://dev.twitter.com/
$consumer_key = "";
$consumer_secret = "";
$access_token = "";
$access_token_secret = "";
$user_id = 0; // Twitter user ID
@ramsey
ramsey / authenticate.php
Last active September 28, 2017 06:14
Demonstrate that Apache converts any response containing WWW-Authenticate to 401
<?php
header('HTTP/1.1 403 Forbidden');
if (isset($_GET['authHeader']) && $_GET['authHeader'] == 1) {
header('WWW-Authenticate: Bearer realm="Foo"');
}
echo "Hi!";