Skip to content

Instantly share code, notes, and snippets.

View BenBrostoff's full-sized avatar
💭
DFS + stocks, options trading

Ben Brostoff BenBrostoff

💭
DFS + stocks, options trading
View GitHub Profile
@BenBrostoff
BenBrostoff / normal-react.jsx
Created January 10, 2019 16:56
Normal react component
const SomeComponent = p => <div>{p.message}</div>;
@BenBrostoff
BenBrostoff / ts-react.jsx
Created January 10, 2019 15:58
React TS example
interface SomeProps {
message: string;
}
const SomeComponent: React.SFC<SomeProps> = p => <div>{p.message}</div>;
@BenBrostoff
BenBrostoff / sfc.ts
Last active January 9, 2019 14:13
React stateless functional component
type SFC<P = {}> = StatelessComponent<P>;
interface StatelessComponent<P = {}> {
(props: P & { children?: ReactNode }, context?: any): ReactElement<any> | null;
propTypes?: ValidationMap<P>;
contextTypes?: ValidationMap<any>;
defaultProps?: Partial<P>;
displayName?: string;
}
@BenBrostoff
BenBrostoff / steps.md
Last active September 12, 2018 17:56
How to run C++ code through Docker

Intro - made this originally for my friend trying to do C++ homework on a Mac.

  1. Add this Dockerfile
FROM alpine

RUN apk add --update make
RUN apk add build-base
RUN mkdir /mycode
@BenBrostoff
BenBrostoff / kubernetes.md
Last active July 18, 2018 12:03
Kubernetes notes

High Level Description

  • Orchestrator for a container environment
  • Job allocator

Terminology

  • Cluster - a set of computing instances that Kubernetes manages
  • Pod - Essentially a VM with a group of containers sharing OS, networking and storage that is separate from the node. The pod lives inside the ndode, and the containers live inside the pod.
  • Service - assigns fixed IP to pod replicas, allows other pods or services to communicate
@BenBrostoff
BenBrostoff / easier-log.js
Created June 27, 2018 15:56
Log without removing immediate return
// thanks to @jnelson for showing me this technique
const original = () => process.env.someThing;
// you might be tempted to do this
const original2 = () => {
console.log(process.env.someThing);
return process.env.someThing;
};
@BenBrostoff
BenBrostoff / good-tips-react-native.md
Last active September 18, 2018 23:24
Useful tips (mostly RN)
@BenBrostoff
BenBrostoff / compose.js
Created June 10, 2018 16:52
re-compose data fetching components
// https://github.com/acdlite/recompose/wiki/Recipes
// Container.js
import { compose, lifecycle, setStatic } from 'recompose';
import { retrieveStuff } from '../../services/db/index';
import SavedStuff from './SavedStuff';
import { generateNavOptions } from '../../nav';
const withStoryData = lifecycle({
state: { loading: true },
componentDidMount() {
@BenBrostoff
BenBrostoff / redux_getState.js
Created April 21, 2018 20:55
Redux getState
/**
* Reads the state tree managed by the store.
*
* @returns {any} The current state tree of your application.
*/
function getState() {
if (isDispatching) {
throw new Error(
'You may not call store.getState() while the reducer is executing. ' +
'The reducer has already received the state as an argument. ' +
@BenBrostoff
BenBrostoff / declarations.js
Created April 21, 2018 20:50
Redux declarations
let currentReducer = reducer
let currentState = preloadedState
let currentListeners = []
let nextListeners = currentListeners
let isDispatching = false
function ensureCanMutateNextListeners() {...}
function getState() {...}