graph BT;
Object.prototype["<b>Object.prototype</b>"]
Function.prototype("<b>Function.prototype</b><br>call: <i>f</i><br>apply: <i>f</i><br>bind: <i>f</i>") --"<i>[[Prototype]]</i>"--> Object.prototype
foo(["foo: <i>f</i>"]) --"<i>[[Prototype]]</i>"--> Function.prototype
%% MyDate --"<i>[[Prototype]]</i>"--> Function.prototype
%% MyDate(["MyDate: <i>f</i>"]) -.-> |".prototype"| MyDate.prototype["<b>MyDate.prototype</b><br>getISOString: <i>f</i>"]
%% MyDate.prototype -.-> |".constructor"| MyDate
%% mydate["mydate: MyDate"] --"<i>[[Prototype]]</i>"--> MyDate.prototype --"<i>[[Prototype]]</i>"--> Object.prototype
%% anotherdate["anotherDate: MyDate"] --"<i>[[Prototype]]</i>"--> MyDate.prototypeclassDiagram
%% Values and Types
Type *-- "1..*" Value
%% Expressions
Type --o Expression : type inference
Value --o Expression : evaluationsequenceDiagram
participant mysqld as MySQL Server (3306)
participant ssh as ssh
participant sshd as sshd (22) <br> on <br> example.com
participant webd as Web Server
participant browser as Browser
ssh-->>+sshd: connect(example.com:22)
ssh->>sshd: TUNNEL(localhost:3306)
sshd-->>sshd: listen(localhost:3306)sequenceDiagram
participant mysql as MySQL Workbench
participant ssh as ssh
participant sshd as sshd (22) <br> on <br> example.com
participant mysqld as MySQL Server (3306) <br> on <br> example.com
ssh-->>ssh: listen(localhost:3306)
ssh-->>+sshd: connect(example.com:22)
rect rgb(240, 240, 240)
mysql-->>+ssh: connect(localhost:3306)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def perm(s: str): | |
| return [s] if len(s) < 2 else [c + p for c in set(s) for p in perm(s.replace(c, '', 1))] | |
| print(perm('abc')) | |
| print(perm('fphp')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import operator | |
| from functools import partial | |
| from itertools import accumulate, count, takewhile | |
| from random import randrange | |
| D = 6 # Number of die sides | |
| N = 1_000_000 # Number of die rolls | |
| zeros = partial(takewhile, operator.not_) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const gl = new Proxy(rawGL, { | |
| get(obj, key, ...rest) { | |
| const value = Reflect.get(obj, key, ...rest); | |
| return typeof value === 'function' | |
| ? new Proxy(value, { | |
| apply(method, _this, args) { | |
| console.log(`gl.${method.name}(${args.join(', ')})`); | |
| return Reflect.apply(method, obj, args); | |
| }, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sleep(ms) { | |
| return new Promise(function (resolve) { | |
| console.debug(`Sleeping for ${ms} ms...`); | |
| return setTimeout(resolve, ms); | |
| }); | |
| } | |
| // "then" chain example: | |
| function thenChainPlusLooseStatements() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function logInAsync(username, password) { | |
| return async function (dispatch) { | |
| dispatch(loginPending()); | |
| const body = new URLSearchParams(); | |
| body.set('username', username); | |
| body.set('password', password); | |
| const response = await fetch('/user/login', { | |
| method: 'POST', | |
| body, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable dot-notation */ | |
| const mysql = require('mysql2/promise'); | |
| const debug = require('debug'); | |
| const log = debug('server:mysql'); | |
| const host = process.env['DBHOST']; | |
| const port = process.env['DBPORT']; | |
| const user = process.env['DBUSER']; | |
| const password = process.env['DBPASS']; |
NewerOlder