Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave mnmldave

View GitHub Profile
@mnmldave
mnmldave / reverse-nav-menu.php
Created Oct 17, 2011
Reverse wordpress nav menu
View reverse-nav-menu.php
/**
* Enables a 'reverse' option for wp_nav_menu to reverse the order of menu
* items. Usage:
*
* wp_nav_menu(array('reverse' => TRUE, ...));
*/
function my_reverse_nav_menu($menu, $args) {
if (isset($args->reverse) && $args->reverse) {
return array_reverse($menu);
}
@mnmldave
mnmldave / Rakefile
Created Jun 8, 2011
Simple rack PHP server rake task
View Rakefile
#
# Sample rake task for starting a Thin rack server for a PHP application (like
# Wordpress or Drupal or whatever).
#
# Requires php-cgi be available on path (I used homebrew on my mac to install
# php since it doesn't come pre-installed) and gems 'thin', 'rack' and
# 'rack-legacy'.
#
BASE_PATH = File.expand_path(File.dirname(__FILE__))
SRC_PATH = File.join(BASE_PATH, 'src')
@mnmldave
mnmldave / ec2env.sh
Created Jun 25, 2012
EC2 environment switcher script
View ec2env.sh
#!/bin/sh
#
# ec2env.sh
# mnmldave
#
# Switch between EC2_PRIVATE_KEY and EC2_CERT environment variables. Licensed under
# WTFPL v2.0.
#
# Installation (you'll have to open a new terminal after installing):
@mnmldave
mnmldave / gist:2979219
Created Jun 23, 2012
Generate random characters, base64 encoded
View gist:2979219
openssl rand -base64 40
@mnmldave
mnmldave / gist:1463847
Created Dec 12, 2011
Resize browser windows with Selenium WebDriver in Ruby
View gist:1463847
driver = WebDriver.for(:remote, :url => Helper.grid, :desired_capabilities => caps)
width = 1024
height = 768
# Resize window. In Firefox and Chrome, must create a new window to do this.
# http://groups.google.com/group/webdriver/browse_thread/thread/e4e987eeedfdb586
case driver.capabilities[:browser_name]
when 'firefox', 'chrome'
handles = driver.window_handles
View bit155-history.js
// Adds click event handlers to all the pager links within some content element, c.
function prepareContent(c) {
$('ul.pager a', c).each(function(i,e) {
var $e = $(e),
path = $e.attr('href'),
base = Drupal.settings.basePath,
regex = '^' + base.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
if (path && path.match(regex)) {
$e.click(function() {
View index_to_column.rb
#
# Converts a number into a column name like in Excel. For example,
#
# index_to_column(0) = 'A'
# index_to_column(1) = 'B'
# index_to_column(2) = 'C'
# ...
# index_to_column(25) = 'Z'
# index_to_column(26) = 'AA'
# index_to_column(27) = 'AB'
You can’t perform that action at this time.