Skip to content

Instantly share code, notes, and snippets.

View devops-school's full-sized avatar

DevOps School devops-school

View GitHub Profile
@devops-school
devops-school / login.php
Last active April 8, 2024 13:22
I am creating a form which would take inputs as a email id, username and password but this has to be inserted into Moodle Mysql database and when i login to moodle with the same username and passworde, it should allow login. I understand that moodle uses bcrypt with salt but i m not sure how to write this php code which would be alternate to moo…
<?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
@devops-school
devops-school / README.md
Created April 8, 2024 07:41
Lucene Cheatsheet
@devops-school
devops-school / gist:c7c7af6529980d89c0aa0311cb39b340
Created April 7, 2024 17:29
Google Cloud: Step by Step Tutorials for setting up Multi-cluster Ingress (MCI)
# Application Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
namespace: default
spec:
selector:
matchLabels:
app: my-app
@devops-school
devops-school / Multi-clusterIngress.yaml
Created April 7, 2024 17:15
Example Deployment YAML for Multi-cluster Ingress with FrontendConfig and BackendConfig
# Application Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
namespace: default
spec:
replicas: 2
selector:
matchLabels:
@devops-school
devops-school / azure-pipelines.yml
Last active December 21, 2023 03:19
Azure Devops Pipeline YAML Example - Build a Docker image
# Docker
# Build a Docker image
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- main
resources:
- repo: self
@devops-school
devops-school / s3.py
Created December 5, 2023 07:40
AWS Tutorials: Python code to sync S3 Buckets
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)
@devops-school
devops-school / gist:8f165edc9936f7dbec71f635f5453326
Created December 1, 2023 05:39
Python Test Runners - unittest-parallel
# 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):
@devops-school
devops-school / gist:dc94ac7919972cabe5e10f612ec5a6a2
Created December 1, 2023 05:38
Python Test Runners - Pytest-xdist
# 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."""
@devops-school
devops-school / gist:d6ef65f294c90db3aec02179d84bb4e9
Created December 1, 2023 05:37
Python Test Runners - pytest-trio
# 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)
@devops-school
devops-school / gist:f0471da2b38fe844a7bf13bdbc0c34ac
Created December 1, 2023 05:37
Python Test Runners - pytest -n
# 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."""