Executing linux commands in parallel with xargs command
xargs --help
Usage: xargs [OPTION]... COMMAND [INITIAL-ARGS]...
Run COMMAND with arguments INITIAL-ARGS and more arguments read from input.
Always I forget how to set Linux swap so there it is
#!/bin/bash | |
# Variables to store argument values | |
ARG1="" | |
ARG2="" | |
# Function to display the error message and exit the script | |
function usage_error { | |
echo "Usage: $0 --argument_1=\"<text>\" --argument_2=\"<text>\"" | |
echo "Error: $1" |
import time | |
# | |
# Creating two large sets for testing | |
# | |
a = set(range(1, 1000000)) # Set with 1 million elements | |
b = set(range(500000, 1500000)) # Set that partially overlaps with set 'a' | |
print() |
# reference: https://docs.gspread.org/en/latest/user-guide.html | |
# Install the required libraries | |
!pip install gspread google-auth | |
# Import libraries | |
import gspread | |
from google.colab import auth | |
from oauth2client.client import GoogleCredentials | |
from google.auth import default |
Currently MongoEngine library only support a single database connection, managing collections by Document classes in global scope.
It has a support to change database connections by switch_db
but it's made by a global class attribute called ._meta['db_alias']
When you define many sub ReferenceFields in a hierarchical tree, only first Document object has its ._meta['db_alias']
atttibute changed, not working to query Documents that implement other documents.
import asyncio | |
async def create_async_results(total_items: int): | |
for r in range(total_items): | |
await asyncio.sleep(1) | |
yield r | |
async def example_of_async_for_loop(): | |
async for item in create_async_results(10): | |
print(item) |
import asyncio | |
from random import randint | |
async def execute_your_task(task_number: int): | |
""" Specific task to run in parallel """ | |
# display begin of parallel task in console | |
print('-> starting parallel task:', task_number) | |
import asyncio | |
from random import randint | |
async def execute_your_task(task_number: int): | |
""" Specific task to run in parallel """ | |
# display begin of parallel task in console | |
print('-> starting parallel task:', task_number) | |