Skip to content

Instantly share code, notes, and snippets.

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

Matt Farina mattfarina

┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
View GitHub Profile
<?php
use OpenStack/OpenStack;
$options = array(
'endpoint' => 'https://example.identity.com/v2.0/',
'username' => 'awesomesauce',
'password' => 'cakeplease',
);

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:

// Provide credentials
$settings = array(
'username' => USERNAME,
'password' => PASSWORD,
'tenantid' => YOUR_TENANT_ID,
'endpoint' => IDENTITY_SERVICES_URL,
'transport' => '\HPCloud\Transport\PHPStreamTransport',
);
Bootstrap::setConfiguration($settings);

Projects not source controlled on Github

This is a short list (not difinitive) just to be used as an example set.

  • OpenStack
  • Linux kernel
  • Drupal (including thousands of contributed modules)
  • Wordpress
  • Ubuntu
  • PHP
  • Python
(function($) {
//
// Automatically calls all functions in APP.init
//
jQuery(document).ready(function() {
APP.go();
});
//
// Module pattern:
/**
* Helper function; removes all required element flags on a section of a form.
*
* @param array $element
* A form or section of a form.
*
* @return array
* A section of a form tree with #required = 0 everyehere.
*/
function example_remove_required($element) {
function checkPlain(str) {
var length,
r = new RegExp('(&)|(\")|(<)|(>)|([^&\"<>]*)', 'g')
replacements = ["&amp;", "&quot;", "&lt;", "&gt;"],
retval = '',
match = r.exec(str);
while (match[0] != "") {
length = match.length;
for (var i = 1; i < length; ++i) {
if (match[i] != undefined) {
@mattfarina
mattfarina / gist:756870
Created December 28, 2010 03:28
Drupal / jQuery html5 placeholder support for browsers without native support
// Here we use a similar set of variables passed in as jQuery. The lone difference is
// the inclusion of the Drupal variable. We pass in the global variables we use which
// provides proper dependency injection and for compressors to have names that can be
// more easily shrunk.
(function($, Drupal, window, document, undefined) {
Drupal.sitetheme = Drupal.sitetheme || {};
/*
* Initialize placeholder functionality on a text based input element.
$.support.positionFixed = (function () {
var el, support,
body = document.body || document.getElementsByTagName("body")[0] || document.documentElement;
// Boolean indicating whether or not "position: fixed" is supported.
// Using the DOM to create an element is much faster than using jQuery.
el = document.createElement("div");
el.style.position = "fixed";
el.style.top = "10px";
el.style.visibility = "hidden";
@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;