Skip to content

Instantly share code, notes, and snippets.

@derofim
derofim / path_cache.js
Created March 20, 2016 15:54
Path cache for screeps
module.exports = (function () { // store and reuse often used paths
function addPath(from, to, path) {
var key = getPathKey(from, to);
var cache = Memory.pathCache || {};
var cachedPath = {
path: path,
uses: 1
}
cache[key] = cachedPath;
@Geruhn
Geruhn / addGlobalStyle.js
Created November 25, 2013 16:59
JavaScript: addGlobalStyle(css)
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
@najlepsiwebdesigner
najlepsiwebdesigner / jquery.plugin.blank.template.js
Created February 19, 2013 10:36
great blank jquery plugin template!
/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
@marcedwards
marcedwards / high-dpi-media.css
Last active March 2, 2025 20:24
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */