Skip to content

Instantly share code, notes, and snippets.

View danott's full-sized avatar
📈
Chart with upward trend

Dan Ott danott

📈
Chart with upward trend
View GitHub Profile
@danott
danott / custom_query.php
Created April 7, 2011 19:09
Wordpress custom query for getting information outside of The Loop
<?
// This is a sub query for pulling data from outside of the loop..
// However, we need to preserve the original $wp_query if this is inside an existing loop.
// If this is the last query, then you can ditch it.
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('your-custom-query');
@danott
danott / texture.css
Created April 7, 2011 19:45
A repeating pattern with no additional download.
/* Made using Patternify: http://bit.ly/ffY9p6 */
body {
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAZ0lEQVQYGXWPAQ7AIAgD3X7hi/wyvMhnuNXkTDUbiRYopVrGGOU8EVHpkd/ljcysQqK11skXovhDbRa32TKMLUPCS5es3c6fsvqo2XYi/PSHpOkIN99I4aicWsLtM2o46fnnRrdG/ABLSeu1eLIkcAAAAABJRU5ErkJggg==);
}
@danott
danott / current_category_id.php
Created April 8, 2011 15:33
WordPress function to accurately retrieve the current category ID outside the loop.
<?php
/* current_category_ID()
*
* Get the currently-being-viewed category's ID.
*
* THE PROBLEM:
* WordPress offers no easy way to get the id of the category that is currently
* being viewd in an index.php. It offers nice conventions to get the title and
* description (within the loop), but I needed this information outside the loop.
@danott
danott / responsive_design_js.css
Created April 11, 2011 18:31
Less Framework/Responsive-design-in-general JavaScript Support Idea
/* Less Framework/Responsive-design-in-general JavaScript Support Idea
*
* THE PROBLEM:
* Ideally, all responsive design would be handled by CSS. In reality, not
* everythingthat we need to do in the implementation of responsive design can
* be handled by CSS.
*
* THE (CURRENTLY BEING INVESTIGATED) SOLUTION:
* Provide an unseen element that contains arbitrary data that aides us in
* determining what to do when the window changes window resizes or
@danott
danott / json_storage.js
Created April 26, 2011 15:51
Override localStorage and sessionStorage's getter and setter function to allow for objects/arrays to be stored as well.
/* json_storage.js
* @danott
* 26 APR 2011
*
* Building on a thread from Stack Overflow, override localStorage and sessionStorage's
* getter and setter functions to allow for storing objects and arrays.
*
* Original thread:
* http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
*/
@danott
danott / install_pow_with_apache_proxy.sh
Created May 31, 2011 20:48 — forked from jwilger/install_pow_with_apache_proxy.sh
Run this file to instal 37signals' Pow but use an Apache proxy instead of the firewall rule.
curl get.pow.cx/install.sh | sh
# We don't actually want the firewall rule that pow installs
echo "Get rid of those silly firewall rules for port 80."
ports=($(ruby -e'puts $<.read.scan(/fwd .*?,([\d]+).*?dst-port ([\d]+)/)' "/Library/LaunchDaemons/cx.pow.firewall.plist"))
HTTP_PORT=${ports[0]}
DST_PORT=${ports[1]}
RULE=$(sudo ipfw show | (grep ",$HTTP_PORT .* dst-port $DST_PORT in" || true) | cut -f 1 -d " ")
[[ -n "$RULE" ]] && sudo ipfw del "$RULE"
# Unload the firewall plist and remove it.
@danott
danott / pow_port.rb
Created May 31, 2011 20:48 — forked from dhrrgn/pow_port.rb
Quickly and easily change the port that Pow is running on. This allows you too run Apache and Pow side-by-side (on different ports of course).
#!/usr/bin/env ruby
# Pow Port
#
# Quickly and easily change the port that Pow is running on. This allows
# you too run Apache and Pow side-by-side (on different ports of course).
#
# WARNING: This will OVERWRITE your ~/.powconfig file. If you have custom
# configurations in there, please back it up first.
#
@danott
danott / relative_time.php
Created June 14, 2011 15:56
Twitter style relative time.
<?php
/*
Origin: http://snipplr.com/view/4912/relative-time/
Copied here for my reference
*/
function plural($num) {
if ($num != 1)
return "s";
alert('hello');
@danott
danott / social.js
Created November 28, 2011 22:04
Replace Twitter/Facebook/G+ scripts with one Modernizr.load call.
Modernizr.load(
[ '//platform.twitter.com/widgets.js'
, '//apis.google.com/js/plusone.js'
, { test: document.getElementById('facebook-jssdk')
, nope: '//connect.facebook.net/en_US/all.js#xfbml=1'
}
]);
/* When Using Modernizr, the above replaces all the social includes below