Skip to content

Instantly share code, notes, and snippets.

View bssth's full-sized avatar
:accessibility:
Exist

Borys S. bssth

:accessibility:
Exist
  • VortalCoil
  • Ukraine
View GitHub Profile
@bssth
bssth / grep-and-download.php
Created September 11, 2023 01:53
Grep URLs and download files from any file
<?php
$files = glob('*.txt');
$offset = '';
$pattern = '/https.+\.jpg/';
$save_file_suffix = '.jpg';
$save_in_folder = 'img/';
foreach ($files as $f) {
$content = file_get_contents($f);
preg_match_all($pattern, $content, $match);
@bssth
bssth / massive-mailing.ts
Last active May 14, 2024 03:31
Send message to an array of users
// $ yarn install node-telegram-bot-api
import TelegramBot from 'node-telegram-bot-api';
// Use yours
const token = '1234567:ABCDEFGH';
const bot = new TelegramBot(token);
// Use your own list
@bssth
bssth / backup.sh
Created August 18, 2022 01:04
Not short command to fast backup anything and send via Telegram
tar czf - /home/USER > /root/backup.tar.gz && \
gpg --output /root/backup.gpg --encrypt --recipient USER@domain.com --always-trust /root/backup.tar.gz && \
curl -F document=@"/root/backup.gpg" https://api.telegram.org/botTOKEN/sendDocument?chat_id=12345678
&& \
rm /root/backup.gpg /root/backup.tar.gz
@bssth
bssth / leave-me-alone.mjs
Created May 1, 2022 16:31
Clear all subscribers in VK.com
let list = (await vk.api.friends.getRequests({'need_viewed': 1, 'count': 1000}))?.items;
if(!list?.length) {
return;
}
console.log('Banning...');
for (let k in list) {
const id = list[k];
try {
const response = await vk.api.account.ban({
@bssth
bssth / no-friends.mjs
Created May 1, 2022 15:33
Delete all friends on VK.com without leaving as subscribers
let list = [
1, 100, 333
];
console.log('Banning...');
for (let id of list) {
const response = await vk.api.account.ban({
owner_id: id
});
@bssth
bssth / clean.py
Created January 1, 2022 20:40
Clean Telegram chat until date
import asyncio
import datetime
from pytz import utc
from telethon import TelegramClient
from telethon.tl.types import PeerUser
DELETE_BEFORE = utc.localize(datetime.datetime(2021, 10, 1)) # offset date
API_ID = 12345 # https://my.telegram.org/apps
API_HASH = 'qwerty123' # https://my.telegram.org/apps
@bssth
bssth / jira-event-struct.go
Created December 19, 2021 10:15
Generated Jira event structs
type IssueEvent struct {
Timestamp int64 `json:"timestamp"`
WebhookEvent string `json:"webhookEvent"`
IssueEventTypeName string `json:"issue_event_type_name"`
User User `json:"user"`
Issue Issue `json:"issue"`
Log ChangeLog `json:"changelog"`
}
type Issue struct {
@bssth
bssth / ucfirst.go
Created December 19, 2021 08:22
Upper-case for first letter in word (same as PHP mb_ucfirst)
func UpperCaseFirst(str string) string {
if len(str) >= 1 {
var newStr string
var first rune
for i, c := range str {
if i == 0 {
first = c
first = unicode.ToUpper(first)
newStr = string(first)
} else {
@bssth
bssth / procman.go
Created November 20, 2021 17:37
Simple process manager (run any executable in background with auto-restart)
package main
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
@bssth
bssth / go.Dockerfile
Last active December 19, 2021 08:21
Golang Simple Dockerfile
FROM golang:1.16
WORKDIR /
COPY . /
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app/
COPY --from=0 ./app ./
CMD ["./app"]