Skip to content

Instantly share code, notes, and snippets.

Avatar
🥔

Dmitry Manannikov slonoed

🥔
View GitHub Profile
@slonoed
slonoed / unused.sh
Last active May 31, 2019
Find unused deps
View unused.sh
FILES=$(cat package.json | jq -r '.dependencies * .devDependencies | keys | join("\n")')
ARR=', ' read -r -a array <<< $FILES
echo Not found deps
echo
for dep in "${array[@]}"
do
grep -qr "$dep" src
@slonoed
slonoed / rules
Last active May 5, 2019
ls_adb_2019_05_03
View rules
# Blocklist for use with Little Snitch
#
# For more information about this list, see: https://pgl.yoyo.org/adservers/
# ----
# last updated: Fri, 03 May 2019 16:04:09 GMT
# entries: 2964
# format: littlesnitch (littlesnitch -- for use with Little Snitch)
# credits: Peter Lowe - pgl@yoyo.org - https://pgl.yoyo.org/ - https://twitter.com/pgl
# this URL: http://pgl.yoyo.org/adservers/serverlist.php?hostformat=littlesnitch;showintro=0
# Patreon: https://patreon.com/blocklist
@slonoed
slonoed / eslint-local-rules.js
Created Mar 6, 2019
eslint rule to prevent await in expressions
View eslint-local-rules.js
/*
Should be used with "eslint-plugin-local-rules" plugin
*/
'use strict'
module.exports = {
'no-await-in-expressions': {
meta: {
type: 'problem',
@slonoed
slonoed / fuzzy_history.sh
Created May 26, 2018
Fuzzy find and execute command from history
View fuzzy_history.sh
# Fuzzy history
hist() {
local cmd
cmd=$(history | sed -E 's/[0-9]+\ \ //g' | sort -u | grep '^[^\ ]' | fzf --no-multi) &&
echo "\$ $cmd" &&
command $cmd
}
@slonoed
slonoed / ClientRender.js
Created May 16, 2018
React component to handle client-server render inconsistency
View ClientRender.js
/*
* ClientRender helps to avoid server-client render inconsistency.
*
* I.E. client render depends on data from LocalStorage
*
* Usage:
*
* r(ClientRender, {server: 'Rendered on server'}, 'Rendered on client')
*/
import {Component} from 'react'
@slonoed
slonoed / domain.sh
Created Oct 1, 2017
Tool to create domain with cert (nginx + letsencrypt)
View domain.sh
#!/bin/sh
# Tool to create domain with cert
# ./domain.sh test.example.com 1234
# where 1234 - upstream port
# Input params
DOMAIN=$1
UPSTREAM_PORT=$2
@slonoed
slonoed / log.js
Created May 22, 2017
Simple log system
View log.js
/* @flow */
/* eslint-disable no-console */
/*
* Логгер, создается в разных контекстах
* Имеет внутренний стейт, так как должнен быть создан и начать
* работать до запуска основных модулей
*
* Доступные уровни: ALL, WARN, ERROR, SILENT
*
@slonoed
slonoed / btc.sh
Created Feb 23, 2018
Create public key from private
View btc.sh
#!/bin/bash
# Various bash bitcoin tools
#
# requires dc, the unix desktop calculator (which should be included in the
# 'bc' package)
#
# This script requires bash version 4 or above.
#
# This script uses GNU tools. It is therefore not guaranted to work on a POSIX
# system.
@slonoed
slonoed / cache.js
Last active Feb 15, 2018
Simple memory cache
View cache.js
/*
* Simple implementation of memory cache
*
* Is use async API in case we replace it with redis.
*
* Keys should be symbols.
*/
const DEFAULT_TTL = 5 * 60 * 1000
const CLEAN_INTERVAL = DEFAULT_TTL * 1.5
@slonoed
slonoed / withPropsChanged.js
Created Oct 18, 2017
HOC call callback when props changed
View withPropsChanged.js
const withPropsChanged = (arePropsChagned, callback) => BaseComponent => {
const factory = React.createFactory(BaseComponent)
return class Watcher extends React.Component {
componentWillReceiveProps(nextProps) {
if (arePropsChagned(this.props, nextProps)) {
callback(nextProps)
}
}
render() {
return factory(this.props)