Skip to content

Instantly share code, notes, and snippets.

View keshan-spec's full-sized avatar
🏠
Working from home

Keshanth Jude keshan-spec

🏠
Working from home
View GitHub Profile
@keshan-spec
keshan-spec / ajax-instant-wins.php
Created January 23, 2025 15:20
/wp-content/plugins/drive-digital-competitions-plugin/api/ajax-instant-wins.php
function handle_image_upload()
{
global $wpdb;
$id = $_POST['id'];
if (isset($_FILES['imageFile'])) {
$upload_dir = wp_upload_dir(); // Get the upload directory
// Define the path for the uploaded image
$image_path = $upload_dir['path'] . '/' . $_FILES['imageFile']['name'];

README: Setting Up a WordPress Site on a Private EC2 Instance


1. Copy WordPress Files to the Instance

  1. Create a zip file of your WordPress files on your local machine:

  2. Use the following scp command to copy the zip file to the private EC2 instance via the bastion host:

    scp -o ProxyJump=ec2-user@<bastion instance url> wordpress.zip ec2-user@<private instance ip>:/var/www/html
cv2.imshow('MediaPipe Face Detection', cv2.flip(image, 1))
if cv2.waitKey(5) & 0xFF == 27:
break
# To improve performance, optionally mark the image as not writeable to
# pass by reference.
image.flags.writeable = False
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = face_detection.process(image)
# Draw the face detection annotations on the image.
image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
cap = cv2.VideoCapture(0)
with mp_face_detection.FaceDetection() as face_detection:
while cap.isOpened():
success, image = cap.read()
while not success:
success, image = cap.read()
# For webcam input:
cap = cv2.VideoCapture(0)
with mp_face_detection.FaceDetection() as face_detection:
while cap.isOpened():
success, image = cap.read()
while not success:
success, image = cap.read()
# To improve performance, optionally mark the image as not writeable to
# pass by reference.
import os
import re
import dateutil.parser as dparser
conversions = {}
# Define the folder containing the files to be renamed
PATH = os.path.join(os.getcwd(),"files")
def create_dummy_files():
@keshan-spec
keshan-spec / docker-compose.yml
Last active December 6, 2022 22:11
Docker compose file
# docker-compose.yml
version: "3.2"
services:
web:
build: . # where the Dockerfile is located
ports:
- 5000:5000 # container:host
environment:
- URL=https://www.worldometers.info/coronavirus/
@keshan-spec
keshan-spec / Dockerfile
Last active December 6, 2022 22:07
Dockerfile for Python Flask
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
WORKDIR /code
COPY . .
EXPOSE 5000
RUN pip3 install -r requirements.txt
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
@keshan-spec
keshan-spec / app.py
Last active December 6, 2022 21:48
Show Country API Endpoint
@app.route("/show/<country>")
def get_country(country):
entries = get_info_table()
if country == "all":
return json.dumps(entries)
else:
for entry in entries["data"]:
if entry["Country"] == country.lower():
return json.dumps(entry)
return json.dumps({"error": f"Country not found: {country}"})