Skip to content

Instantly share code, notes, and snippets.

Ben Ramsey ramsey

Block or report user

Report or block ramsey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ramsey
ramsey / openapi.yaml
Last active Sep 26, 2019
OpenDISCO OpenAPI Document WIP
View openapi.yaml
openapi: 3.0.2
info:
title: DISCO Server
contact:
url: http://www.open-disco.org
version: 'v1.0.0'
servers:
- url: http://rwmbook-registry.herokuapp.com
@ramsey
ramsey / r53export.sh
Last active Dec 11, 2018
Queries AWS Route53 for a zone name and outputs a zone file of its records
View r53export.sh
#!/bin/bash
#
# Queries AWS Route53 for a zone name and outputs a zone file of its records
#
# Usage:
#
# r53export example.com[ profile]
#
# By default, uses $AWS_PROFILE environment variable, if set.
#
@ramsey
ramsey / foo.php
Created Oct 16, 2017
Segfault when running built-in PHP web server
View foo.php
<?php
class Foo
{
public function execute($log)
{
file_put_contents($log, "this is a log\n", FILE_APPEND);
}
}
(new Foo())->execute('./mylog.txt');
@ramsey
ramsey / authenticate.php
Last active Sep 28, 2017
Demonstrate that Apache converts any response containing WWW-Authenticate to 401
View authenticate.php
<?php
header('HTTP/1.1 403 Forbidden');
if (isset($_GET['authHeader']) && $_GET['authHeader'] == 1) {
header('WWW-Authenticate: Bearer realm="Foo"');
}
echo "Hi!";
@ramsey
ramsey / cycle-list.php
Created Sep 1, 2017 — 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
View cycle-list.php
<?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
View xhgui-tideways-docker.md

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 && \
View run_bm.php
#!/usr/local/bin/php
<?php
shell_exec('ssh debian sudo service hhvm stop');
function parse_siege($data) {
preg_match("#(\d+\.\d+) trans/sec#",$data,$m);
$rps = $m[1];
preg_match("#Response time:\s*(\d+\.\d+) secs#",$data,$m);
$lat = $m[1];
View pip-cache-notes.md

Thinking this to be a powerline issue related to https://github.com/powerline/powerline/issues/1494, I originally posted the following at https://github.com/powerline/powerline/issues/1494#issuecomment-291605075

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:

@ramsey
ramsey / uuid.php
Created Oct 26, 2016
Creating an ordered time UUID alongside a timestamp-first COMB UUID.
View uuid.php
<?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 / variadic-generics.php
Created Oct 13, 2016
You may type-hint on variadic functions in PHP to enforce type on elements in the array
View variadic-generics.php
<?php
class Foo {}
$f1 = new Foo();
$f2 = new Foo();
$bar = function (Foo ...$foo) {
foreach ($foo as $f) {
echo get_class($f) . "\n";
}
You can’t perform that action at this time.