Skip to content

Instantly share code, notes, and snippets.

View slonoed's full-sized avatar
🥔

Dmitry Manannikov slonoed

🥔
View GitHub Profile
package main
import (
"context"
"log"
"os"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
@slonoed
slonoed / unused.sh
Last active May 31, 2019 13:28
Find unused deps
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 09:53
ls_adb_2019_05_03
# 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 March 6, 2019 11:13
eslint rule to prevent await in expressions
/*
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 08:07
Fuzzy find and execute command from history
# 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 16:36
React component to handle client-server render inconsistency
/*
* 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 October 1, 2017 09:55
Tool to create domain with cert (nginx + letsencrypt)
#!/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 11:10
Simple log system
/* @flow */
/* eslint-disable no-console */
/*
* Логгер, создается в разных контекстах
* Имеет внутренний стейт, так как должнен быть создан и начать
* работать до запуска основных модулей
*
* Доступные уровни: ALL, WARN, ERROR, SILENT
*
@slonoed
slonoed / btc.sh
Created February 23, 2018 18:35
Create public key from private
#!/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 February 15, 2018 09:08
Simple memory cache
/*
* 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