putz u in dhe washing machin and spins ur bsky pofile pictuer !!! :D
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

write state

did:plc:73gqgbnvpx5syidcponjri… 4065f4fe cd4b8174

verified
+29
+1
.statefile
··· 1 + 353
+28
src/main.rs
··· 20 20 type AgentType = 21 21 Agent<CredentialSession<MemorySessionStore<SessionKey, AtpSession>, JacquardResolver>>; 22 22 23 + fn write_state(angle: f32) { 24 + const STATE_FILE: &str = ".statefile"; 25 + 26 + std::fs::write(STATE_FILE, angle.to_string()).unwrap_or_else(|e| { 27 + eprintln!("failed to write state file '{}': {}", STATE_FILE, e); 28 + // fine to not exit here like so what you'll do an extra upload who cares 29 + }); 30 + 31 + println!("wrote state file '{}'", STATE_FILE); 32 + } 33 + 34 + fn read_state() -> Option<f32> { 35 + const STATE_FILE: &str = ".statefile"; 36 + let contents = std::fs::read_to_string(STATE_FILE).ok()?; 37 + let angle: f32 = contents.trim().parse().ok()?; 38 + Some(angle) 39 + } 40 + 23 41 fn print_usage(executable: &str) { 24 42 eprintln!( 25 43 "usage: {} <input> <output> <app-password> <did/handle>", ··· 154 172 process::exit(1); 155 173 }); 156 174 175 + let previous_angle = read_state(); 176 + if let Some(prev) = previous_angle { 177 + let current_angle = compute_angle(); 178 + if (prev - current_angle).abs() < f32::EPSILON { 179 + println!("profile picture is already at {} degrees", current_angle); 180 + return; 181 + } 182 + } 183 + 157 184 let angle = compute_angle(); 158 185 let rotated = rotate_image(image, angle); 159 186 rotated.save(&output).unwrap_or_else(|e| { ··· 162 189 163 190 update_avatar(rotated, &agent, &mime_type).await; 164 191 192 + write_state(angle); 165 193 println!("rotated profile picture by {} degrees", angle); 166 194 }