Skip to content

Instantly share code, notes, and snippets.

@hashchange
hashchange / marionette.handlebars.js
Last active August 29, 2015 14:02 — forked from funkjedi/marionette.handlebars.js
Handlebars for Marionette. -- No longer maintained. Instead, please use https://github.com/hashchange/marionette.handlebars
/**
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* This gist is no longer updated. Please use
*
* https://github.com/hashchange/marionette.handlebars
*
* instead.
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@raybellis
raybellis / jquery.classlist.js
Last active December 14, 2015 16:38
A shim for jQuery that uses the native "classList" property of an element for class modifications, if available.
/*global jQuery */
;(function($) {
/*global document */
"use strict";
if (typeof document !== 'undefined' && ('classList' in document.createElement('a'))) {
var $ = jQuery;
@hashchange
hashchange / rounding.js
Created July 26, 2015 19:53
Floating-point versions of Math.round, Math.floor, Math.ceil
/**
* Adjusts a number to a given precision, working around the buggy floating-point math of Javascript. Works for
* round, floor, ceil operations.
*
* Lifted from the Math.round entry of MDN. Minor changes without effect on the algorithm.
*
* @param {string} operation "round", "floor", "ceil"
* @param {number} value
* @param {number} [precision=0] can be negative: round( 104,-1 ) => 100
* @returns {number}
@hashchange
hashchange / scrollTargetPosition.js
Created August 17, 2015 14:16
Returns the scroll target position for scrolling to the top of an element.
/**
* Returns the scroll target position for scrolling to the top of an element.
*
* Pass the result to a scrollTo method:
*
* - $scrollContainer.scrollTop( result ) for instant scrolling
* - $scrollContainer.scrollTo( result ) for animated scrolling with jQuery.scrollable
*
* @param {jQuery} $target the target element
* @param {jQuery} $scrollContainer either $(window), or a scrollable HTML element
@hashchange
hashchange / README.md
Created March 22, 2018 21:42 — forked from barneycarroll/README.md
Lock and unlock a page's scroll position.

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
@mildlygeeky
mildlygeeky / gist:14b814ec8c815a1f5c6f
Last active January 3, 2019 11:43
Dynamic Navigation using native Craft CMS and Twig templates
{# For this, I wanted the nav to show the top-level node and second-level nodes #}
{# when on level 1, and then show the second-level and its children when on #}
{# level 2 or level 3 (so we get good parent, child, and sibling navigation. #}
{# Requires string 'sectionName' to be passed with Structure section name #}
{% if entry.showLeftNavigation %}
<nav class="interior-page__nav">
@khalwat
khalwat / set-project-perms.sh
Last active January 1, 2020 01:10
Properly set permissions for a Craft CMS install, including ensuring that files are all g-x. Set CHOWN_USER, CHOWN_GROUP, and BASE_DIR to whatever is appropriate, add directories that need to be writeable by the web server to DIRS[], then execute: sudo ./set-project-perms.sh PROJECT_NAME
This is now part of craft-scripts:
https://github.com/nystudio107/craft-scripts
@Jakobud
Jakobud / _map-sort.scss
Last active June 20, 2022 14:50
Sort a SASS map
/// map-sort
/// Sort map by keys
/// @param $map - A SASS map
/// @returns A SASS map sorted by keys
/// @requires function list-sort
/// @author Jake Wilson <jake.e.wilson@gmail.com>
@function map-sort($map) {
$keys: list-sort(map-keys($map));
$sortedMap: ();
@each $key in $keys {
@CITguy
CITguy / custom-task.js
Last active January 13, 2023 19:23
Basic pattern for creating a custom Transform stream for use with gulp tasks.
var gulp = require('gulp');
var myTransform = require('./myTransform');
gulp.task('foobar', function (){
return gulp.src("foobar.js")
.pipe(myTransform())
.pipe(gulp.dest('.'));
});
1. Highlight a recommended option,

2. Allow users to switch currency (€/$/£)

3. Allow users to switch pricing monthly/yearly

4. Keep the entire pricing plan area clickable

5. Use slider to calculate how much a user would save

6. Provide free first month for good engagement

7. Prominently highlight testimonials prominently

8. Repeating call to action on top and bottom

9. Sell benefits instead of features

10. Indicate that users can cancel any time