Skip to content

Instantly share code, notes, and snippets.

View konarev's full-sized avatar

Alexander Konarev konarev

  • Krasnodar, Russia
  • 07:54 (UTC +03:00)
View GitHub Profile
from itertools import count
N = 5
i = count(1)
numbers = {}
row = start_row = 1
colon = start_col = 1
for size in range(N, 0, -1):
for colon in range(start_col, size + 1):
@konarev
konarev / msys2-visual-studio-code.md
Created April 6, 2021 15:48 — forked from dhkatz/msys2-visual-studio-code.md
Using MSYS2 with Visual Studio Code

Using MSYS2 with Visual Studio Code is extremely easy now thanks to the Shell Launcher extension by Tyriar.

First, install the extension and reload Visual Studio Code.

Then, open the settings.json to edit your settings.

Add the field shellLauncher.shells.windows. I recommend using autocompletion here so that all the default shells are added.

You should having something like this now:

@konarev
konarev / vscode-debug.md
Last active April 4, 2021 06:58
VSCode debug
@konarev
konarev / gist:d82e63a43d5271f73d885f9e3e2bd4b4
Created April 1, 2021 07:38
VSCode windows terminal UTF-8
I have resolved this problem by setting terminal.integrated.env.windows
Here is the setting:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.integrated.env.windows": {
"LANG": "C.UTF-8"
}
https://stackoverflow.com/a/30071634
Download MSYS2 from this page (choose 32 or 64-bit according to what version of Windows you are going to use it on, not what kind of executables you want to build, both versions can build both 32 and 64-bit binaries).
After the install completes, click on the newly created "MSYS2 Shell" option under either MSYS2 64-bit or MSYS2 32-bit in the Start menu. Update MSYS2 according to the wiki (although I just do a pacman -Syu, ignore all errors and close the window and open a new one, this is not recommended and you should do what the wiki page says).
Install a toolchain
a) for 32-bit:
pacman -S mingw-w64-i686-gcc
b) for 64-bit:
pacman -S mingw-w64-x86_64-gcc

Исходные данные: роутер имеет адрес 192.168.1.1, tor и i2pd подняты на 192.168.1.10 (если роутер достаточно мощный, можно поднять их прямо на нём, соответственно скорректировав адреса)

В LEDE для загрузки списка заблокированных доменов проще всего использовать поставляемую по умолчанию утилиту uclient-fetch. Необходимо лишь добавить ей поддержку SSL:

opkg update
opkg install libustream-mbedtls

Впрочем, вы можете использовать wget или curl, если предпочитаете. Особенности wget см. ниже.

@konarev
konarev / gist:deef14c43e8449b1ffca05a08f7ec9e6
Last active June 2, 2020 08:19
OpenWrt: Точечный обход блокировок
https://habr.com/ru/post/317354/#comment_9958456
Выгрузка ip адресов с rublacklist, должен выполняться по крону каждые n-минут/часов/дней:
#!/bin/sh
TARGET_SET=vpn-whitelist
TARGET_TMP=vpn-whitelist-tmp
ipset destroy -q ${TARGET_TMP} || true
ipset create -q ${TARGET_SET} hash:ip || true
ipset create ${TARGET_TMP} hash:ip
@konarev
konarev / WSL-ssh-server.md
Created January 6, 2020 20:15 — forked from dentechy/WSL-ssh-server.md
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on:

Google Drive Sync Wine Scripting

This is a set of scripts that help running Google Drive Backup and Sync under Wine, with multiple Google accounts.

Each account is given its own Wine prefix (a separate wine configuration).

To install, run install-gdrive-sync google_account

List the accounts set up in ~/.config/gdrive-accounts

@konarev
konarev / docker-cleanup-resources.md
Created February 21, 2018 14:15 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm