Skip to content

Instantly share code, notes, and snippets.

import curry from 'crocks/helpers/curry'
import or from 'crocks/logic/or'
import pathSatisfies from 'crocks/predicates/pathSatisfies'
import propSatisfies from 'crocks/predicates/propSatisfies'
const list = [
'nice', 'bad', 'super bad'
]
const data = [
@mlynch
mlynch / auth.markdown
Last active September 4, 2020 18:11
AngularJS Authentication and CORS

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

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.

@abiodun0
abiodun0 / view_and_reader_monad.js
Last active September 16, 2021 04:10
React and reader monad from first principles https://codesandbox.io/s/react-composition-rjmzd
import ReactDOM from 'react-dom'
import Reac, { createElement } from 'react'
import { compose, map, ap, pipe } from 'ramda'
import IntlMessageFormat from 'intl-messageformat'
const copyrightNotice = View(({ author, year }) => <p>© {author} {year}</p>)
const Monad = {
do: gen => {
const Either = (() => {
const Right = x => ({
chain: f => f(x),
ap: other => other.map(x),
alt: other => Right(x),
extend: f => f(Right(x)),
concat: other =>
other.fold(
x => other,
y => Right(x.concat(y)),
@addyosmani
addyosmani / route-based-chunking.md
Last active December 28, 2021 06:18
Route-based chunking

Route-based chunking

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.

screen shot 2016-09-28 at 4 45 52 pm

This is a little backwards, especially when apps are used under real-world network (3G) and device

import R from 'ramda'
import { account } from 'store/lenses'
export default {
ids: R.view(account.ids),
recentActivity: R.memoize(
state => R.compose(
ids => {
const hash = R.view(account.data, state)
@stefanmaric
stefanmaric / notes.md
Last active February 11, 2023 04:51
CleverKek notes

y-combinator

const y = le => (f => f(f))(f => le(x => f(f)(x)))

fib func that would theoretically take advantage of TCO

'use strict'
const fib = (n, a = 1, b = 0) => n ? fib(n - 1, a + b, a) : b

ICS: Cinderella Tokens: An Async/IBC friendly alternative to flash loans

Flashloans are a fascinating economic coordination mechanism that has emerged out the Ethereum architecture as a result of a synchronous, sequential, atomic transaction system. It allows anonymous coordination between capital providers and arbitrageurs because the capital providers can condition providing any capital on protocol enforced guarantee that the entire arbitrage is profitable denominated in the token being lent.

One of the effects of this process has been the it ensures an efficient and healthy liquidation market for the collateral in long term debt instruments. It also enables low cost scaling of economic exploits.

Why don’t flash loans exist in IBC world?

Flash loans are impossible in an IBC world because IBC semantics require finalizing a block on the origin chain rather than on the receiving chain. This makes atomicity for the lender difficult and moves us into the domain of over collateralized lending.

@evilsoft
evilsoft / ours(preds addtion).md
Last active April 14, 2023 06:44
Simple Style Diffs
+ const isValidScore = score =>
+   score >= 70
+
+ const isValidUser = user =>
+   user && user.length > 3

data.reduce((acc, rec) => {
  const { score, user } = rec
import Maybe from 'crocks/Maybe'
import Star from 'crocks/Star'
import prop from 'crocks/Maybe/prop'
import propOr from 'crocks/helpers/propOr'
import resultToMaybe from 'crocks/Maybe/resultToMaybe'
import tryCatch from 'crocks/Result/tryCatch'
const MaybeStar =
Star(Maybe)