Skip to content

Instantly share code, notes, and snippets.

View and-semakin's full-sized avatar

Andrey Semakin and-semakin

View GitHub Profile
@and-semakin
and-semakin / underscore.js
Created August 3, 2018 11:27
Underscore.js _.isEqual for Map objects
define(["_underscore"], function(_) {
"use strict";
// underscore.js monkey patches
// from 1.9.1
return (function() {
// All **ECMAScript 5** native function implementations that we hope to use
// are declared here.
var nativeKeys = Object.keys;
// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
@and-semakin
and-semakin / webpack.config.js
Created June 22, 2019 11:51
Less loader with prefixwrap & css-modules
prefixer = require('postcss-prefix-selector');
// ...
{
test: /.*\/some-vendor\/.*\.less$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
@and-semakin
and-semakin / FAIL1: logread
Created July 29, 2019 05:03
Автозапуск L2TP на OpenWRT срабатывает через раз
root@tp-link-home:~# logread
Mon Jul 29 09:40:05 2019 kern.notice kernel: [ 0.000000] Linux version 4.9.184 (buildbot@2ccc8102e0c3) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r7808-ef686b7292) ) #0 Thu Jun 27 12:18:52 2019
Mon Jul 29 09:40:05 2019 kern.debug kernel: [ 0.000000] MyLoader: sysp=7f15abbf, boardp=2eb6ad83, parts=7fb4e127
Mon Jul 29 09:40:05 2019 kern.info kernel: [ 0.000000] bootconsole [early0] enabled
Mon Jul 29 09:40:05 2019 kern.info kernel: [ 0.000000] CPU0 revision is: 00019750 (MIPS 74Kc)
Mon Jul 29 09:40:05 2019 kern.info kernel: [ 0.000000] SoC: Qualcomm Atheros QCA9558 ver 1 rev 0
Mon Jul 29 09:40:05 2019 kern.info kernel: [ 0.000000] Determined physical RAM map:
Mon Jul 29 09:40:05 2019 kern.info kernel: [ 0.000000] memory: 04000000 @ 00000000 (usable)
Mon Jul 29 09:40:05 2019 kern.info kernel: [ 0.000000] Initrd not found or empty - disabling initrd
Mon Jul 29 09:40:05 2019 kern.warn kernel: [ 0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 by
@and-semakin
and-semakin / .pre-commit
Last active August 8, 2019 14:43
pre-commit hook to check source formatting with black & isort
#!/usr/bin/env python3
import subprocess
import sys
def compose_up(service):
subprocess.run(["docker-compose", "up", "-d", service])
def compose_exec(service, command) -> bool:
2019-09-03 11:16:13,952 (23963/MainThread) pgcli.main WARNING - import keyring failed: ModuleNotFoundError("No module named 'keyring'").
2019-09-03 11:16:16,636 (23963/MainThread) pgcli.main ERROR - traceback: 'Traceback (most recent call last):\n File "/home/br0ke/.local/share/virtualenvs/pgcli_test-ns5XQy2A/lib/python3.7/site-packages/pgcli/main.py", line 555, in connect\n pgexecute = PGExecute(database, user, passwd, host, port, dsn, **kwargs)\n File "/home/br0ke/.local/share/virtualenvs/pgcli_test-ns5XQy2A/lib/python3.7/site-packages/pgcli/pgexecute.py", line 215, in __init__\n self.connect(database, user, password, host, port, dsn, **kwargs)\n File "/home/br0ke/.local/share/virtualenvs/pgcli_test-ns5XQy2A/lib/python3.7/site-packages/pgcli/pgexecute.py", line 255, in connect\n conn = psycopg2.connect(**conn_params)\n File "/home/br0ke/.local/share/virtualenvs/pgcli_test-ns5XQy2A/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect\n conn = _connect(dsn, connection_factor
@and-semakin
and-semakin / PostgreSQL logs
Last active September 27, 2019 11:11
osm2pgsql problem
CONTEXT: COPY planet_osm_point, line 1
STATEMENT: COPY planet_osm_point (osm_id,"access","addr:housename","addr:housenumber","addr:interpolation","admin_level","aerialway","aeroway","amenity","area","barrier","bicycle","brand","bridge","boundary","building","capital","construction","covered","culvert","cutting","denomination","disused","ele","embankment","foot","generator:source","harbour","highway","historic","horse","intermittent","junction","landuse","layer","leisure","lock","man_made","military","motorcar","name","natural","office","oneway","operator","place","population","power","power_source","public_transport","railway","ref","religion","route","service","shop","sport","surface","toll","tourism","tower:type","tunnel","water","waterway","wetland","width","wood","z_order",tags,way) FROM STDIN
ERROR: unexpected message type 0x58 during COPY from stdin
CONTEXT: COPY planet_osm_line, line 1
STATEMENT: COPY planet_osm_line (osm_id,"access","addr:housename","addr:housenumber","addr:interpolation","admin_
@and-semakin
and-semakin / tox-asdf tox output
Created November 21, 2019 07:31
tox-asdf tox output
$ tox
GLOB sdist-make: /home/br0ke/git/tox-asdf/setup.py
py27 create: /home/br0ke/git/tox-asdf/.tox/py27
py27 installdeps: mock, pytest, pytest-mock, tox
py27 inst: /home/br0ke/git/tox-asdf/.tox/.tmp/package/1/tox-asdf-0.1.1.dev0.zip
py27 installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,atomicwrites==1.3.0,attrs==19.3.0,configparser==4.0.2,contextlib2==0.6.0.post1,filelock==3.0.12,funcsigs==1.0.2,importlib-metadata==0.23,mock==3.0.5,more-itertools==5.0.0,packaging==19.2,pathlib2==2.3.5,pluggy==0.13.0,py==1.8.0,pyparsing==2.4.5,pytest==4.6.6,pytest-mock==1.12.1,scandir==1.10.0,six==1.13.0,toml==0.10.0,tox==3.14.1,tox-asdf==0.1.1.dev0,virtualenv==16.7.7,wcwidth==0.1.7,zipp==0.6.0
py27 run-test-pre: PYTHONHASHSEED='3137834157'
py27 run-test: commands[0] | pytest
===============================================================================
@and-semakin
and-semakin / 5c2b70c3275376a95d8ce9fe39756f01871ea81b
Created December 1, 2019 11:27
MyTetra experimental cppcheck report
~/g/mytetra_dev (experimental|✔) $ cppcheck --quiet --enable=all app
[app/src/controllers/attachTable/AttachTableController.cpp:404]: (style) Variable 'fromFileName' is assigned a value that is never used.
[app/src/controllers/recordTable/RecordTableController.cpp:794]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[app/src/controllers/shortcutSettings/ShortcutSettingsController.cpp:7]: (warning) Member variable 'ShortcutSettingsController::view' is not initialized in the constructor.
[app/src/controllers/shortcutSettings/ShortcutSettingsController.cpp:7]: (warning) Member variable 'ShortcutSettingsController::model' is not initialized in the constructor.
[app/src/libraries/DiskHelper.cpp:156] -> [app/src/libraries/DiskHelper.cpp:157]: (style) Condition 'result' is always false
[app/src/libraries/Downloader.cpp:24]: (performance) Variable 'saveDirectory' is assigned in constructor body. Consider performing initialization in initialization list.
[app/src/libraries/GlobalParameters.cpp:26
@and-semakin
and-semakin / fish_prompt.fish
Created December 3, 2019 14:51
My favorite Fish prompt
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
end
@and-semakin
and-semakin / README.md
Last active November 26, 2022 02:02
Awesome weather script

Скрипт, показывающий погоду

Для запуска нужно иметь Python 3.6+ и установленные зависимости:

pip install -r requirements.txt

Ещё для запуска нужен API-ключ к сервису OpenWeatherMap. Смотрите инструкцию в файле weather.py.