// Lazy Getters | |
/* What enables Tail Recursion Modulo Cons in Javascript is a thunk in Weak Head Normal Form. | |
An expression in weak head normal form has been evaluated to the outermost data constructor, | |
but contains sub-expressions that may not have been fully evaluated. In Javascript only thunks | |
can prevent sub-expressions from being immediately evaluated. */ | |
const cons = (head, tail) => ({head, tail}); | |
Note:
When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.
If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:
- Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
How to configure your Mac to use DNS over TLS in five easy steps:
-
Install Stubby with Homebrew (https://dnsprivacy.org/wiki/display/DP/DNS+Privacy+Daemon+-+Stubby):
brew install stubby
-
Edit the configuration file:
// WARNING: Completely untested code. it might not work and/or it might have | |
// things that don't work well. Just made for illustrational purposes | |
// redux-observable shines the most with complex async stuff, like WebSockets | |
// but many of us will still use it for more modest things like AJAX requests. | |
// In these cases, there can be a ton of repetitive boilerplate. So this is a | |
// simple example of applying some abstractions and conventions to make it easier. | |
// THAT SAID, since abstractions cause indirection it can make it harder for | |
// someone to come along later and know how something works. Weigh the costs | |
// and remember, this example isn't a suggestion of the actual code you should |
Minimal loader with state management capabilities.
Checkout out the demo.
Make sure to add a .babelrc
file:
const SomeScreen = () => ( | |
<div> | |
<Blah /> | |
<Categories | |
render={categories => ( | |
<Expenses | |
render={expenses => ( | |
<div> | |
{groupExpensesByCategory(categories, expenses).map(category => ( | |
<RandomScreen {...category} /> |
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:
- Don't use
Math.random()
. There are extremely few cases whereMath.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. - Don't use
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. - If you want to generate random tokens or API keys: Use
uuid
, specifically theuuid.v4()
method. Avoidnode-uuid
- it's not the same package, and doesn't produce reliably secure random values. - If you want to generate random numbers in a range: Use
random-number-csprng
.
You should seriously consider reading the entire article, though - it's
Proposal for this year's Reactive lightning talks @ReactiveConf - If you want to see my talk, star this gist please :-) [Reactive Blogpost][reactive-conference-blogpost]
As a JavaScript developer, could you imagine using something else than Atom, Sublime or other IDE-like text-editors? During their daily work, people wrangle a lot with different applications, editors, windows, browsers and loose a lot of time because of their tools getting in their way.