Skip to content

Instantly share code, notes, and snippets.

@dubbs
dubbs / gist:4719202
Last active December 12, 2015 05:08
gem install zurb-foundation
compass install foundation --force
compass watch
import re
def in_active_path(nav_slug, page_slug):
return re.match(nav_slug, page_slug)
@dubbs
dubbs / html.snippets
Created January 24, 2013 03:37 — forked from smt/html.snippets
# Some useful Unicode entities
# Non-Breaking Space
snippet nbs
 
# ←
snippet left
←
# →
snippet right
→
@dubbs
dubbs / gist:4611547
Created January 23, 2013 18:53
Rendering navigation, the easy way
<ul>
{%- for slug, title, children in NAVIGATION recursive %}
<li><a href="{{SITEURL}}/{{slug}}/">{{ title }}</a>
{%- if children -%}
<ul>{{ loop(children) }}</ul>
{%- endif %}</li>
{%- endfor %}
</ul>
@dubbs
dubbs / vim.md
Last active May 17, 2024 04:29
Useful Vim Commands

Execute the macro stored in register a on lines 5 through 10.

:5,10norm! @a

Execute the macro stored in register a on all lines.

:%norm! @a

Jumping

@dubbs
dubbs / gist:4477834
Created January 7, 2013 19:53
Cross browser print request detection
(function() {
var beforePrint = function() {
console.log('before');
};
var afterPrint = function() {
console.log('after');
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
@dubbs
dubbs / .htaccess
Last active December 10, 2015 16:18
RewriteRule ^(js|css|img)/(.+)\.(.+)\.(js|css|jpg|gif|png)$ $1/$2.$4 [L]
<link rel="stylesheet" href="<?php autoVer('/css/main.css'); ?>" type="text/css" />
<script type="text/javascript" src="<?php autoVer('/scripts/main.js'); ?>"></script>
@dubbs
dubbs / app.php
Last active May 17, 2024 04:29
versioning filenames with last modified time - PHP
<?php
function autoVer($url) {
$path = pathinfo($url);
$ver = '.' . filemtime($_SERVER['DOCUMENT_ROOT'] . $url) . '.';
echo $path['dirname'] . '/' . str_replace('.', $ver, $path['basename']);
}
@dubbs
dubbs / .htaccess
Last active May 17, 2024 04:29
far future Expires header
<FilesMatch "\.(gif|png|jpg|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 10 years"
</FilesMatch>