- C-a == Ctrl-a
- M-a == Alt-a
:q close
:w write/saves
:wa[!] write/save all windows [force]
:wq write/save and close
""" | |
Re-implementation of StrEnum for imports in python 3.8.6+ version | |
From https://github.com/clbarnes/backports.strenum/blob/main/backports/strenum/strenum.py | |
""" | |
from enum import Enum | |
class StrEnum(str, Enum): | |
""" |
/** | |
* Perform a faster file copy under windows of a file, has the piece of code | |
* {@code inChannel.transferTo(0, inChannel.size(), outChannel);} seems to | |
* struggle. | |
* @param in the source file object | |
* @param out the destination file object | |
*/ | |
public static void fastCopy(File in, File out) throws IOException | |
{ | |
FileChannel inChannel = new FileInputStream(in).getChannel(); |
import java.text.MessageFormat; | |
import java.util.Objects; | |
/** | |
* A convenience class to represent pairs (tuples of 2 values) | |
* @param <T> the type to be used by the pair | |
*/ | |
public class Pair<T> | |
{ | |
// ===== ( Members ) ================================================================================================ |
def get_pid_by_name(name: str): | |
""" | |
Search the PID of by name of the program | |
return: a generator with the list of pids | |
""" | |
processes = subprocess.check_output(["ps", "-fea"]).decode(sys.stdout.encoding).split('\n') | |
for p in processes: | |
args = p.split() | |
for part in args: | |
if name in part: |
def search_dict_element_with_keys(dictionnary, *keys): | |
"""Recursively search for a dictionnary for the dict[n0][n1][...][n(k-1)][nk] element.""" | |
dict_value = dictionnary.get(keys[0], None) | |
# If the sub element is a dictionnary key and there are still keys to iterate through | |
if isinstance(dict_value, dict) and len(keys) > 1: | |
return get_dict_element_at(dict_value, *keys[1:]) | |
# elif the value is not a dictionnary but there are still keys to iterate through, that means that we reached a dead end | |
elif dict_value is not None and len(keys) > 1: |
for /R c:\source %%f in (*.xml) do copy %%f x:\destination\ |
# SMA: | |
n = 10 | |
array_meanA = array('f', []) | |
for h in range(n): | |
array_meanA.append(14.0) # Initialise the array with 10 values of '14'. | |
for x in range(n): | |
getSensorData() # Get some data.eg tempPiFloat | |
array_meanA[n] = tempPiFloat # tempPiFloat slots into end of array. | |
for h in range(n): | |
array_meanA[h] = array_meanA[(h+1)] # Shift the values in the array to the left |
#!/usr/bin/env python3 | |
# Loads and manage configuration | |
"""A module that manage a configuration file and makes it accessible to any other modules.""" | |
import configparser | |
import logging | |
import os.path | |
class Config: |