Skip to content

Instantly share code, notes, and snippets.

View renatodeleao's full-sized avatar

Renato de Leão renatodeleao

View GitHub Profile
@brettz9
brettz9 / html5-dataset.js
Last active April 29, 2023 14:58
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License
@alademann
alademann / _map-get-deep-dot.scss
Last active February 25, 2019 12:40
Dot notation extension for SassyMap's map-get-deep Sass function
/**
* Fetch a deeply nested value in a multi-level map using object dot-notation string OR a list of keys.
*
* @requires sassy-maps
* @requires SassyLists
* @requires is-map
* @requires is-string
* @requires is-list
*
* @param {map} $map
@budparr
budparr / jekyll-collections-prev-next.html
Last active September 29, 2021 10:55
Previous Next Links for Jekyll Collections
{% capture the_collection %}{{page.collection}}{% endcapture %}
{% if page.collection %}
{% assign document = site[the_collection] %}
{% endif %}
<h1>TITLE: {{ page.title }}</h1>
{% for links in document %}
{% if links.title == page.title %}
{% unless forloop.first %}
{% assign prevurl = prev.url %}
{% endunless %}
@tswaters
tswaters / git-subdirectory-tracking.md
Last active February 19, 2024 21:15
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

@simevidas
simevidas / es6-modules-summary.md
Last active December 1, 2019 18:37
A summary of Jason Orendorff’s Mozilla Hacks post on ES6 modules

ECMAScript Modules

  • modules are automatically strict mode
  • declarations inside a module are scoped to that module (not visible by other scripts)
  • ECMAScript does not define what import does (it’s left up to the implementation)
  • there is no error recovery; “if anything fails to load or link, nothing runs”
  • exporting:
    • you can export any top-level function, class, var, let, or const

@taranda
taranda / dynamic-critical-path-css.md
Last active July 7, 2021 19:53
Dynamically Add Critical CSS to Your Rails App

Dynamically Add Critical CSS to Your Rails App

Optimizing the delivery of CSS is one way to improve user experience, load speed and SEO of your web app. This involves determining the "critical path CSS" and embeding it into the html of your page. The rest of the CSS for the site is loaded asynchronously so it does not block the rendering of your "above the fold" content. This Gist will show you how to dynamically generate critical path CSS for your Rails app.

In this example we will use the mudbugmedia/critical-path-css gem.

Prerequisites

You will need to set up caching and Active Job in your Rails app. I recommend using a thread-safe background job manager like resque.

@MariusRumpf
MariusRumpf / config.json
Last active November 23, 2021 02:35
Detect irregular whitespace in visual studio code with whitespace+ extension
// Whitespace+ irregular whitespace detection
// https://marketplace.visualstudio.com/items?itemName=davidhouchin.whitespace-plus
// Inspired by eslint https://github.com/eslint/eslint/blob/master/lib/rules/no-irregular-whitespace.js
{
"mode": "all",
"autoStart": true,
"refreshRate": 100,
"elements":
[{
"name": "space",
@DawidMyslak
DawidMyslak / vue.md
Last active April 22, 2024 12:49
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

(function () {
// An object with options for the IntersectionObserver.
const options = {
// 0.5 = The callback is fired when 50% of the element is visible
// We can add more values to the array, like 0.25, 0.75 or 1.0
threshold: [0.5]
};
// Instantiate the IntersectionObserver class
const observer = new IntersectionObserver((entries, observer) => {