Skip to content

Instantly share code, notes, and snippets.

View ramsey's full-sized avatar

Ben Ramsey ramsey

View GitHub Profile
@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 / bootstrap-fileinput.js
Created October 3, 2014 16:31
Nicer looking file inputs for Bootstrap 3
/**
* Nicer looking file inputs for bootstrap 3
* By Jeff Dairiki <dairiki@dairiki.org> based on ideas from
* http://www.abeautifulsite.net/blog/2013/08/whipping-file-inputs-into-shape-with-bootstrap-3/
*
* Found here: http://jsbin.com/OxOQoDa/8
*/
(function ($) {
var Upload = function (element, options) {
@ramsey
ramsey / test_rollback_proc.sql
Created October 28, 2014 20:43
Example of declaring a continue handler in MySQL and rolling back or committing, based on status of _rollback
DROP PROCEDURE IF EXISTS test_rollback_proc;
DELIMITER //
CREATE PROCEDURE test_rollback_proc()
BEGIN
DECLARE `_rollback` BOOL DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `_rollback` = 1;
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@ramsey
ramsey / README.md
Last active August 29, 2015 14:18 — forked from vanto/README.md

OEmbed Liquid Tag for Jekyll

This is a simple liquid tag that helps to easily embed images, videos or slides from OEmbed enabled providers. It uses Magnus Holm's great oembed gem which connects to the OEmbed endpoint of the link's provider and retrieves the HTML code to embed the content properly (i.e. an in-place YouTube player, Image tag for Flickr, in-place slideshare viewer etc.). By default it supports the following OEmbed providers (but can fallback to Embed.ly or OoEmbed for other providers):

  • Youtube
  • Flickr
  • Viddler
  • Qik
  • Revision3
  • Hulu
  • Vimeo
@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 / 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']
@ramsey
ramsey / gist:672168e6fcf3120dbfc5
Created January 12, 2016 16:53 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@ramsey
ramsey / Bar.php
Last active October 3, 2018 20:24
Mocking fluent interfaces with Mockery, and vary return values based on input to methods in the middle of the chain
<?php
namespace Ramsey\Talks;
class Bar
{
public function getSomething(Foo $foo, $arg1, $arg2)
{
$result = $foo->bar()->baz($arg1)->qux()->quux($arg2);
return "Now, we're {$result}";
#!/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