Andrew Pennebaker
https://github.com/mcandre/cheatsheets/blob/master/lucene.md
Lucene is a programmable search engine, used by elasticsearch and Kibana to search public and private data collections.
<?php | |
// Moodle configuration file inclusion - adjust the path as needed | |
require('/path/to/your/moodle/config.php'); | |
// User data | |
$email = 'example@example.com'; // Assume this comes from your form | |
$username = 'newusername'; // Assume this comes from your form | |
$password = 'newpassword'; // Assume this comes from your form, needs to be hashed | |
// Hash the password using bcrypt, compatible with Moodle's password hashing |
Andrew Pennebaker
https://github.com/mcandre/cheatsheets/blob/master/lucene.md
Lucene is a programmable search engine, used by elasticsearch and Kibana to search public and private data collections.
# Application Deployment | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: my-app | |
namespace: default | |
spec: | |
selector: | |
matchLabels: | |
app: my-app |
# Application Deployment | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: web-app | |
namespace: default | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: |
# Docker | |
# Build a Docker image | |
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker | |
trigger: | |
- main | |
resources: | |
- repo: self |
import boto3 | |
import os | |
def sync_s3_bucket_to_local(bucket_name, local_directory): | |
# Initialize S3 client | |
s3_client = boto3.client('s3') | |
# Create local directory if it does not exist | |
if not os.path.exists(local_directory): | |
os.makedirs(local_directory) |
# pip install unittest-parallel | |
# tests/test_parallel_execution.py | |
# In this code, we have a unittest test case class TestParallelExecution with three test methods representing tasks that can run concurrently. | |
import time | |
import unittest | |
class TestParallelExecution(unittest.TestCase): | |
def test_task_1(self): |
# pip install pytest pytest-xdist | |
# tests/test_parallel_execution.py | |
# In this code, we have three test functions representing tasks that can run concurrently. | |
import pytest | |
import time | |
def test_task_1(): | |
"""Simulate task 1 that takes some time to complete.""" |
# pip install pytest pytest-trio | |
# my_module.py | |
import trio | |
async def trio_async_operation(): | |
async with trio.open_nursery() as nursery: | |
nursery.start_soon(trio_async_task) |
# pip install pytest | |
# tests/test_parallel.py | |
import pytest | |
import time | |
@pytest.mark.parametrize("task_id", range(1, 6)) | |
def test_concurrent_task(task_id): | |
"""Simulate concurrent tasks that take some time to complete.""" |