Standard escape codes are prefixed with Escape
:
- Ctrl-Key:
^[
- Octal:
\033
- Unicode:
\u001b
- Hexadecimal:
\x1b
- Decimal:
27
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
import foo from 'foo'
instead of const foo = require('foo')
to import the package. You also need to put "type": "module"
in your package.json and more. Follow the below guide.await import(…)
from CommonJS instead of require(…)
./* calculator in javascript using functional programming principles */ | |
const operators = ["+", "*", "-", "/"]; | |
//isOperator checks if a given character is an operator | |
const isOperator = char => operators.includes(char); | |
/* all operations to be used */ | |
const operations = { | |
"/": (a, b) => a / b, | |
"*": (a, b) => a * b, |
Not all random values are created equal - for security-related code, you need a specific kind of random value.
A summary of this article, if you don't want to read the entire thing:
Math.random()
. There are extremely few cases where Math.random()
is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.crypto.getRandomBytes
directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.uuid
, specifically the uuid.v4()
method. Avoid node-uuid
- it's not the same package, and doesn't produce reliably secure random values.random-number-csprng
.You should seriously consider reading the entire article, though - it's
^3[47][0-9]{13}$
^(6541|6556)[0-9]{12}$
^389[0-9]{11}$
^3(?:0[0-5]|[68][0-9])[0-9]{11}$
^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
^63[7-9][0-9]{13}$
^(?:2131|1800|35\d{3})\d{11}$
^9[0-9]{15}$
function add1(v) { return v + 1; } | |
function isOdd(v) { return v % 2 == 1; } | |
function sum(total,v) { return total + v; } | |
var list = [2,5,8,11,14,17,20]; | |
list | |
.map( add1 ) | |
.filter( isOdd ) | |
.reduce( sum ); |
function throttle(callback, wait, immediate = false) { | |
let timeout = null | |
let initialCall = true | |
return function() { | |
const callNow = immediate && initialCall | |
const next = () => { | |
callback.apply(this, arguments) | |
timeout = null | |
} |
I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)