Skip to content

Instantly share code, notes, and snippets.

View bloadvenro's full-sized avatar

Viktor bloadvenro

View GitHub Profile
#!/bin/env bash
mkdir src
cat << END > src/index.tsx
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
const appRoot = document.querySelector("#root");
const isTestEnv = process.env.NODE_ENV === 'test';
module.exports = {
presets: [
[
'@babel/preset-env',
{
modules: isTestEnv
? 'commonjs' // transform imports for jest to work
: false, // do not transform imports to allow tree shaking by webpack
type Tuple<T = unknown> = [T] | T[]
type Tail<A extends Tuple> =
((...args: A) => any) extends ((h: any, ...t: infer T) => any) ? T : never
type HandleVoidAnyUnknown<Target, Fallback> = [void] extends [Target /* void/any/unknown */]
? Fallback
: Target
type StrictestFromTwo<L, R> =
import { Effect, Event, sample, Store, Unit } from "effector"
declare let unit: Unit<number>
declare let store: Store<number>
declare let event: Event<number>
declare let effect: Effect<number, number>
store = sample(store)
store = sample(store, store)
event = sample(store, event)
@bloadvenro
bloadvenro / add-p.md
Created November 26, 2019 13:00 — forked from mattlewissf/add-p.md
Lightning Talk: Git add -p

git add -p is your friend

git add -p is basically "git add partial (or patch)"

Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.

It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:

from the command line, either use

  • git add -p
@bloadvenro
bloadvenro / README.md
Created November 20, 2019 06:40
*nix shell tips ant tricks

*nix shell tips ant tricks

@bloadvenro
bloadvenro / create-parcel-boilerplate
Last active November 9, 2019 00:33
Easily create Parcel boilerplates (vanillaJS, TS, React, React+TS)
#!/bin/bash
script_dir=$(pwd)
project_home=$1
isEmpty() { [ -z $1 ] ; }
isCliFlag() { [[ $1 == --* ]] ; }
if isEmpty $project_home || isCliFlag $project_home
then

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
@bloadvenro
bloadvenro / do-on-subscribe.rxjs.operator.ts
Created April 12, 2019 13:48 — forked from evxn/do-on-subscribe.rxjs.operator.ts
rxjs on subscribe hook, callback on subscribe, doOnSubscribe operator, doOnSubscribe pipe, rxjs onSubscribe
import {defer} from 'rxjs/observable/defer';
import {Observable} from 'rxjs/Observable';
/** Example
import {from} from 'rxjs/observable/from';
from([1, 2, 3])
.pipe(doOnSubscribe(() => console.log('subscribed to stream')))
.subscribe(x => console.log(x), null, () => console.log('completed'));
*/
interface Dispatch<A extends { type: string }> {
(action: A): void;
}
interface StateGetter<S extends { [key: string]: any }> {
(): S;
}
interface ActionReducer<A extends { type: string }, S extends { [key: string]: any }> {
dispatch: Dispatch<A>;