- Boot with a live USB stick.
- Get name of SSD by running
lsblk
- Run this command:
sudo hdparm --user-master u --security-set-pass 1234 /dev/sda &&
sudo hdparm --user-master u --sanitize-crypto-scramble 1234 /dev/sda
class DictDelta: | |
'''Returns a list of ḱeys, which are added, deleted or whose values have been altered compared to the dict passed in the previous call.''' | |
def __init__(self): | |
self.old_dict = None | |
def __call__(self, new_dict): | |
"""Returns list of changed keys.""" | |
# explicitly check for None, prevent all keys being returned on 1st run |
def mt(a, memo=[]): | |
a += 1 | |
print(a) | |
memo.append(a) | |
print(memo) | |
mt(1) | |
mt(2) | |
mt(3) |
>>> def process_data(a, b, c, d): | |
>>> print(a, b, c, d) | |
>>> x = {'a': 1, 'b': 2} | |
>>> y = {'c': 3, 'd': 4} | |
>>> process_data(**x, **y) | |
1 2 3 4 | |
>>> process_data(**x, c=23, d=42) |
# To be case-insensitive, and to eliminate a potentially large else-if chain: | |
m.lower().endswith(('.png', '.jpg', '.jpeg')) |
from xml.etree.ElementTree import Element, tostring | |
def dict_to_xml(tag, d): | |
''' | |
Turn a simple dict of key/value pairs into XML | |
''' | |
elem = Element(tag) | |
for key, val in d.items(): | |
if type(val) == dict: |
>>> lst = ['a', 'a', 'a'] | |
>>> len(set(lst)) == 1 | |
True | |
>>> all(x == lst[0] for x in lst) | |
True | |
>>> lst.count(lst[0]) == len(lst) | |
True |
#!/bin/bash | |
echo watch activated | |
inotifywait -qmre modify . | while read f | |
do | |
python $1 | |
done |
import sublime | |
import sublime_plugin | |
s = sublime.load_settings('var_share.sublime-settings') | |
def consume(): | |
num = s.get("test_var") | |
print("Consumer received: ", num) |
#!/bin/bash | |
# run under sudo | |
# script for permanently setting environment variables, found here: | |
# https://stackoverflow.com/questions/13046624/how-to-permanently-export-a-variable-in-linux | |
add_env_var() | |
{ | |
KEY=$1 | |
VALUE=$2 | |
echo "export "$KEY"="$VALUE>>~/.bashrc |