A timeline of the last four years of detecting good old window.localStorage.
October 2009: 5059daa
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
A timeline of the last four years of detecting good old window.localStorage.
October 2009: 5059daa
| import codecs | |
| import struct | |
| class Codec(codecs.Codec): | |
| def encode(self,input,errors='strict'): | |
| pass | |
| def decode(self,input,errors='strict'): | |
| unistr = u'' |
| #!/usr/bin/env python | |
| import sys | |
| import struct | |
| import binascii | |
| def mkchunk(tp, data): | |
| return struct.pack("!L", len(data)) + tp + data + struct.pack("!L", binascii.crc32(tp + data) & 0xffffffff) | |
| def getchunk(f, tp): | |
| f.seek(0) |
In the Brackets editor, have you noticed that the HTML within <SCRIPT type="text/ng-template"> is not syntax-colored? Here is how to fix it.
AngularJS has support for inline HTML templates. I am going to explain here only how to get the syntax coloring working, not what inline-templates actually are. To create an inline-template, you put the template's HTML into a SCRIPT tag like this:
<SCRIPT type="text/ng-template" id="/path/to/your/template.html">template: {{HTML}} here</SCRIPT>| from tkinter import * | |
| import asyncio | |
| from functools import wraps | |
| import websockets | |
| def runloop(func): | |
| ''' | |
| This decorator converts a coroutine into a function which, when called, | |
| runs the underlying coroutine to completion in the asyncio event loop. | |
| ''' |
| title | slug | createdAt | language | preview |
|---|---|---|---|---|
Unit testing Angular.js app with node.js, mocha, angular-mocks and jsdom |
unit-testing-angular-js-app-with-node |
2015-07-05T18:04:33Z |
en |
Majority of search result about unit testing Angular.js apps is about how to do it by using test frameworks that run the tests in a real browser. Even though it's great to be able to test your code in multiple platforms, in my opinion it creates a lot of boilerplate code and makes it hard to run the tests in, for instance a CI-server. |
Lean unit tests with minimal setup
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.offsetParentVisit Gist and see 'raw' link, It's including SHA-1 long hash name like this.
https://gist.github.com/raw/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {