const y = le => (f => f(f))(f => le(x => f(f)(x)))'use strict'
const fib = (n, a = 1, b = 0) => n ? fib(n - 1, a + b, a) : b| const daggy = require('daggy') | |
| const { uncurryN } = require('wi-jit') | |
| Array.prototype.empty = () => [] | |
| Sum = daggy.tagged('value') | |
| Sum.prototype.concat = function (that) { | |
| return Sum(this.value + that.value) | |
| } |
| /* ----------------------------------------- * | |
| Lazy List Implementation | |
| * ----------------------------------------- */ | |
| // Haskell-like infinite List, implemented with es6 generators | |
| // Lazyness lets you do crazy stuff like | |
| List.range(0, Infinity) | |
| .drop(1000) | |
| .map(n => -n) |
| const fl = require('fantasy-land') | |
| //- Textbook rose tree. | |
| //+ type RoseTree a = { value :: a, children :: [RoseTree a] } | |
| function RoseTree(value, children) { | |
| if (this.constructor !== RoseTree) | |
| return new RoseTree(value, children) | |
| Object.assign(this, { value, children }) | |
| } |
| const fl = require('fantasy-land') | |
| //- Lazy holds a vaue in a thunk, effectively delaying | |
| //- evaluation until required. This is useful when we're | |
| //- in a situation with either very large data set or | |
| //- cyclical data. | |
| //@ make stack-safe. | |
| //> type Lazy a = Unit -> a | |
| function Lazy(run) { |
Many of us building single-page apps today use JavaScript module bundling tools that trend towards a monolithic "bundle.js" file including the full app and vendor code for multiple routes. This means if a user lands on any arbitrary route they need to wait for a large bundle of JS to be fetched, parsed and executed before the application is fully rendered and interactive.
This is a little backwards, especially when apps are used under real-world network (3G) and device
Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.
The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from
| // connect() is a function that injects Redux-related props into your component. | |
| // You can inject data and callbacks that change that data by dispatching actions. | |
| function connect(mapStateToProps, mapDispatchToProps) { | |
| // It lets us inject component as the last step so people can use it as a decorator. | |
| // Generally you don't need to worry about it. | |
| return function (WrappedComponent) { | |
| // It returns a component | |
| return class extends React.Component { | |
| render() { | |
| return ( |
Picking the right architecture = Picking the right battles + Managing trade-offs
Single Page Apps are ruling the world and AngularJS is leading the charge. But many of the lessons we learned in the Web 2.0 era no longer apply, and few are as drastically different as authentication.
CORS is an oft-misunderstood feature of new browsers that is configured by a remote server. CORS stands for Cross-Origin-Resource-Sharing, and was designed to make it possible to access services outside of the current origin (or domain) of the current page.
Like many browser features, CORS works because we all agree that it works. So all major browsers like Chrome, Firefox, and IE support and enforce it. By using these browsers, you benefit from the security of CORS.
That means certain browsers do not enforce it, so it is not relevant there. One large example is a native Web View for things like Cordova and Phonegap. However, these tools often have configuration options for whitelisting domains so you can add some security that way.