Skip to content

Instantly share code, notes, and snippets.

View Sh1Yo's full-sized avatar

Alexander Mironov Sh1Yo

View GitHub Profile
@Sh1Yo
Sh1Yo / buffer.py
Created August 8, 2021 06:56
The program saves a few lines and then prints them at once.
#usage: program | python3 buffer.py <amount of lines to buffer> | another_program
import sys
lines = []
try:
for line in sys.stdin:
lines.append(line)
if len(lines) >= int(sys.argv[1]):
@Sh1Yo
Sh1Yo / concurrence.rs
Created July 13, 2020 06:30
Rust concurrence example. Usage - cat concurrence.rs | ./concurrence
//dependecies
//futures = "0.3.5"
//async-std = "1.5.0"
use std::time::Duration;
use futures::executor::block_on;
use async_std::task;
use std::io::BufRead;
use std::io;
fn main() {
@Sh1Yo
Sh1Yo / threading.rs
Last active July 13, 2020 06:26
Rust threading example. Usage - cat threading.rs | ./threading
use std::io::BufRead;
use std::io;
use std::thread;
use std::time;
fn read_line() -> Option<String> {
match io::stdin().lock().lines().next()? {
Ok(val) => Some(val),
Err(_) => None,
}
@Sh1Yo
Sh1Yo / request_with_https.rs
Last active June 9, 2020 12:47
Rust raw requests via a proxy
//[dependencies]
//native-tls = "0.2.4"
use native_tls::TlsConnector;
use std::net::TcpStream;
use std::io::Write;
use std::io::Read;
fn main() {
let host = String::from("example.com");
let path = "/";
@Sh1Yo
Sh1Yo / parallel.py
Last active May 23, 2020 11:03
Get list of commands and run them in parallel.
import os, sys, time
from concurrent.futures import ThreadPoolExecutor
from threading import Thread
class WorkThread(Thread):
def __init__(self, data):
Thread.__init__(self)
self.data = data
def run(self):
os.system(self.data)
@Sh1Yo
Sh1Yo / 3proxy.zsh
Created March 28, 2020 17:46
Tor&3proxy
cd /tmp
print -P "%B%F{green} Creating 3proxy.cfg...%f%b"
echo "auth iponly" > 3proxy.cfg
echo "log 3proxy.log" >> 3proxy.cfg
echo "allow *" >> 3proxy.cfg
for i in {10000..10100}
do
echo "parent 10 http 127.0.0.1 $i" >> 3proxy.cfg
done
@Sh1Yo
Sh1Yo / telegram.py
Last active April 29, 2020 10:57
Telegram notifications
#!/usr/bin/python3
#Usage - "telegram {file}" or "telegram '{message}'"
import requests, sys
from requests.adapters import HTTPAdapter
from requests.exceptions import ConnectionError
group_id = ""
bot_token = ""
f = ""
try: