(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.
| AZHU.storage = { | |
| save : function(key, jsonData, expirationMin){ | |
| if (!Modernizr.localstorage){return false;} | |
| var expirationMS = expirationMin * 60 * 1000; | |
| var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS} | |
| localStorage.setItem(key, JSON.stringify(record)); | |
| return jsonData; | |
| }, | |
| load : function(key){ | |
| if (!Modernizr.localstorage){return false;} |
| function slugify(text) | |
| { | |
| return text.toString().toLowerCase() | |
| .replace(/\s+/g, '-') // Replace spaces with - | |
| .replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
| .replace(/\-\-+/g, '-') // Replace multiple - with single - | |
| .replace(/^-+/, '') // Trim - from start of text | |
| .replace(/-+$/, ''); // Trim - from end of text | |
| } |
| // 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/ |
| { | |
| "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" |
(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.
| 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 { |
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
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| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| import configureStore from "./store/configureStore"; | |
| const store = configureStore(); | |
| const rootEl = document.getElementById("root"); |
| const fetch = require('node-fetch') | |
| const delay = (ms) => { | |
| return new Promise(resolve => { | |
| setTimeout(() => { | |
| resolve() | |
| }, ms) | |
| }) | |
| } | |
| const retryFetch = (url, fetchOptions={}, retries=3, retryDelay=1000) => { |