Skip to content

Instantly share code, notes, and snippets.

@Fedcomp
Fedcomp / script.js
Last active March 25, 2024 13:41
Example of mass deletion of telegram join messages in telegram web (https://web.telegram.org/a/)
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
const contextMenuClick = (element) => element.dispatchEvent(new MouseEvent('contextmenu', {
bubbles: true,
cancelable: true,
view: window,
}))
const messages = () => [...document.querySelectorAll('[id^=message].ActionMessage')]
.filter(e => e.textContent.includes(' joined the group'));
const deleteMessage = async (e) => {
@Fedcomp
Fedcomp / git-filter-repo.sh
Last active November 26, 2023 14:12
git filter-repo example (saved for myself, use at your own risk)
git filter-repo --force --replace-refs delete-no-add --commit-callback '
if commit.author_email == b"old_email@domain":
commit.author_email = b"new_private_email@domain"
commit.author_name = b"username"
commit.committer_email = b"new_private_email@domain"
commit.committer_name = b"username"
'
@Fedcomp
Fedcomp / generator.php
Created October 24, 2016 13:22
IPV6 generator
<?php
$filename = "ip.list";
$prefix = "2a04:5200:8";
function generate_ipv6($prefix){
function generate_ipv6_block() {
$seed = str_split('1234567890abcdef');
shuffle($seed);
$block = join("", $seed); // Symbol array to string
$block = substr($block, 0, 4);
@Fedcomp
Fedcomp / Gemfile
Created December 20, 2015 09:50
Rails taps working configuration Mysql -> Postgresql (Ubuntu 14.04/15.10) (20.12.2015)
source "https://rubygems.org"
gem 'taps', git: 'git://github.com/eric1234/taps.git', branch: 'patch-1'
gem 'mysql2'
gem 'sqlite3'
gem 'pg'
gem 'rack','1.0.1'
@Fedcomp
Fedcomp / data.json
Last active April 30, 2021 10:49
Array comparison in php, javascript, and ruby
[
{ "name": "leroy", "kills": 25, "banned": false },
{ "name": "jenkins", "kills": 30, "banned": false },
{ "name": "cheater", "kills": 999, "banned": true },
{ "name": "n00b", "kills": 0, "banned": false }
]
@Fedcomp
Fedcomp / Cargo.toml
Created June 27, 2020 05:23
tokio-tungstenite simple https example
[package]
name = "tungstenite-example"
version = "0.0.1"
authors = ["Fedcomp"]
edition = "2018"
[dependencies]
tokio-tungstenite = { version = "0.10.1", features = ["tls"] }
tokio = { version = "0.2.21", features = ["full"] }
futures = "0.3.5"
@Fedcomp
Fedcomp / get_web_page.php
Last active April 8, 2019 01:33
Example remote page download with php-curl.
<?php
function get_web_page( $url ){
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
@Fedcomp
Fedcomp / .env
Last active March 30, 2019 12:22
Create docker image with non-root user
USER_ID=1000
@Fedcomp
Fedcomp / Gemfile
Created March 25, 2019 20:08
age difference
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem 'rails', '~> 5.0'
gem 'pry-byebug'
@Fedcomp
Fedcomp / description.txt
Last active March 25, 2019 20:04
Rails timestamptz migration
docker-compose --run --rm ruby test.rb