I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.Note: This is an old post from back when I was trying to make sense of why inets are so fast for evaluating some λ-terms. It has some silly bits, I learned a lot since and could probably write a better article today, but I think this can still be insightful for these getting started, so I'll leave it here.
Yesterday, I reported the bizarre observation that certain functions can behave as if they had negative complexity. If you haven’t checked that article yet, it isn’t necessary, but you should, as it may blow your mind. In short, the λ-term f(bits) = copy(comp(inc,n,bits)), when given to optimal λ-calculus evaluator, is asymptotically faster than g(bits) = comp(inc,n,bits); i.e.,copy (a O(1) operation for a fixed size) behaves as if it had a O(1/n) complexity, causing the program to run faster by doing more things (!?).
That’s not the only bizarre complexity result I had when
| import { v4 as uuid } from 'uuid'; | |
| export function generateId() { | |
| return uuid(); | |
| } | |
| const v4 = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i); | |
| console.log(generateId().match(v4)); | |
| //console.log(generateId().length) |
The kernel lets you run code in a particular programming language using one of the Jupyter tools, such as the Notebook, Jupyterlab or nteract. Installing additional kernels will let you run code in more languages using your existing jupyter installation.
Technically, the kernel is an application which speaks the Jupyter Messaging Protocol, to receive code input from the frontend and respond with the results.
In the Notebook or JupyterLab, the list of available kernels will be shown when trying to create a new notebook.
| # | |
| # $> ruby load.rb http://data.githubarchive.org/2012-04-01-15.json.gz | |
| # | |
| require 'yajl' | |
| require 'zlib' | |
| require 'sqlite3' | |
| require 'open-uri' | |
| input = ARGV.shift |
| /* Fetch data from GitHub Archive using Google's BigQuery */ | |
| select actor, repository_language, count(repository_language) as pushes | |
| from [githubarchive:github.timeline] | |
| where type='PushEvent' | |
| and repository_language != '' | |
| and PARSE_UTC_USEC(created_at) >= PARSE_UTC_USEC('2012-01-01 00:00:00') | |
| and PARSE_UTC_USEC(created_at) < PARSE_UTC_USEC('2013-01-01 00:00:00') | |
| group by actor, repository_language; |