Skip to content

Instantly share code, notes, and snippets.

View chodorowicz's full-sized avatar

Jakub Chodorowicz chodorowicz

View GitHub Profile
// using airbnb-base
// need to change sourceType to script
{
"extends": "airbnb-base",
"env": {
"node": true
},
parserOptions: {
ecmaVersion: 7,
@chodorowicz
chodorowicz / .editorconfig
Last active March 25, 2017 09:10
web dev dotfiles, config files
root = true
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
@chodorowicz
chodorowicz / middleware.js
Last active July 18, 2016 10:43
redux middlewares
/**
* bare middleare
*/
export default function({ dispatch }) {
return next => action => {
console.log(action);
// send this action to next middleware or reducers if that's the last middleware
next(action);
}
@chodorowicz
chodorowicz / hoc.js
Last active July 18, 2018 16:26
React HOC example
/** base form */
import React, { Component } from 'react';
export default function(InnerComponent) {
class WrapperComponent extends Component {
render() {
return <InnerComponent {...this.props} />
}
}
}
@chodorowicz
chodorowicz / saga.js
Last active July 13, 2016 14:40
redux saga
/**
* shortcut for fork (no need to define separate watch functions
* https://yelouafi.github.io/redux-saga/docs/basics/UsingSagaHelpers.html
*/
import { takeLatest } from 'redux-saga'
import { fork } from 'redux-saga/effects'
function* fetchUsers(action) { }
function* createUser(action) { }
@chodorowicz
chodorowicz / find.sh
Last active December 20, 2016 15:16
find shell tool
# find files in several folders
find foo bar baz -name "*.py"
# find
find . -name "__tests__"
# used with Mocha → find spec files in app and test folders
mocha $(find test app -path *.spec.js)
# find recursivelly all symlinks
@chodorowicz
chodorowicz / mastemind.sh
Created July 11, 2016 22:54
mitmproxy and mastermind
# simple mode with ignore all but specific domains
sudo mastermind --response-body $(pwd)/fake.json --url https://api.github.com/users/octocat/orgs --ignore '^(?!example\.com)(?!mitmproxy\.org)'
@chodorowicz
chodorowicz / setup.sh
Last active August 4, 2016 14:23
running Selenium test on CI server (SemaphoreCI)
# run your usual build scripts e.g.
# npm install
# npm run build
# download selenium standalone jar
wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar
# run selenium using xvfb
# set web driver path
# get path to chrome.driver ➡️ which chromedriver
@chodorowicz
chodorowicz / asci.txt
Created July 5, 2016 15:12
ascii animals
|\__/| __
/ ö ö \| |
\ -- /
/ 千 /
| | 万 |
| | 両 \_______
\__|___|________|_\
@chodorowicz
chodorowicz / toggle.js
Last active February 15, 2021 21:23
lodash toggle array element
/**
* descructive
* https://github.com/lodash/lodash/issues/1677
*/
function toggle(collection, item) {
var idx = _.indexOf(collection, item);
if(idx !== -1) {
collection.splice(idx, 1);
} else {
collection.push(item);