Skip to content

Instantly share code, notes, and snippets.

View SnejUgal's full-sized avatar

Artem Starikov SnejUgal

View GitHub Profile
@SnejUgal
SnejUgal / main.rs
Created February 22, 2021 17:49
Recover a block from a glitchy thumb
use std::{
env::args,
fs::{remove_file, File, OpenOptions},
io::{prelude::*, SeekFrom},
thread::sleep,
time::Duration,
};
const BLOCK_SIZE: usize = 4 * 1024 * 1024;
const SECTOR_SIZE: usize = 512;
@SnejUgal
SnejUgal / main.rs
Last active February 22, 2021 17:21
Find the position of the last non-zero byte in a file
use std::io::{prelude::*, SeekFrom};
const CHUNK: usize = 512 * 1024 * 1024;
fn main() {
let path = std::env::args_os().nth(1).unwrap();
let mut file = std::fs::File::open(path).unwrap();
let mut position = file.seek(SeekFrom::End(-(CHUNK as i64))).unwrap();
@SnejUgal
SnejUgal / findAndReplace.js
Last active July 7, 2019 13:04
Find and replace for .attheme editor
const find = Color.parseHex("#607d8b");
const replace = Color.parseHex("#abcdef");
// ↑ Replace these colors. The alpha channel
// is ignored.
// Below starts the find and replace logic.
const variables = activeTheme.getVariables();
@SnejUgal
SnejUgal / main.rs
Last active January 22, 2019 14:40
Extract default wallpapers
// First you should prepare all themes with default wallpapers using
// tdesktop. Go to Settings -> Chat Settings -> Choose from gallery,
// choose a wallpaper, go back -> Launch theme editor -> ... -> Export
// theme -> Export, and name it `n.tdesktop-theme` where n is an
// inremeneted counter. Repeat for all wallpapers.
// Specify the last value of `n` here
const N: u8 = 1;
// Specify the channel where the wallpapers will be sent
const CHANNEL: &str = "@defaultwallpapers";