Skip to content

Instantly share code, notes, and snippets.

@imjasonh
imjasonh / markdown.css
Last active January 3, 2025 20:15
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@paulirish
paulirish / bling.js
Last active May 5, 2025 12:44
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)); };
@ef4
ef4 / select.hbs
Last active October 7, 2021 09:41
Goodbye old Select View
<select onchange={{action (mut vehicle) value="target.value"}}>
{{#each vehicles key="@item" as |vehicleChoice|}}
<option value={{vehicleChoice}} selected={{eq vehicle vehicleChoice}}>{{vehicleChoice}}</option>
{{/each}}
</select>
@paulirish
paulirish / what-forces-layout.md
Last active May 8, 2025 05:49
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@gaearon
gaearon / slim-redux.js
Last active December 3, 2024 06:34
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@davideast
davideast / rules.bolt
Last active December 15, 2015 18:33
Securing user data - Bolt rules
isUser(uid) = auth != null && auth.uid == uid;
type Post {
uid: String;
title: String;
description: String;
timestamp: Number;
}
type User {
@runspired
runspired / named-yields.md
Last active April 21, 2023 17:14
Some thoughts I had on named yeilds

Ember Named Yields

Current Idea

The current thinking floating around for named yields looks something like this. You can't mix use of named blocks and non-blocked content. Once you use a block helper within a component, everything, including your main yield needs to be within one. If you don't use one, then your yielded content is the main block. This gist is a suggestion I have for how named yields should be implemented and work, and follows the evolution of my thinking on it.

@marty-wang
marty-wang / compose function
Created July 5, 2016 04:24
Very small compose function
const compose = (...fns) => (...args) => fns.reduceRight((input, fn) => fn.apply(null, [].concat(input)), args)
const combine = (...args) => args.join(" ")
const shout = (x) => x.toUpperCase()
const emphasize = (x) => `${x}!`
const yell = compose(emphasize, shout, combine)
console.log(yell("hello", "world")); // "HELLO WORLD!"
@billybonks
billybonks / SPEC.md
Last active August 28, 2018 06:22
Translations

These are my thoughts, on how the translation files should be modeled, take into consideration the following postulates:

  • Web applications are modeled around their data.
  • Web applications data models have the following states.
    • Saved
    • Deleted
    • Updated
    • Empty
    • Created
    • Loading
@nemtsov
nemtsov / remove-unused-imports.js
Last active January 22, 2025 15:17
A jscodeshift to remove unused imports
module.exports = (file, api, options) => {
const j = api.jscodeshift;
const printOptions = options.printOptions || {quote: 'single'};
const root = j(file.source);
const requires = {};
const filterAndTransformRequires = path => {
const varName = path.value.local.name;
const scopeNode = path.parentPath.scope.node;