Skip to content

Instantly share code, notes, and snippets.

View sompylasar's full-sized avatar

Ivan Babak sompylasar

View GitHub Profile
@markerikson
markerikson / FormContentsContainer.jsx
Last active February 28, 2021 21:31
Redux form editing HOC
import React, {Component} from 'react';
import {bindActionCreators} from "redux"
import { connect } from 'react-redux';
import {schema, getModelByType} from "models/models"
import SomeFormComponent from "SomeFormComponent"
import {selectedItemSelector, isEditingSelector} from "selectors/entities"
let mapStateToProps = (state) => {
@gaearon
gaearon / reducers.js
Last active December 11, 2020 14:56
How I'd do code splitting in Redux (pseudo code, not tested!)
import { combineReducers } from 'redux';
import users from './reducers/users';
import posts from './reducers/posts';
export default function createReducer(asyncReducers) {
return combineReducers({
users,
posts,
...asyncReducers
});
import { Module } from '../../core';
import AppContainer from './AppContainer.jsx';
const AppModule = new Module('App');
AppModule
.setInitialState({ counter: 0 })
// This will create Action Types (with normalized names) and Action Creators.
// The application container which is a wrapper around the redux store will
// compose all reducers of registered modules. The module name is used as key in the
@NotWoods
NotWoods / split.js
Last active December 1, 2022 04:10
Node.js - Break up a stream and reassemble it so that each line is a chunk.
const stream = require("stream");
/** Simplified version of split() on npm. */
const split = new stream.Transform({
/**
* @param {Buffer | string} chunk is the data from the Readable Stream.
* @param {string} encoding is the file encoding, but isn't used here.
* @param {() => void} next is a callback function called when you finish working
* with this chunk.
*/
@jrencz
jrencz / .eslintrc
Created April 12, 2016 12:05
Useful set of words for eslint-plugin-spellcheck
{
"plugins": [
"spellcheck"
],
"rules":
// Spellcheck
//
"spellcheck/spell-checker": ["warn", {
"skipWords": [
// own names
@markerikson
markerikson / redux-timer-middleware.js
Last active January 5, 2021 17:37
Sample Redux timer middleware
function timerMiddleware({dispatch, getState}) {
const timers = {};
return next => action => {
if(action.type == "START_TIMER") {
const {action, timerName, timerInterval} = action.payload;
clearInterval(timers[timerName]);
@chtenb
chtenb / archive_merged_branches.py
Last active May 25, 2019 21:33
Python script that lets you archive branches interactively
"""
Archive branches that are merged into master.
This is done by tagging them as archive/<branchname> and removing them both locally and
remotely. Before each operation, the user is asked for confirmation.
"""
# This dependency can be found on github: https://github.com/Chiel92/python-shellout
from shellout import get, out, confirm
# Tag merged branches
@tomkis
tomkis / redux-saga-confirmation-dialog.js
Last active March 14, 2019 15:02
Implementing confirmation dialog via redux-saga
import { select, put, take } from 'redux-saga/effects';
function* emptySaga() {}
export function* withConfirmation(text, onConfirm, onCancel = emptySaga) {
yield put({ type: 'ShowConfirmationDialog', payload: text });
const { type } = yield take([
'ConfirmationDialogConfirmed',
'ConfirmationDialogCanceled'
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active July 12, 2025 14:53
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@jouni-kantola
jouni-kantola / reasons-for-webpack-chunk-hash-updates.md
Last active May 9, 2021 10:08
Reasons for webpack chunk hash updates

Reasons for hash change

First build, for reference

       0.14ff9d89ef59e0542b1d.dev.js    1.55 kB    0, 7  [emitted]
       1.bcca8d49c0f671a4afb6.dev.js  708 bytes    1, 7  [emitted]
       2.6617d1b992b44b0996dc.dev.js  708 bytes    2, 7  [emitted]
       3.c8edca9c31923a566f7f.dev.js  403 bytes    3, 7  [emitted]
       4.c67fbd67a62782c31d1c.dev.js  403 bytes    4, 7  [emitted]
  vendor.3c35d30d5995c0e6e1c1.dev.js     259 kB    5, 7  [emitted]  [big]  vendor