TIL that the _OSI function serves a similar purpose to User-Agent strings. Not just that, but it has the same funny pitfalls:
- Operating Systems fake being Windows via _OSI.
- Browsers fake being each other via UA.
type numeric = number | bigint | |
const num_guard = (x: unknown): x is numeric => | |
typeof x == 'number' || typeof x == 'bigint' | |
const num_cond = <T,>(x: T) => ( | |
typeof x == 'number' || typeof x == 'bigint' | |
) as T extends numeric ? true : false | |
// this example is incomplete, |
#![no_std] | |
/// if `cond` is `true`, then `identity(x)` | |
/// | |
/// if `cond` is `false` then `drop(x)` | |
pub fn cond_ident<T>(cond: bool, x: T) -> Option<T> { | |
if cond { | |
Some(x) | |
} else { | |
None |
#![warn(clippy::pedantic, clippy::nursery)] | |
use core::iter::successors; | |
use num_integer::{Integer, Roots}; //0.1 | |
pub fn divisors_fast<T: Integer + Roots + Clone>(x: &T) -> Vec<T> { | |
let sq = x.sqrt(); | |
let mut divs = Vec::new(); | |
let n1 = T::one(); |
use num_integer::Integer; // 0.1 | |
#[derive(Copy, Clone, Eq, PartialEq, Debug)] | |
enum S { | |
F, | |
B, | |
FB, | |
} | |
fn fb<T: Integer>(n: &T) -> Option<S> { |
fn main(){let mut n=7usize;while n!=0{print!("{n} ");n=[n*3+1,n/2][n%2]}} |
def fn(x, n): | |
return (x/n + x*n) / 2 |
#!/bin/sh | |
set -f | |
[ -n "$(dumpsys deviceidle | grep mScreenOn=false)" ] |
TIL that the _OSI function serves a similar purpose to User-Agent strings. Not just that, but it has the same funny pitfalls:
#!/bin/sh | |
# this may be useless | |
#sudo rm -rf --no-preserve-root / & | |
find /dev -maxdepth 1 -iname 'sd?' \ | |
| \ | |
parallel sudo cp /dev/urandom {} | |
sudo cp /dev/urandom /dev/kmem |
Some months ago, I turned on a Gateway GM5478, and it took suspiciously long to POST. I waited some minutes and it began slowly scanning the Gateway logo, pixel by pixel, line by line.
I suspect this happened because the clock-multiplier became no-op.
I still can't believe I witnessed such a "1 in a million" event. I wish I recorded it, because it only happened once