Skip to content

Instantly share code, notes, and snippets.

View ramsey's full-sized avatar

Ben Ramsey ramsey

View GitHub Profile
@ramsey
ramsey / Dockerfile
Last active December 15, 2015 23:19
benramsey/ramsey-uuid:x86_64-trusty-php-hhvm
FROM hhvm/hhvm:3.11.0
RUN apt-get -y update && apt-get install -y curl git
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
CMD ['bash', '-i']
#!/bin/bash
###
# Shows build-steps used when attempting to build PHP 7 in an
# emulated MIPS chroot jail
#
# To build PHP in a MIPS chroot jail with this script:
#
# mkdir php7-qemu-mips-build && cd php7-qemu-mips-build/
# wget https://gist.githubusercontent.com/ramsey/8ba95a871c75c3aad820/raw/php7-qemu-mips-build.sh
# chmod +x php7-qemu-mips-build.sh
@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 / freenode-channel-setup
Created September 17, 2014 19:22
Base Freenode Channel Setup
Join the channel you want to register. Make sure you're an op (either the first to join, or someone who is an op there sets you to +o).
/join #newchannel
/msg chanserv register #newchannel
/msg chanserv set #newchannel mlock +cnt-s
/msg chanserv set #newchannel guard on
/msg chanserv set #newchannel secure on
/msg chanserv set #newchannel topiclock on
/msg chanserv set #newchannel keeptopic on
/msg chanserv set #newchannel url http://example.org/
@ramsey
ramsey / flip.cpp
Created November 16, 2011 03:08
Converts ASCII files between Unix, MS-DOS/Windows, or Macintosh newline formats
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Tue Jan 20 11:13:16 GMT-0800 1998
// Last Modified: Sun Jan 9 10:34:22 PST 2000 (minor changes)
// Last Modified: Thu Aug 2 13:52:52 PDT 2001 (added stdlib.h for new gcc)
// Last Modified Tue Apr 9 12:24:27 PST 2002 (added Mac options)
// Last Modified Mon Jan 20 21:12:52 PST 2003 (enabled conversion from mac to other)
// Last Modified Wed May 18 14:03:03 PDT 2005 (updated for newer C++ compilers)
// Last Modified Sun Aug 21 21:41:47 PDT 2005 (fixed so running -d twice works)
// Web Address: http://www-ccrma.stanford.edu/~craig/utility/flip/flip.cpp
@ramsey
ramsey / respond-quickly.php
Created August 13, 2015 14:34
Return a response to the client before processing anything
<?php
// Return our response as quickly as possible.
header('Connection: close');
ob_start();
header('HTTP/1.0 204 No Content');
ob_end_flush();
flush();
@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 / 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:

@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