This file contains 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 cProfile, pstats | |
import operator | |
import contextlib | |
from functools import reduce | |
from itertools import accumulate | |
import sys | |
def cumsum(num=0): | |
"""Loop based""" | |
total = 0 |
These are my notes, not a generic solution. They are not meant to work anywhere outside my machines. Update version numbers to whatever are the current ones while you do this.
asdf
lives in https://github.com/asdf-vm/asdf
Follow its installation instructions, which at the moment of writing were:
This file contains 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
#!/usr/bin/env python3 | |
import sys | |
import re | |
import requests | |
uri_regex = re.compile( | |
r'^(?:http|ftp)s?://' | |
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' | |
r'localhost|' |
This file contains 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
class LinkedList(): | |
"""A singly general purpose linked list implementation.""" | |
class _Node(): | |
"""A singly linked node.""" | |
def __init__(self, value, next=None): | |
self.next = next | |
self.value = value |
This file contains 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 { MyVeryUsefulProject } = require('../index'); | |
const { getFooOfId, saveFoo } = require('../infrastructure/inMemory'); | |
describe('Feature: updating bar', () => { | |
describe('scenario: updating bar with a value not containing a "?"', () => { | |
describe('given a foo object in database with the id foo1 and a bar value of "initial bar value"', () => { | |
describe('when updating the bar value to "some new value"', async (done) => { | |
test('then the foo object with id foo1 should have its bar value set to "some new value"', () => { | |
const inMemoryDatabase = { | |
foo1: { |
This file contains 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 assert = require("assert"); | |
function red(text) { | |
return `\x1b[30m\x1b[101m${text}\x1b[0m`; | |
} | |
function green(text) { | |
return `\x1b[30m\x1b[102m${text}\x1b[0m`; | |
} |
This file contains 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 compose (...fns) { | |
function _compose(fnA, fnB) { | |
if (fnA === undefined) { | |
throw new Error('compose needs at least one argument') | |
} | |
return (...args) => { | |
return fnA(fnB(...args)); | |
} | |
} |
This file contains 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
K --- Y // K e Y são opcionais; K e Y NÃO possuem quaisquer relações. | |
K === Y // K e Y são necessários; K e Y NÃO possuem quaisquer relações. | |
K --> Y // K e Y são opcionais; A presença de K demanda que Y esteja presente. | |
K --x Y // K e Y são opcionais; A presença de K demanda que Y NÃO esteja presente. | |
K ==x Y // K é necessário; A presença de K demanda que Y NÃO esteja presente (Y é proibido). | |
K ==> Y // K é necessário; A presença de K demanda que Y esteja presente (Y é necessário) | |
K <=> Y // K e Y são necessários; A presença de K demanda que Y esteja presente; A presença de Y demanda que K esteja presente. | |
K <-> Y // K e Y são opcionais; A presença de K demanda que Y esteja presente; A presença de Y demanda que K esteja presente. | |
K x-x Y // K e Y são opcionais; A presença de K demanda que Y NÃO esteja presente; A presença de Y demanda que K NÃO esteja presente. | |
K x=x Y // K e Y são proibidos; A presença de K demanda que Y NÃO esteja presente; A presença de Y demanda que K NÃO esteja presente. |
any
: magic, ill-behaved type that acts like a combination ofnever
(the proper [bottom type]) andunknown
(the proper [top type])- Anything at all is assignable to
any
, andany
is assignable to anything at all. - Identities:
any & AnyTypeExpression = any
,any | AnyTypeExpression = any
- Key TypeScript feature that allows for [gradual typing].
- Anything at all is assignable to
unknown
: proper, well-behaved [top type]- Anything at all is assignable to
unknown
.unknown
is only assignable to itself (unknown
) andany
. - Identities:
unknown & AnyTypeExpression = AnyTypeExpression
,unknown | AnyTypeExpression = unknown
- Anything at all is assignable to
- Prefer over
any
whenever possible. Anywhere in well-typed code you're tempted to useany
, you probably wantunknown
.
NewerOlder