Language | Execution time(sec) |
---|---|
JS with V8 (Node 8.11) | 3.18 |
PHP 7.2 | 28.026075124741 |
PHP 7.0 | 28.537676095963 |
Ruby 2.5 | 37.355172 |
Python 2.7 | 70.2023770809 |
Python 3.6 | 99.59470009803772 |
import asyncio | |
class DummyAPI: | |
async def get(self, number): | |
print(f"GET {number} executed") | |
await asyncio.sleep(number) | |
return number, "a" | |
async def context_switched_get(self): | |
dispatch_list = [] |
``` | |
from sanic.log import logger | |
from insanic.conf import settings | |
from functools import wraps | |
from time import time | |
def measure_time(f): | |
@wraps(f) |
#!/bin/bash | |
# Author: @radekk | |
# List of vulnerable packages is from https://twitter.com/iamakulov/status/892485192883073024 | |
# ---------------------- | |
_IFS=$IFS | |
_COUNTER=0 | |
_COUNTER_ALL=0 | |
_SCAN_PATH=${1:-~/} | |
_VULN_PACKAGES="babelcli crossenv cross-env.js d3.js fabric-js ffmepg gruntcli http-proxy.js jquery.js mariadb mongose mssql.js mssql-node mysqljs nodecaffe nodefabric node-fabric nodeffmpeg nodemailer-js nodemailer.js nodemssql node-opencv node-opensl node-openssl noderequest nodesass nodesqlite node-sqlite node-tkinter opencv.js openssl.js proxy.js shadowsock smb sqlite.js sqliter sqlserver tkinter" | |
_REGEXP="(babelcli|crossenv|cross-env\.js|d3\.js|fabric-js|ffmepg|gruntcli|http-proxy\.js|jquery\.js|mariadb|mongose|mssql\.js|nodecaffe|nodefabric|node-fabric|nodeffmpeg|nodemailer-js|nodemailer\.js|nodemssql|node-opencv|node-opensl|node-openssl|noderequest|nodesass|nodesqlite|node-sqlite|node-tkinter|opencv\.js|openssl\.js|proxy\.js|shadowsock|smb|sqlite\.js|sqliter|sqlserver|tkinter)" |
var old_sin = Math.sin; | |
Math.sin = function(x) { | |
if (typeof x == "number" && isFinite(x)){ | |
return old_sin(x); | |
} | |
var str = "" + x; | |
if (str.length>0){ | |
str = str.repeat(Math.ceil(Math.max(1,18/str.length))); | |
} | |
var sinstr = "|\n"; |
CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.
In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.
First, let's illustrate the 3 styles by implementing
Here are all of the resources mentioned by Deconstruct 2017 speakers, along with who recommended what. Please post a comment if I missed something or have an error!
- Seeing Like a State by James Scott
- Public Opinion by Walter Lippmann (Evan Czaplicki)
- A Pattern Language by Christopher Alexander (Brian Marick)
- Domain Driven Design by Eric Evans (Brian Marick)
This is my ZSH theme. I've had it for years, this adoption is for use as an antigen theme.
The git prompt looks like this:
- Current git project name (blue: last exit status was ok, red: last exit status failed)
- Time since last commit
- Branch name or commit ref (green: working tree is clean, red: dirty working tree)
- Merge status (↑ is you can push, ↓ is you can pull, ↕ means you have diverged)
This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:
- TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
- In the wild, we're seeing
(async main(){...}())
as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems - Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.
I'll leave the rest of this document unedited, for archaeological