Skip to content

Instantly share code, notes, and snippets.

View keeganstreet's full-sized avatar

Keegan Street keeganstreet

View GitHub Profile
@keeganstreet
keeganstreet / drupalsouth.theme
Created November 11, 2017 02:07
Drupal theme hooks to add a template suggestion for labels based on the associated input type
<?php
/**
* Implements hook_preprocess_HOOK().
*/
function drupalsouth_preprocess_form_element(array &$variables) {
$variables['label']['#attributes']['data-element-type'] = $variables['element']['#type'];
}
/**
@keeganstreet
keeganstreet / script.js
Created August 10, 2016 10:24
Show all global variables, excluding native browser ones
(function() {
var windowKeys = Object.keys(window),
iframe = document.createElement('iframe'),
cleanWindowKeys,
customVars;
document.body.appendChild(iframe);
cleanWindowKeys = Object.keys(iframe.contentWindow);
customVars = windowKeys.filter(function(key) {
return (cleanWindowKeys.indexOf(key) === -1);
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@keeganstreet
keeganstreet / README.md
Created June 9, 2011 08:33
Vim command for converting multiline HTML into concatenated strings

For converting this:

<ul>
	<li><a href="#" id="btnLogin">Login with Facebook</a></li>
	<li><a href="#" id="btnLogout">Log out</a></li>
	<li><a href="#" id="btnSelect1">Select friends</a></li>
	<li><a href="#" id="btnSelect2">Select friends in a seperate instance with different options</a></li>
</ul>

Into this:

@keeganstreet
keeganstreet / README.md
Created May 12, 2011 12:43
Facebook share links

You can create feed dialogues on Facebook simply by navigating to a URL. You don't need to include the hefty Facebook JavaScript SDK (unless you need post published callbacks).

Here's a demo with some JavaScript that will open the dialogue as a popup window at the correct size. If the popup is blocked, it will fall back to a target="_blank".

The feed properties are documented here: http://developers.facebook.com/docs/reference/dialogs/feed/

@keeganstreet
keeganstreet / README.md
Created May 12, 2011 09:20
Twitter share links

Make your Twitter share links open as a small popup window so the user can still see your page in the background.

This jQuery snippet will open your Twitter link in a window the perfect size for the Twitter sharer. It will focus the popup so it comes to the front. If the popup was blocked by a popup blocker it will allow the default event behaviour to run so the window opens as a _blank.

For more options with Twitter sharing go to: http://dev.twitter.com/pages/tweet_button

@keeganstreet
keeganstreet / JavaScript hook.js
Created April 19, 2011 14:08
Inspired by Modernizr
// Add a "no-js" class to the html element.
// Include this code in the head of the doc. Must be in the head.
document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/,'') + ' js';
@keeganstreet
keeganstreet / Vim plugins
Created April 17, 2011 09:52
Adding a Vim plugin as a git submodule
# From http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/
# Add a Vim plugin as a git submodule
git submodule add http://github.com/tpope/vim-fugitive.git bundle/fugitive
git add .
git commit -m "Install Fugitive.vim bundle as a submodule."
# Update all submodules
git submodule foreach git pull origin master