Skip to content

Instantly share code, notes, and snippets.

@mjangda
mjangda / save-post-meta-helper.php
Created April 13, 2011 03:55
Helper function to save post meta in custom metaboxes
<?php
/**
* Saves post meta value
*
* @param int ID of the post
* @param string Name of the post_meta key (same as the $_POST key and nonce name)
* @param string Name of the nonce key
* @param mixed The default value to be assigned if not set
*
* @return string Value that was saved
@cballou
cballou / wordpress-multi-env-configphp-setup.php
Created August 15, 2011 13:54
Wordpress Multi-Environment wp-config.php Setup
<?php
/**
* This code is intended to be added to your wp-config.php file just below the top comment block.
* It should replace the existing define('DB_*') statements. You can add or remove sections
* depending on the number of environments you intend to setup. You should change all values of
* DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST for each environment, making them all distinct
* for security purposes.
*/
// determine the current environment
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@christophercochran
christophercochran / Add WordPress Menu Item Description
Created May 31, 2012 16:20
Adds Menu Description to Wordpress Menu with the walker_nav_menu_start_el filter.
add_filter( 'walker_nav_menu_start_el', 'gt_add_menu_item_description', 10, 4);
function gt_add_menu_item_description( $item_output, $item, $depth, $args ) {
$desc = __( $item->post_content );
return preg_replace('/(<a.*?>[^<]*?)</', '$1' . "<small class=\"nav-desc\">{$desc}</small><", $item_output);
}
@rachelbaker
rachelbaker / matchMedia.js
Created August 24, 2012 17:38
jQuery matchMedia event handler for mobile
jQuery(document).ready(function($) {
// load touchdown resposnive nav
$('#site-navigation .menu').Touchdown();
// check window size
if (matchMedia) {
var mq = window.matchMedia("(min-width: 769px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
@wenjul
wenjul / index.html
Created November 22, 2012 15:22 — forked from anonymous/index.html
Advanced Checkbox Hack - This works for both iOS and Android! You can use almost the default checkbox-hack syntax and just need to add two things:## 1. Android smaller than / equal 4.1.2pseudo-class + general/adjacent siblin
<h1>Advanced Checkbox Hack</h1>
<input type="checkbox" id="button" />
<label for="button" onclick>click / touch</label>
<div>
Change my color!
<br>
<span>even mine :D</span>
</div>
@electricg
electricg / mouse.js
Last active April 27, 2021 16:32
Mouse position relative to document and element
// Which HTML element is the target of the event
function mouseTarget(e) {
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
}
@ryanjduffy
ryanjduffy / inherited.sublime-snippet
Created January 19, 2013 20:38
If you're using Sublime Text 2 for EnyoJS, you need this snippet!
<snippet>
<content><![CDATA[
this.inherited(arguments);
]]></content>
<tabTrigger>inh</tabTrigger>
<scope>source.js</scope>
<description>this.inherited(arguments);</description>
</snippet>
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jareware
jareware / SCSS.md
Last active May 19, 2024 14:03
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso