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 | |
| } |
| # Useful for testing things that are time zone | |
| # sensitive - like scheduling things | |
| # Get current timezone | |
| sudo systemsetup -gettimezone | |
| # Get list of available timezones | |
| sudo systemsetup -listtimezones | |
| # Set the timezone to the selected timezone |
When [Markdown][markdown] appeared more than 10 years ago, it aimed to make it easier to express ideas in an easy-to-write plain text format. It offers a simple syntax that takes the writer focus away from the formatting, thus giving her time to focus on the actual content.
The market abunds of editors to be used for help with markdown. After a few attempts, I settled to Sublime and its browser preview plugin, which work great for me and have a small memory footprint to accomplish that. To pass the results around to other people, less technical, a markdown file and a bunch of images is not the best approach, so converting it to a more robust format like PDF seems like a much better choice.
[Pandoc][pandoc] is the swiss-army knife of converting documents between various formats. While being able to deal with heavy-weight formats like docx and epub, we will need it for the more lightweight markdown. To be able to generate PDF files, we need LaTeX. On OSX, the s