Skip to content

Instantly share code, notes, and snippets.

@rungta
rungta / fontloader.js
Last active May 1, 2019 06:10
Load CSS `@font-face` fonts by listening for font loading events. A workaround while we wait for browsers to support the `font-rendering: swap` property.
/**
* fontloader.js
Helps you avoid FOIT and progressively load in multiple
sets of webfonts as asynchronous non-blocking resources.
Apply them on the page when the fonts are ready, like so:
.title-type { font-family: serif; }
.prose-type { font-family: sans-serif; }
@paulirish
paulirish / bling.js
Last active May 26, 2025 20:31
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@croxton
croxton / ee_multilanguage_with_resource_router.md
Last active April 5, 2022 19:11
Using Resource Router for roll-your-own multi-language ExpressionEngine sites

Multi-language routing with Resource Router

The idea is to set up ISO 639-1 language code prefixes for urls (e.g. en/, de/, fr/), and set global variables {global:lang} and {global:lang_dir} for use in your templates.

In the control panel create a category group "languages" and populate it with your languages, setting the category url title to the appropriate 2-letter language code. Assign the category group to the channels you want to translate.

For example:

Category Name Category URL Title
@gak
gak / fish-prompt.sh
Last active February 4, 2022 18:34
My custom fish prompt code explained at http://geraldkaszuba.com/tweaking-fish-shell/
function _common_section
printf $c1
printf $argv[1]
printf $c0
printf ":"
printf $c2
printf $argv[2]
printf $argv[3]
printf $c0
printf ", "
@nifl
nifl / check_object_instance.md
Created November 26, 2012 20:17
It is NOT 'bad' to use the new keyword. But if you forget it, you will be calling the object constructor as a regular function. If your constructor doesn't check its execution context then it won't notice that 'this' points to different object (ordinarily

And yes, new has one crucial disadvantage, ably described by other answers: if you forget to use it, your code will break without warning. Fortunately, that disadvantage is easily mitigated - simply add a bit of code to the function itself:

function foo()
{
   // if user accidentally omits the new keyword, this will 
   // silently correct the problem...
   if ( !(this instanceof foo) )
      return new foo();

// constructor logic follows...

@nifl
nifl / record.cfm
Created November 19, 2012 18:35
Queries QB for record object. If record ID exists, update; Otherwise create new record.
<!---
Name: record.cfm
Author: Gernot Bartels
Description: Queries QB for record object.
If record ID exists, update;
Otherwise create new record.
History: Created
Added logic
Usage: Surveys, Intake,
Created: 2011-08-05
@croxton
croxton / stash_nested_embeds.md
Created October 29, 2012 14:23
Stash & template partials - nested embed

Required:

Stash 2.3.4 (beta) or later

Stash template directory

	/layouts/
		standard.html

	/partials/

listing.html

@nifl
nifl / js_notes.md
Last active September 26, 2015 20:57
JavaScript Notes

Javascript notes

JS is ...

  • Interpreted, not compiled
  • Case-sensitve
  • Whitespace insensitive except within quotes

Placement

@jasonrudolph
jasonrudolph / about.md
Last active May 2, 2025 12:20
Programming Achievements: How to Level Up as a Developer
<?php
/**
* Custom configuration bootstrap file for ExpressionEngine
*
* Place config.php in your site root
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/config.php
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/database.php
* If you have moved your site root you'll need to update the require_once path
*