Skip to content

Instantly share code, notes, and snippets.

View mattfarina's full-sized avatar
┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻

Matt Farina mattfarina

┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
View GitHub Profile
// Provide credentials
$settings = array(
'username' => USERNAME,
'password' => PASSWORD,
'tenantid' => YOUR_TENANT_ID,
'endpoint' => IDENTITY_SERVICES_URL,
'transport' => '\HPCloud\Transport\PHPStreamTransport',
);
Bootstrap::setConfiguration($settings);

Keybase proof

I hereby claim:

  • I am mattfarina on github.
  • I am mattfarina (https://keybase.io/mattfarina) on keybase.
  • I have a public key whose fingerprint is D65A 0E4F 7836 7744 2D69 3D55 DC66 5B26 7D74 FD99

To claim this, I am signing this object:

<?php
use OpenStack/OpenStack;
$options = array(
'endpoint' => 'https://example.identity.com/v2.0/',
'username' => 'awesomesauce',
'password' => 'cakeplease',
);
@mattfarina
mattfarina / gist:6933353
Last active December 25, 2015 06:39
Looking at Composer for ideas in Go package management.

Summary: This document looks at composer from PHP for ideas around Go package management.

Composer is a command line tool for PHP to manage dependent packages. It can manage packages from a central registry, other registries, or from a list of projects themselves. Packages and versions are described in a composer.json file at the root of a project. For example:

{
  "name": "namespace/name",
  "description": "foo bar baz",
  "require": {
    "foo/bar": "1.*",

"bar/qux": "dev-master"

server:
@@jekyll --server
render:
@@echo "Building the site..."
@@jekyll --no-future
minify:
@@echo "Minifying the CSS..."
@@java -jar _build/yuicompressor.jar --verbose --type css -o _site/path/to/style.css _site/path/to/style.css
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'YOUR CODE HERE';
var disqus_url = 'http://example.com/{{ page.url }}';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
@mattfarina
mattfarina / custom.module
Created December 27, 2011 16:05
Protocol Relative URLs in Drupal 7
<?php
/**
* Implements hook_file_url_alter().
*
* Make all URLs be protocol relative.
* Note: protocol relatice URLs will cause IE7/8 to download stylesheets twice.
* @see http://www.stevesouders.com/blog/2010/02/10/5a-missing-schema-double-download/
*/
function custom_file_url_alter(&$url) {
@mattfarina
mattfarina / custom.module
Created December 27, 2011 14:00
Protocol relative image paths in Drupal 7
<?php
/**
* Implementation of hook_preprocess_image().
*
* Make images that use a full url be protocol relative.
*/
function custom_preprocess_image(&$variables) {
// If the image URL starts with a protocol remove it and use a
@mattfarina
mattfarina / gist:974898
Created May 16, 2011 17:20
Strip tags from pathauto node title
function custom_tokens_alter(array &$replacements, array $context) {
$options = $context['options'];
$sanitize = !empty($options['sanitize']);
if ($context['type'] == 'node' && !empty($context['data']['node'])) {
$node = $context['data']['node'];
foreach ($context['tokens'] as $name => $original) {
switch ($name) {
case 'title':
$title = !empty($options['pathauto']) ? strip_tags($node->title) : $node->title;