Skip to content

Instantly share code, notes, and snippets.

View amorev's full-sized avatar

Anton Morev amorev

View GitHub Profile
{
parent: {
database_id: taskDB
},
properties: {
Name: {
type: "title",
title: [
{
type: "text",
@amorev
amorev / bash
Last active August 31, 2023 08:44
Sending file via Telegram from terminal
#!/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 / convert.php
Last active May 24, 2021 04:25
Convert webp images to png for work in safari
<?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 / readme.md
Last active March 27, 2024 00:29
WSL add Windows host address to /etc/hosts

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 October 17, 2019 12:33
Wget file from Google Drive
# 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
@amorev
amorev / bash
Last active February 11, 2024 01:17
Telegram backup script
# создаем один 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`