Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Morev amorev

View GitHub Profile
@amorev
amorev / readme.md
Last active June 9, 2022 14:55
WSL add Windows host address to /etc/hosts
View readme.md

This small gist will add automaticaly wsl.host to hosts file and you will be able to communicate with your windows system, using wsl.host as address.

After creating your wsl do next:

  1. Place startup.sh at /startup.sh and run chmod +x /startup.sh
  2. Run visudo
  3. Add %sudo ALL=NOPASSWD: /startup.sh to end of file
  4. Add sudo /startup.sh at end of file /etc/profile

That's all. After first login in wsl after system start wsl.host will point to your windows host

@amorev
amorev / bash
Last active January 4, 2022 10:42
Telegram backup script
View bash
# создаем один tar.bz2 архив
backupDirectory=<backups_directory>
projectDirectory=<projects_directory>
chatId=<telegram_chat_id>
botToken=<telegram_bot_token>
cd $backupDirectory
tar -cvjf $backupDirectory/archive.full.tar.bz2 $projectDirectory
split -b 40M archive.full.tar.bz2 "archiver.tar.bz.part"
for i in `ls $backupDirectory | grep part`
View NotionTaskObject.ts
{
parent: {
database_id: taskDB
},
properties: {
Name: {
type: "title",
title: [
{
type: "text",
@amorev
amorev / convert.php
Last active May 24, 2021 04:25
Convert webp images to png for work in safari
View convert.php
<?php
// details - https://amorev.ru/safari-webp-problem/
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$fileInfo = explode('.', $entry);
$fileName = $fileInfo[0];
$fileExt = $fileInfo[1];
if ($fileExt === 'png') {
continue;
@amorev
amorev / bash
Last active December 13, 2020 08:42
Sending file via Telegram from terminal
View bash
#!/bin/sh
chatId=<YOUR_CHAT_ID>
botToken=<YOUR_BOT_TOKEN>
curdir=$PWD
echo sending $curdir/$1
curl -F chat_id=$chatId -F document=@$curdir/$1 https://api.telegram.org/bot$botToken/sendDocument
# more about gist on my site — amorev.ru/telegram-terminal-file-send
@amorev
amorev / bash
Last active October 17, 2019 12:33
Wget file from Google Drive
View bash
# Change FILE_ID to ID of File in google drive.
# Change FILE_NAME to File name, which you want to use for save file
FILE_ID=FILE_ID FILE_NAME=FILE_NAME wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=$FILE_ID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=$FILE_ID" -O $FILE_NAME && rm -rf /tmp/cookies.txt