Skip to content

Instantly share code, notes, and snippets.

View olecksamdr's full-sized avatar

Oleksandr olecksamdr

View GitHub Profile
@olecksamdr
olecksamdr / dump.sh
Last active August 27, 2020 11:01
Dump several collections from mongodb server
collections=( collectionName1 collectionName2 collectionName3 collectionName4 )
for c in ${collections[@]}
do
mongodump \
--uri "..." \
--collection=$c \
--out "$(pwd)/staging/$(date +"%m-%d-%y")"
done
@olecksamdr
olecksamdr / series.js
Created August 10, 2020 06:12
Run the functions in the tasks collection in series, each one running once the previous function has completed
/**
* series :: array -> Promise
*
* Run the functions in the tasks collection in series,
* each one running once the previous function has completed.
*/
const series = tasks =>
tasks.reduce(
(prevPromise, nextPromise) => prevPromise.then(nextPromise),
Promise.resolve()
/**
* runPromisesSync :: (array, function) -> Promise
*
* Runs a list of functions that return a Promise one by one
* promisesFactoryMap - a list of functions that return a promise
*/
const runPromisesSync = (promisesFactoryMap, onError = defaultOnError) =>
promisesFactoryMap.reduce(
(prevPromise, nextPromise) => prevPromise.then(nextPromise).catch(onError),
Promise.resolve()
const allIsTrue = R.curry((predicates, object) =>
Object.key(predicates).reduce((acc, key) => {
const predicate = predicates[key];
const predicateType = typeof predicate;
const value = object[key];
const valueType = typeof value;
if (predicateType === 'function') {
return predicate(value);
@olecksamdr
olecksamdr / python_virtual_env.md
Last active January 29, 2020 18:41
Create, Activate, Check, Deactivate Python Virtual Environments

Python virtual envirment

Create virtual envirment

python3 -m venv env

Activate vitual envirment

export const phoneFormatter = phone =>
phone ? phone.replace(/(\d{3})(\d{3})(\d{4})/, '($1) $2 - $3') : null;
mogrify -format jpg *.png
import styled from 'styled-components';
import { SORT_ORDERS } from './constants';
const { ASC, DESC } = SORT_ORDERS;
const SortIcon = styled.span`
margin-left: 0.5em;
height: 1em;
vertical-align: middle;
.text-truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* https://justmarkup.com/log/2015/07/dealing-with-long-words-in-css/ */
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
const withProps = input => WrappedComponent => props => (
<WrappedComponent {...props} {...input} />
);