- When Gatsby starts up, it will read
gatsby-config.js
first. - As you can see below, we use that file to
require('ts-node').register()
which registers a TypeScript evaluator that will be used when Gatsby reads all other API Javascript files. In other words, we only need to do this once in our entire codebase and not in other Gatsby files likegatsby-node.js
. - Our
gatsby-config.js
re-exports all the exported variables available ingatsby-config.ts
.
(function () { | |
var video = document.querySelector('video:not([title="Advertisement"])') | |
if (!video.webkitSupportsPresentationMode || typeof video.webkitSetPresentationMode !== 'function') { | |
console.error('Esse código só funciona no Safari!') | |
return | |
} | |
var scoreX = document.querySelector('.placar__equipes') | |
var button = document.createElement('button') |
const fetch = require('node-fetch') | |
const delay = (ms) => { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve() | |
}, ms) | |
}) | |
} | |
const retryFetch = (url, fetchOptions={}, retries=3, retryDelay=1000) => { |
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import configureStore from "./store/configureStore"; | |
const store = configureStore(); | |
const rootEl = document.getElementById("root"); |
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.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.
However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on
import Foundation | |
extension String | |
{ | |
// Works in Xcode but not Playgrounds because of a bug with .insert() | |
mutating func insertString(string:String,ind:Int) { | |
var insertIndex = advance(self.startIndex, ind, self.endIndex) | |
for c in string { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
{ | |
"scripts": { | |
"eslint": "LIST=`git diff-index --name-only HEAD | grep .*\\.js | grep -v json`; if [ \"$LIST\" ]; then eslint $LIST; fi" | |
}, | |
"devDependencies": { | |
"pre-commit": "0.0.7", | |
"eslint": "~0.5.1" | |
}, | |
"pre-commit": [ | |
"eslint" |
// XORCipher - Super simple encryption using XOR and Base64 | |
// | |
// Depends on [Underscore](http://underscorejs.org/). | |
// | |
// As a warning, this is **not** a secure encryption algorythm. It uses a very | |
// simplistic keystore and will be easy to crack. | |
// | |
// The Base64 algorythm is a modification of the one used in phpjs.org | |
// * http://phpjs.org/functions/base64_encode/ | |
// * http://phpjs.org/functions/base64_decode/ |