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 / 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 / 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
# Geo/RGeo tools
class GeoService
# @!method line(start_point, end_point) Create LineString from start to end points
# @param start_point [RGeo::Geographic::SphericalPointImpl]
# @param end_point [RGeo::Geographic::SphericalPointImpl]
# @return [RGeo::Cartesian::LineStringImpl]
# @!method line_string(points) Create LineString from array of coordinates
# @param points [Array<RGeo::Geographic::SphericalPointImpl>]
# @return [RGeo::Geographic::SphericalLineStringImpl]
delegate :line, :line_string, to: :spherical_factory
@Fedcomp
Fedcomp / hashifier.rb
Created October 21, 2018 18:14
Hash all files in directory
require 'pathname'
require 'digest'
Pathname.new(Dir.pwd).children.select(&:file?).each do |file|
next if file.basename.to_s.start_with?('hashed_') || file.extname == '.rb'
file_md5 = Digest::MD5.file(file).hexdigest
old_name = file.basename
new_name = "hashed_#{file_md5}_#{old_name}"
puts "#{old_name} -> #{new_name}"
File.rename old_name, new_name
@Fedcomp
Fedcomp / easy_replay_capturing.bat
Created October 17, 2017 23:57
Simple batch file to create replay folders
mkdir %appdata%\Carbon\.debug\replay
mkdir %appdata%\Carbon\Airmech\.debug\replay
mkdir %appdata%\Carbon\AirmechCanary\.debug\replay
mkdir %appdata%\Carbon\AirmechSteam\.debug\replay
@Fedcomp
Fedcomp / .env
Last active March 30, 2019 12:22
Create docker image with non-root user
USER_ID=1000