Skip to content

Instantly share code, notes, and snippets.

💭
🐺⚔️🛡️🐲🏹❄️🔥

Daniel Mascena danielmascena

💭
🐺⚔️🛡️🐲🏹❄️🔥
Block or report user

Report or block danielmascena

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Object.is-polyfill.js
if (!Object.is) {
Object.is = function(x, y) {
// SameValue algorithm
if (x === y) { // Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
@gaearon
gaearon / index.html
Last active Oct 15, 2019
Add React in One Minute
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
</head>
<body>
<h2>Add React in One Minute</h2>
<p>This page demonstrates using React with no build tooling.</p>
View string.md

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@vkarpov15
vkarpov15 / promise1.js
Created Apr 5, 2018
Write Your Own Node.js Promise Library from Scratch, Part 1
View promise1.js
class MyPromise {
constructor(executor) {
if (typeof executor !== 'function') {
throw new Error('Executor must be a function');
}
// Internal state. `$state` is the state of the promise, and `$chained` is
// an array of the functions we need to call once this promise is settled.
this.$state = 'PENDING';
this.$chained = [];
View Repeatable example of lit-html issue.html
<!DOCTYPE html>
<html>
<body>
<div id=target></div>
<script type="module" charset="utf-8">
import { html, render } from './lit-html.js';
const renderForm = (entity) => {
const e = [];
Object.keys(entity).forEach((attr) => {
@evantoli
evantoli / GitConfigHttpProxy.md
Last active Oct 18, 2019
Configure Git to use a proxy
View GitConfigHttpProxy.md

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@jacomyal
jacomyal / README.md
Created Dec 12, 2014
A problem with Function.prototype.bind polyfill
View README.md

I met an issue with the common polyfill for Function.prototype.bind, found on the MDN, and I do not know where to fix it.

Here is the polyfill:

if (!Function.prototype.bind) {
  Function.prototype.bind = function(oThis) {
    if (typeof this !== 'function') {
      // closest thing possible to the ECMAScript 5
      // internal IsCallable function
      throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
View table.css
table { display: table }
tr { display: table-row }
thead { display: table-header-group }
tbody { display: table-row-group }
tfoot { display: table-footer-group }
col { display: table-column }
colgroup { display: table-column-group }
td, th { display: table-cell }
caption { display: table-caption }
@jcgregorio
jcgregorio / How_to_use.html
Last active Aug 14, 2019
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
View How_to_use.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@magicznyleszek
magicznyleszek / css-selectors.md
Last active Oct 19, 2019
CSS Selectors Cheatsheet
View css-selectors.md

CSS Selectors Cheatsheet

Element selectors

Element -- selects all h2 elements on the page

h2 {
    foo: bar;
You can’t perform that action at this time.