Skip to content

Instantly share code, notes, and snippets.

Avatar
🇺🇸
Procrastinating

Techcable

🇺🇸
Procrastinating
View GitHub Profile
@Techcable
Techcable / ignore.txt
Created Jan 14, 2021
Utilities to print files that would be good to backup (in /etc /var /opt) - Automatically ignores files owned by pacman. Remember to check modification with `pacman -Qii | grep -P '^(?:UN)?MODIFIED'` and `paccheck --sha256sum`
View ignore.txt
/etc/.pwd.lock
/etc/.updated
/etc/adjtime
/etc/ca-certificates/
/etc/dhcpcd.duid
/etc/group
/etc/group.pacnew
/etc/gshadow-
/etc/ld.so.cache
/etc/locale.gen.pacnew
@Techcable
Techcable / README.md
Last active Jan 18, 2021
Backup a set of SMS backup files from Android's "SMS Backup and Restore"
View README.md

SMS Backups

Sms Backups (for the paranoid) using Andorid's "SMS Backup and Restore"

  1. Install "SMS Backup and Restore" to backup periodically
    • Configure backups to a cloud provider like "Google Drive"
    • Ideally backup phone clals as well
  2. Wait until the Cloud Provider runs low on storage
    • This should happen relatively quickly, since my SMS files take 300+ MB each (they include photo/videos)
  3. Download the backup folder
@Techcable
Techcable / opt.rs
Created Jul 11, 2020
Safety of nbody power optimization (f**-1.5) == 1/(sqrt(f) * f) [Always within 1 ULP?]
View opt.rs
extern crate rand; // 0.7.3
use rand::prelude::*;
use rand::distributions::Uniform;
fn clear(f: f64) -> f64 {
f.powf(-1.5)
}
fn fast(f: f64) -> f64 {
@Techcable
Techcable / ulps.rs
Created Jul 11, 2020
Floating Point Raw ULP comparison
View ulps.rs
//! Taken from Stack overflow: ttps://stackoverflow.com/a/17871376/5713037
fn diff_ulps(a: f64, b: f64) -> u64 {
(raw_ulps(a) as i64).wrapping_sub(raw_ulps(b) as i64).abs() as u64
}
fn raw_ulps(f: f64) -> u64 {
assert!(!f.is_nan());
let b: u64 = f.to_bits();
const TOP: u64 = 0x8000_0000_0000_0000;
@Techcable
Techcable / eulers_method.py
Created Sep 13, 2018
Euler's Method for solving Differential Equations
View eulers_method.py
def parse_location(s: str):
if s.startswith("(") and s.endswith(")"):
parts = s[1:-1].split(',')
if len(parts) == 2:
try:
return tuple(map(int, parts))
except ValueError:
pass
raise ValueError(f"Invalid location: {s!r}")
@Techcable
Techcable / strsim.js
Last active May 7, 2019
Javascript Damerau Levenshtein Similarity metrics
View strsim.js
function damerau_levenshtein(first, second) {
"use strict";
// TODO: Support non-BMP characters (like that's ever going to happen)
if (first == second) return 0;
var firstLen = first.length;
var secondLen = second.length;
if (firstLen == 0) return secondLen;
if (secondLen == 0) return firstLen;
View 21x named format arguments.txt
note: trace_macro
--> src/tests.rs:251:5
|
251 | error!(log, "at {name:?} {sym:#}", name = ip, sym = demangled);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: expanding `error! { log , "at {name:?} {sym:#}" , name = ip , sym = demangled }`
= note: to `log ! (
log , $crate :: Level :: Error , "" , "at {name:?} {sym:#}" , name = ip , sym
= demangled )`
@Techcable
Techcable / euler53.py
Created Aug 4, 2017
Euler #53 Combinatoric selections
View euler53.py
from math import factorial
def numCombinations(n, r):
return factorial(n) // (factorial(r) * factorial(n - r))
def numCombinationsBiggerThan(n, target):
amount = 0
for r in range(1, n + 1):
if numCombinations(n, r) > target:
amount += 1
@Techcable
Techcable / euler52.rs
Created Aug 4, 2017
Euler #52 Permuted multiples Rust
View euler52.rs
use std::cmp::max;
fn digitsOf(mut value: usize, buffer: &mut Vec<u8>) {
buffer.clear();
if value > 0 {
while value > 0 {
buffer.push((value % 10) as u8);
value /= 10;
}
buffer.reverse();
@Techcable
Techcable / euler51.py
Created Jul 24, 2017
Euler #51 Prime Digit Replacements (Spoiler)
View euler51.py
from math import log10, ceil, sqrt
import numpy as np
from itertools import combinations
import operator
import array
def basicNumpySieve(bound):
isPrime = np.ones((bound), dtype=np.bool)
for i in range(2, ceil(sqrt(bound)) + 1):
if isPrime[i]:
You can’t perform that action at this time.