Skip to content

Instantly share code, notes, and snippets.

@Dr-Nikson
Dr-Nikson / 0-redux-auth.MD
Last active October 23, 2017 17:16
This is a redux-auth concept

This gist is about token-based authentication (who you are?) with redux

Currently it for clent-side apps only. Not for universall (isomorphic) apps. Will add it soon

0. Requirements

I'm using the promise middleware to dispatch actions like this:

@patio11
patio11 / bitfinex-03152019.md
Created April 26, 2019 00:29
`shasum bitfinex-03152019.md` is 938d939059a23aa84ce493db0c4d542748f849a7

Prediction as of 3/15/2019 JST:

  • Bitfinex is insolvent, for the Bitcoin economy's usual quixotic definition of insolvent.
  • This happened as a result of collateralizing Tether with BTC and other cryptocurrencies during the run-up.
  • Bitfinex / Tether treat whether Bitfinex held the collateral or Tether held the collateral as a material distinction, but that's ridiculous due to common control. The important fact: in 2018, ground truth diverged from "There is $1 in a bank account for every tether outstanding" to "There is $1 in a bank account and/or $1 worth of Bitcoin at prevailing prices available to Bitfinex for every tether outstanding."
  • This makes Tether synthetically long Bitcoin, via a receivable from Bitfinex. Bitfinex took the newly issued Tether and then, since this accounting shellgame appears to balance its books and leave it with surplus Bitcoin, either sold or lent the Bitcoin to short sellers during the run-up.
  • If Bitfinex simply sold the Bitcoin, they're doing relatively well for themselve
@markerikson
markerikson / dispatching-action-creators.js
Last active May 2, 2020 14:27
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
@WickyNilliams
WickyNilliams / README.md
Last active September 24, 2020 11:01
So you want to publish a react component?!

So you want to publish a react component?!

This is a quick guide of what you need to do to publish a react component for use by others. This guide is distilled from a conversation [0] on twitter. I will reference individual tweets, where appropriate (thereby shifting blame for incorrect advice from me to the authors :D)

Assumptions

  1. You are using some sort of module system in your source
  2. You have a build step
  3. You want broad support for your component (browser-ready, npm compatible, consumable by bower)
@aweary
aweary / App.js
Last active August 29, 2021 14:06
import React from "react";
import useMutableReducer from "./useMutableReducer";
const reducer = (draft, action, state) => {
switch (action) {
case "increment":
draft.count++;
break;
case "decrement":
draft.count--;
@statico
statico / pitchpatterns.md
Last active November 10, 2021 21:36
Pitch Paterns
@tlrobinson
tlrobinson / prettier-branch.sh
Last active December 13, 2021 00:00
Steps for merging an old branch into a newly prettier-ified codebase. Use at your own risk, verify everything was correctly merged.
# Assumes 3 sequential commits:
#
# 1. commit tagged "prettier-before" that added `prettier` depedency and `prettier` script your package.json
# 2. commit that actually ran `prettier` on your entire codebase for the first time
# 3. commit tagged "prettier-after" that fixes any minor issues caused by prettier (e.x. moving eslint-ignore or $FlowFixMe comments around), or just the next commit if there were none
#
# I recommend running these as individual commands, not as a script, in case of merge conflicts
#
# Checkout the non-pretty branch you want to merge
# (or optionally make a new branch with `git checkout -b $YOUR_BRANCH-prettier $YOUR_BRANCH`)
@addyosmani
addyosmani / preprocessing.md
Last active January 17, 2023 17:07
JavaScript preprocessing/precompilation

Problem: How can we preprocess JavaScript (at build-time or on the server-side) so engines like V8 don't have to spend as much time in Parse? This is a topic that involves generating either bytecode or a bytecode-like-abstraction that an engine would need to accept. For folks that don't know, modern web apps typically spend a lot longer in Parsing & Compiling JS than you may think.

  • Yoav: This can particularly be an issue on mobile. Same files getting parsed all the time for users. Theoretically if we moved the parsing work to the server-side, we would have to worry about it less.
  • One angle to this problem is we all ship too much JavaScript. That's one perspective. We could also look at preprocessing.
  • We've been talking about this topic over the last few weeks a bit with V8. There were three main options proposed.
    1. Similar to what optimize-js does. Identify IIFEs and mark them as such so the browser and VMs heuristics will catch them and do a better job than today. optimize-js only tackles IIFE bu
I was drawn to programming, science, technology and science fiction
ever since I was a little kid. I can't say it's because I wanted to
make the world a better place. Not really. I was simply drawn to it
because I was drawn to it. Writing programs was fun. Figuring out how
nature works was fascinating. Science fiction felt like a grand
adventure.
Then I started a software company and poured every ounce of energy
into it. It failed. That hurt, but that part is ok. I made a lot of
mistakes and learned from them. This experience made me much, much
@clarkbw
clarkbw / redux-performance-mark.js
Last active February 8, 2024 05:03
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
performance.mark(`${action.type}_start`);
let result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
);
return result;