Skip to content

Instantly share code, notes, and snippets.

View jonschlinkert's full-sized avatar
🤔
Trying to stay in the right branch of the wave function.

Jon Schlinkert jonschlinkert

🤔
Trying to stay in the right branch of the wave function.
View GitHub Profile
@jonschlinkert
jonschlinkert / assemblefile.js
Last active August 29, 2015 13:57
Everything you need to build a complete project with Assemble v0.6.0
var assemble = require('assemble');
assemble.partials('templates/partials/*.hbs');
assemble.layouts('templates/layouts/*.hbs');
assemble.task('default', function() {
assemble.src('templates/*.hbs')
.pipe(assemble.dest('_gh_pages'))
});
@jonschlinkert
jonschlinkert / verbfile-with-logging.js
Last active August 29, 2015 13:57
This verbfile adds some basic logging and changes the dest directory to `book/`. (if you don't use a verbfile, verb-cli will just process templates in the `docs` directory by default.)
var file = require('fs-utils');
module.exports = function(verb) {
verb.log.subhead('building', 'My Book');
// Process templates
file.writeFileSync('book/', verb.read('src/*.tmpl.md', {
data: 'chapters/*.json' // custom metadata for templates
}));
@jonathan-beebe
jonathan-beebe / assemble-io-looping.html
Last active August 29, 2015 13:57
Looping through data using Assemble.io + Handlebars
---
headings: [1, 2, 3, 4, 5, 6]
---
<div data-section="headings">
{{#each headings}}
{{#withHash num=this text="Heading"}}
<h{{num}}>{{text}} {{num}}</h{{num}}>
{{/withHash}}
{{/each}}
@jonschlinkert
jonschlinkert / .assemblerc.yml
Last active August 29, 2015 14:01
Create a theme with Assemble
# I'm only using a few fields here to demonstrate how this works
# Site theme
theme: slides
# Assets
# The assets path is based on the theme,
# the other paths can build on the assets path
assets: assets/<%= site.theme %>
images: <%= site.assets %>/images
@jonschlinkert
jonschlinkert / tutorial-create-permalinks-using-stringsjs.md
Last active August 29, 2015 14:01
Creating permalinks with Strings.js
############################################################################################################
### % [ title ] ( src ) ###
video_matcher = /^%\[([^\]]*)\]\s*\(([^)]+)\)/
#-----------------------------------------------------------------------------------------------------------
parse_video = ( state, silent ) ->
return false if state.src[ state.pos ] isnt '%'
match = video_matcher.exec state.src[ state[ 'pos' ] .. ]
return false unless match?
unless silent
@ucnv
ucnv / README.md
Created May 3, 2009 09:01
Diff for gist.github
@satyr
satyr / gist_diff.user.js
Created May 5, 2009 22:40 — forked from ucnv/README.md
Diffs on Gist with google-diff-match-patch
// ==UserScript==
// @name gist diff
// @namespace http://github.com/satyr
// @description Shows diffs on Gist with google-diff-match-patch.
// @include https://gist.github.com/*
// @require https://raw.github.com/gist/105908
// @require https://google-diff-match-patch.googlecode.com/svn/trunk/javascript/diff_match_patch.js
// @fork_of http://gist.github.com/105913
// @check_also http://gist.github.com/107780
// ==/UserScript==
@sms420
sms420 / gist:119108
Created May 28, 2009 05:18
toggle_ME.js
//toggle_ME.js
jQuery(document).ready(function() {
jQuery(".menu_item img").hide();
jQuery(".menu_item a").click(function () {
jQuery(this).siblings('img:visible').hide('normal');
jQuery(this).siblings('img:hidden').show('normal');
@akai
akai / script.md
Last active September 26, 2015 19:37
JavaScript Snippets

Load newest JQuery 1.x library from Google's CDN

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

The Window Scroll Event

  • It's a very, very, bad idea to attach handlers to the window scroll event.
  • Always cache the selector queries that you're re-using.