Skip to content

Instantly share code, notes, and snippets.

<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',
@elusiveunit
elusiveunit / sticky-footer.html
Last active December 17, 2015 06:18
Sticky footer with table display
@elusiveunit
elusiveunit / debounce-resize.js
Last active December 17, 2015 09:09
If more debouncing (or throttling) is needed, there is this plugin: https://github.com/cowboy/jquery-throttle-debounce
var resized = null;
$(window).resize(function() {
clearTimeout(resized);
resized = setTimeout(function() {
// Do stuff
}, 250);
});
var tabbableElements = 'a[href], area[href], input:not([disabled]),' +
'select:not([disabled]), textarea:not([disabled]),' +
'button:not([disabled]), iframe, object, embed, *[tabindex],' +
'*[contenteditable]';
var keepFocus = function (context) {
var allTabbableElements = context.querySelectorAll(tabbableElements);
var firstTabbableElement = allTabbableElements[0];
var lastTabbableElement = allTabbableElements[allTabbableElements.length - 1];
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
<?php
/**
* Create an array from a hyphenated, newline separated string.
*
* Converts a string like:
*
* Tacos
* Hamburger
* - With cheese
* -- Cheddar
<?php
/**
* Replace the first occurrence in a string.
*
* @param string $search The value being searched for.
* @param string $replace The replacement value.
* @param string $subject The string being searched.
* @return string
*/
function str_replace_first( $search, $replace, $subject ) {
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
/* some hi-res css */
}
@elusiveunit
elusiveunit / focusable-dropdowns.html
Created November 22, 2013 21:07
As implemented on WebPlatform Docs. Makes use of event capturing through the useCapture parameter for addEventListener, so IE9+ or any modern browser. http://docs.webplatform.org/wiki/Main_Page
<p>Let's have a <a href="#before">link before</a></p>
<div class="dropdown">
<a href="#admin">Admin</a>
<ul>
<li><a href="#admin-one">Pages</a></li>
<li><a href="#admin-two">Posts</a></li>
<li><a href="#admin-three">Users</a></li>
<li><a href="#admin-four">Settings</a></li>
</ul>

Using Console2 as a Git Bash wrapper

On Windows 7. Assumed setup, edit .reg file if needed:

  • Git in C:/Program Files (x86)/Git
  • Console2 in C:/Console2
  • A tab in Console2 called 'Git Bash' (-t flag in the .reg file) with the shell C:\Program Files (x86)\Git\bin\sh.exe --login -i

The .reg file adds an item to open a shell in the current directory, just like 'Git Bash Here' from msysgit. console.xml is the Console2 settings file.