Skip to content

Instantly share code, notes, and snippets.

@raybellis
raybellis / jquery.classlist.js
Last active Dec 14, 2015
A shim for jQuery that uses the native "classList" property of an element for class modifications, if available.
View jquery.classlist.js
/*global jQuery */
;(function($) {
/*global document */
"use strict";
if (typeof document !== 'undefined' && ('classList' in document.createElement('a'))) {
var $ = jQuery;
@kevingessner
kevingessner / parent.htm
Created May 17, 2013
Detect browser zoom in javascript 'zoom' event is triggered on window on every browser zoom change. No polling!
View parent.htm
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<iframe id="frame" style="width: 250px; border: solid 1px red;" ></iframe>
<script type="text/javascript">
var elFrame = $('#frame')[0];
$(elFrame.contentWindow).resize(function() {
$(window).trigger('zoom');
@guenthertheilen
guenthertheilen / gist:8401080
Created Jan 13, 2014
Install Composer on Managed Hosting at Domainfactory
View gist:8401080

Install Composer on Managed Hosting at Domainfactory

Step 1:

Log in to your Managed Hosting Server via SSH

Step 2:

Add these two lines to .bashrc:

@mildlygeeky
mildlygeeky / gist:14b814ec8c815a1f5c6f
Last active Jan 3, 2019
Dynamic Navigation using native Craft CMS and Twig templates
View gist:14b814ec8c815a1f5c6f
{# 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">
@hashchange
hashchange / marionette.handlebars.js
Last active Aug 29, 2015 — forked from funkjedi/marionette.handlebars.js
Handlebars for Marionette. -- No longer maintained. Instead, please use https://github.com/hashchange/marionette.handlebars
View marionette.handlebars.js
/**
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* This gist is no longer updated. Please use
*
* https://github.com/hashchange/marionette.handlebars
*
* instead.
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@CITguy
CITguy / custom-task.js
Last active Mar 3, 2021
Basic pattern for creating a custom Transform stream for use with gulp tasks.
View custom-task.js
var gulp = require('gulp');
var myTransform = require('./myTransform');
gulp.task('foobar', function (){
return gulp.src("foobar.js")
.pipe(myTransform())
.pipe(gulp.dest('.'));
});
@hashchange
hashchange / rounding.js
Created Jul 26, 2015
Floating-point versions of Math.round, Math.floor, Math.ceil
View rounding.js
/**
* 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 Aug 17, 2015
Returns the scroll target position for scrolling to the top of an element.
View scrollTargetPosition.js
/**
* 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
@khalwat
khalwat / set-project-perms.sh
Last active Jan 1, 2020
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
View set-project-perms.sh
This is now part of craft-scripts:
https://github.com/nystudio107/craft-scripts
@nrollr
nrollr / ApacheHTTPSConfig.md
Last active May 15, 2022
Enable SSL in Apache for 'localhost' (OSX, El Capitan)
View ApacheHTTPSConfig.md

Enable SSL in Apache (OSX)

The following will guide you through the process of enabling SSL on a Apache webserver

  • The instructions have been verified with OSX El Capitan (10.11.2) running Apache 2.4.16
  • The instructions assume you already have a basic Apache configuration enabled on OSX, if this is not the case feel free to consult Gist: "Enable Apache HTTP server (OSX)"

Apache SSL Configuration

Create a directory within /etc/apache2/ using Terminal.app: sudo mkdir /etc/apache2/ssl
Next, generate two host keys: