Skip to content

Instantly share code, notes, and snippets.

View allanwhite's full-sized avatar

Allan White allanwhite

View GitHub Profile
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
@jackmcdade
jackmcdade / twitter-bootstrap2-with-structure.js
Created March 19, 2012 21:50
Twitter Bootstrap2 with Structure
{exp:structure:nav max_depth="2" show_depth="2" current_class="active" css_class="nav" has_children_class="dropdown"}
<script>
$(function() {
$('ul li.dropdown').each(function() {
$(this).children('ul').addClass("dropdown-menu"); // add children dropdown menu class
$(this).children('a').append('<b class="caret"></b>') // add caret icon
$(this).clone().prependTo($(this).find('ul')).removeClass('dropdown active').children('ul').remove(); // clone parent link into child menu
$(this).children('a').attr('data-toggle', 'dropdown').attr('href', '#').addClass("dropdown-toggle"); // add data attributes to hook up Bootstrap
});
@d6y
d6y / process.sh
Created July 11, 2012 17:58
Batch convert HTML to Markdown
#!/bin/bash
# Converts HTML from https://exportmyposts.jazzychad.net/ exports to Markdown
POSTS_DIR=/Users/richard/Desktop/d6y/posts
for file in $POSTS_DIR/*.html
do
echo $file
@ls-lukebowerman
ls-lukebowerman / gist:3677503
Created September 8, 2012 17:24
IndexTank/JSON Sitemap Generator for Middleman
<%
entries = []
pages = sitemap.resources
pages = pages.find_all{|p| p.source_file.match(/\.html/) && !p.directory_index? && p.data.hide_listing != true }
pages.each do |article|
file = File.open(article.source_file,'r')
file_contents = file.read.split('---').last.gsub(/\t|\n/,' ')
content = Nokogiri::HTML(file_contents).xpath("//text()").to_s
@atenni
atenni / README.md
Last active April 24, 2024 01:36
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@jshawl
jshawl / Gruntfile.js
Last active January 18, 2023 13:52
Grunt + Sass + Autoprefixer
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options:{
style:'compressed'
},
files: {
'css/style.css' : 'scss/style.scss'
@brock
brock / nodereinstall.sh
Last active June 2, 2024 16:15
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"
@grncdr
grncdr / data.csv
Created June 17, 2015 22:29
Demo of importing a CSV file into a Contentful space
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
@raybrownco
raybrownco / image_helpers.rb
Last active July 10, 2021 13:37
Inline SVG in Middleman
# Middleman - Inline SVG Helper
# ------------------------------------------------------------------------------
#
# Installation
# ------------
# 1. Save this file at `[project_root]/helpers/image_helpers.rb`
# 2. Open the project's Gemfile and add this line: `gem "oga"`
# 3. Run `bundle install` from the command line
#
# Note: Restart your local Middleman server (if it's running) before continuing
@javierarques
javierarques / config.rb
Created August 22, 2017 08:00
Middleman 4 and Webpack 3 integration. Use Middleman with External Pipeline.
# ...
activate :external_pipeline,
name: :webpack,
command: build? ? "npm run build:assets" : "npm run start:assets",
source: ".tmp/webpack_output",
latency: 1
# ...