Forgot why I needed this, but isn't it a beauty :)
git whatchanged --since '2022-03-01' --oneline | grep "whatever_..." | uniq | sort
(Most likely largely via StackOverflow)
Forgot why I needed this, but isn't it a beauty :)
git whatchanged --since '2022-03-01' --oneline | grep "whatever_..." | uniq | sort
(Most likely largely via StackOverflow)
Was just Googling around if I forgot anything about using dd for creating a bootable, and behold:
You can even create a bootable USB stick with cp (it seems much more straightforward for me than dd or a GUI):
sudo cp path/to/ISO /dev/sdX
Also:
That was really new to me. Together with progress unix.stackexchange.com/a/301329/87264 it shows progress, too
Source: AskUbuntu
Well, truly useful ... let's see ...!
Looks like I'm not a user though :) can't just connect my Android phone right away ... really?
See Can't transfer files from Android to Ubuntu via USB cable - Ask Ubuntu
"After digging around I found that Ubuntu doesn't include MTP support by default, which is needed to do general file transfers with Android. I opened a terminal and typed:
sudo apt-get install gmtp
Yea' that was kind of my 2nd thought. 3rd?
But why it's got to get so complicated ... :)
Anyway, note:
echo -e "Hello \nWorld \n" >> greetings.txt
Or, alternatively just output each line with a separate echo statement and printing to append with the >> piper.
SO: shell - how to pipe commands in ubuntu
At least when it's near-trivial to come up with some good design concerns, applying them is effortless...
... well, it turns out just now that about 5 minutes of thinking could have saved - albeit hypothetical - hours of a future DB migration. Even thinking about it I lost like a good 10 minutes :)
There are mitigating circumstances (it's just a "plug-in" until it turns out whether it's worth buying the proper dedicated tech or not - maybe won't ever be needed), but things could be much better too easily.
A poor design/bad implementation can spread in the form of bad practice afterwards... better choices are less likely to end up doing that.
Even if not doing two ful lrounds, think 1½ times at least 😏
... virtually nobody uses it.
Should remind myself that one GitHub search can save a lot of sanity for the rest of the day :) Before I get stuck in "how come I never heard about it? what else don't I know? Google up something else to be worried about + repeat 👍" mode.
So this thing from the defer module was mentioned in relation to the Python generators' .send() method .. hm ... actually now I (believe I) see that's a package! Last released in 2012. Right, good. Move on.
https://github.com/search?q=inline_callbacks+language%3Apy&type=code
Doing some katas, prime factorization of n! is once again a small fun problem to have a go at. I wonder how many equal solutions are out there :) anyway, creating a max prime divisor map instead of the standard Eratosthenes' was an interesting twist of mine (?) so I thought I'd capture it. For the betterment of my audience of 0 people I guess : ))
from collections import Counter
from typing import Dict, List, Tuple
from functools import lru_cache
import math
def max_prime_divisors(n) -> List[int]:
# A slight variation of Erathosthenes' algorithm
# Find and return max_prime_divisor[i], i = 0..n
# true divisors: 1 and n itself are excluded
# could be nicer with numpy arrays? :)
ans = [None] * (n + 1)
for k in range(2, len(ans) // 2 + 1):
if ans[k] is None:
i = k * 2
while i < len(ans):
ans[i] = k
i += k
return ans
def decomp_nr(n, mpd) -> Dict[int, int]:
# return value is in prime -> count form
ans = []
while mpd[n]:
d = mpd[n]
ans.append(d)
n = n // d
if n >= 1:
ans.append(n)
return Counter(ans)
def format_decomp(d):
factors = [f"{key}^{count}" if count > 1 else f"{key}"
for key, count in sorted(d.items())]
return " * ".join(factors)
def decomp(n):
# decompose factorial
mpd = max_prime_divisors(n)
total_decomp = sum([decomp_nr(k, mpd) for k in range(2, n + 1)], Counter())
# print("tdc is:", total_decomp)
return format_decomp(total_decomp) --- --- from collections import Counter
from typing import Dict, List, Tuple, Optional
from functools import lru_cache
import math
def erathosthenes(n) -> List[bool]:
# return is_prime[i], i = 0..n
ans = [True] * (n + 1)
# by convention
ans[0] = False
ans[1] = False
for k in range(2, len(ans) // 2 + 1):
if ans[k]:
i = k * 2
while i < len(ans):
ans[i] = False
i += k
return ans
def decomp_n_fac(n, erat: List[bool]) -> Dict[int, int]:
ans = {}
for p in range(n + 1):
exp = 0
if not erat[p]:
continue
p_pow = p
while p_pow <= n:
exp += n // p_pow
p_pow *= p
ans[p] = exp
return ans
def format_decomp(d):
factors = [f"{key}^{count}" if count > 1 else f"{key}"
for key, count in sorted(d.items())]
return " * ".join(factors)
def decomp(n):
# decompose factorial
erat_map = erathosthenes(n)
total_decomp = decomp_n_fac(n, erat_map)
return format_decomp(total_decomp)