Skip to content

Instantly share code, notes, and snippets.

View PsychedelicShayna's full-sized avatar
🐇
Writing Code & Contemplating Existence

Shayna PsychedelicShayna

🐇
Writing Code & Contemplating Existence
View GitHub Profile
@PsychedelicShayna
PsychedelicShayna / md5.rs
Last active May 10, 2024 03:18
A condensed, 358 line MD5 implementation for Rust, easy to copy paste into other projects.
pub mod md5 {
use std::convert::TryInto;
use std::fmt::Display;
use std::{fs::File, io::Read};
pub const BLOCK_LENGTH: usize = 64;
pub const DIGEST_LENGTH: usize = 16;
#[rustfmt::skip]
pub const INITIAL_STATE: [u32; 4] = [
@PsychedelicShayna
PsychedelicShayna / extract.rs
Last active January 5, 2024 23:46
Basically, for when Regex is overkill and you just want to extract substrings between deterministic start and end patterns. This Rust function will find every occurrence of a matching start/end pattern and return the contents in between.
pub fn extract(input: &str, pattern_start: &str, pattern_end: &str) -> Vec<String> {
let mut matches = Vec::new();
let mut position = 0;
while let Some(match_index) = input[position..].find(pattern_start) {
let start_index = position + match_index;
position = start_index + pattern_start.len();
if let Some(match_index) = input[position..].find(pattern_end) {
let end_index = position + match_index;
@PsychedelicShayna
PsychedelicShayna / hashmap_macro.rs
Last active January 4, 2024 19:06
A versatile map! macro I came up with as an analogue to vec! but for HashMaps, with added powers for quality of life in Rust.
use std::collections::HashMap;
#[macro_export]
macro_rules! map (
// -----------------------------------------------------------------------
// Inferred types, no bindings.
{$($key:expr => $value:expr;)+} => {
vec![
$(
($key, $value),
@PsychedelicShayna
PsychedelicShayna / zero_rand_decimal_places.py
Created December 16, 2023 23:41
Generates a random floating point zero, with N decimal places randomized between a lower (L) and upper (U) bound.
def zero_rand_places(n: int = 5, l: int = 4, u: int = 5) -> float:
'''
Generates a random floating point zero, with n decimal places between
0.1 and 0.9, with l and u clamping the lower and upper bounds of the
number, e.g. with l = 4, u = 5, n = 3: 0.400 <= R <= 0.599
'''
lb: int = 0.1 * 10**n
ub: int = 0.1 * 10 ** (n + 1) - 1
@PsychedelicShayna
PsychedelicShayna / repetition.reg
Created September 7, 2023 13:54
A backup of my preferences and a reference for others; overriding key repeat speeds on Windows to be speedier, especially with Vim.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response]
"AutoRepeatDelay"="250"
"AutoRepeatRate"="6"
"BounceTime"="0"
"DelayBeforeAcceptance"="0"
"Flags"="59"
"Last BounceKey Setting"=dword:00000000
"Last Valid Delay"=dword:00000000
@PsychedelicShayna
PsychedelicShayna / beewarez.md
Created September 2, 2023 03:41
To those whose eyes are attracted by litttle know secret; how does the piracy scene operate?

Disclaimer : Don't expect that when you walk away from reading this post that you will be magically transformed into the scene as one of their l33t members - it aint gonna happen. This post will hopefully give you an idea of how the scene operates, and this knowledge MAY aid you in your endeavours to get in. You are also hereby instructed not to send me PM's asking me if I have any leads for you.

The Scene - it's an amazingly large underground network of pirates, and it's a very secritive society. The Scene hates P2P (which includes Torrents), primarily because we give away all their stuff, even though it's ironic that it's not actually theirs to begin with. The scene operates simplisticly as follows.

A supplier (somebody who has access to stuff, eg people at DVD store or publishing house) provides a group with source media. This group then rips the media and converts it to scene standards. If it is software, and the group specialises in cracking software, then they write a keygen or crack for it. Sc

@rhaberkorn
rhaberkorn / aes.apl
Last active November 11, 2023 14:07
AES in GNU APL
⍝ Left rotate ⍺ bit
Rot8 ← {2⊥⍺⌽(8⍴2)⊤⍵}
⍝ Addition and subtraction in finite field GF(2)
Add2 ← {⍺ ⊤≠ ⍵}
⍝ Multiplication in GF(2) [x]/(x8 + x4 + x3 + x + 1)
Mul2 ← {⊤≠/({⍵,$FF ⊤∧ ($11B×$80≤¯1↑⍵) ⊤≠ 2ׯ1↑⍵}⍣7 ⍺) × ⌽(8⍴2)⊤⍵}
⍝ Multiplicative inverse, calculated by brute force
Mul2Inv ← {$FF ⊤∧ 1⍳⍨⍵ Mul2¨⍳255}
SBox ← {⊤≠/$63,(1-⍨⍳5) Rot8¨Mul2Inv ⍵}¨1-⍨⍳256
@PsychedelicShayna
PsychedelicShayna / sto_first_person_perspective.md
Last active February 24, 2024 14:12
A way to simulate a first person perspective within the MMO, Star Trek Online.

Star Trek Online - Simulate First Person Perspective

By binding this command to a key, and pressing it while leaning the camera right up against a wall, such that the camera slides down to where your head should be, and then activating it, the camera will be frozen in that position, allowing you to continue walking around with the camera in that positoin.

/bind L "cam_distance_interp_speed 0" 

This can then be combined with this command in order to adjust your FOV to your liking, since it can look a bit off at first. Try experimenting with the FOV, find out what's best for you; 70 is a good starting point.

/setregionfov ground 70
@PsychedelicShayna
PsychedelicShayna / github-flavored-markdown.css
Created July 15, 2023 00:11
The CSS used to stylize markdown the way GitHub does it.
@media (prefers-color-scheme: dark) {
.markdown-body {
color-scheme: dark;
--color-prettylights-syntax-comment: #8b949e;
--color-prettylights-syntax-constant: #79c0ff;
--color-prettylights-syntax-entity: #d2a8ff;
--color-prettylights-syntax-storage-modifier-import: #c9d1d9;
--color-prettylights-syntax-entity-tag: #7ee787;
--color-prettylights-syntax-keyword: #ff7b72;
--color-prettylights-syntax-string: #a5d6ff;
@PsychedelicShayna
PsychedelicShayna / gfm-render
Created July 15, 2023 00:08 — forked from bitti/gfm-render
Offline renderer for GitHub flavoured markdown
#!/usr/bin/ruby
require 'redcarpet'
require 'erb'
input = ARGV[0] && ARGV[0] != "-" && File.open(ARGV[0]) || STDIN
output = ARGV[1] && File.open(ARGV[1], "w") || STDOUT
File.join(ENV["XDG_CACHE_HOME"] || "#{ENV['HOME']}/.cache", "gfm-render")
class RenderWithTaskLists < Redcarpet::Render::HTML