Skip to content

Instantly share code, notes, and snippets.

use std::collections::HashMap;
use std::hash;
struct DisjointSet<T> {
elements: HashMap<T, usize>,
parents: HashMap<usize, usize>,
}
impl<T: Eq + hash::Hash> DisjointSet<T> {
pub fn new() -> Self {
@orez-
orez- / split_by.rs
Last active February 25, 2024 01:51
struct SplitBy<'a, T> {
slice: &'a [T],
value: T,
last_idx: usize,
}
impl<'a, T: PartialEq> Iterator for SplitBy<'a, T> {
type Item = &'a [T];
fn next(&mut self) -> Option<Self::Item> {
@alirobe
alirobe / reclaimWindows10.ps1
Last active July 3, 2024 09:36
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 16, 2024 13:44
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@glittershark
glittershark / tsvector_agg.sql
Created August 20, 2013 19:42
Postgresql aggregate function for tsvectors
CREATE OR REPLACE FUNCTION concat_tsvectors(tsv1 tsvector, tsv2 tsvector)
RETURNS tsvector AS $$
BEGIN
RETURN coalesce(tsv1, to_tsvector('default', ''))
|| coalesce(tsv2, to_tsvector('default', ''));
END;
$$ LANGUAGE plpgsql;
CREATE AGGREGATE tsvector_agg (
BASETYPE = tsvector,