Skip to content

Instantly share code, notes, and snippets.

View esirK's full-sized avatar
🎯
Focusing

Isaiah King'ori esirK

🎯
Focusing
View GitHub Profile
@esirK
esirK / docker-compose.yml
Created February 26, 2024 07:06
Localstack with docker swarm
version: '3.7'
services:
localstack:
image: localstack/localstack:3.0.2
deploy:
placement:
constraints: [node.labels.localstack == true]
# Exposing ports on will result into Internal Server Error ("Could not attach to network ingress: rpc error: code = PermissionDenied desc = network ingress not manually attachable")
environment:
class Tweet(TimestampedModelMixin):
"""
Tweet model
"""
tweet_id = models.BigIntegerField(primary_key=True)
content = models.CharField(max_length=1024, help_text=_("Tweet Content"))
deleted_at = models.DateTimeField(blank=True, null=True, db_index=True,)
FROM cfa/base_image as base
EXPOSE 8000
# Install Python dependencies specific to debunkbot
COPY requirements.txt /var/tmp/
RUN pip3 install -r /var/tmp/requirements.txt && rm /var/tmp/requirements.txt && rm -rf /root/.cache/
COPY . /opt/cfa/src/debunkbot/
FROM ubuntu@sha256:9c152418e380c6e6dd7e19567bb6762b67e22b1d0612e4f5074bda6e6040c64a as ubuntu-22.04
RUN apt update && apt upgrade -y
RUN apt install -y wget build-essential zlib1g-dev libssl-dev
# Install Python
RUN wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz && \
tar xzf Python-3.10.2.tgz && \
cd Python-3.10.2 && \
const request = require('request');
const cheerio = require('cheerio');
const url = 'https://browser.geekbench.com/';
async function getData(url) {
let requests = [];
return new Promise((resolve, reject) => {
@esirK
esirK / monitor.py
Last active September 15, 2022 05:52
#!/usr/bin/env python
import os
import subprocess
import re
import shutil
def get_statistics():
statistics = {}
# Network latency
"""
Here we will ping google at an interval of five seconds for five times and record the
min response time, average response time, and the max response time.
"""
ping_result = subprocess.run(['ping', '-i 5', '-c 5', 'google.com'], stdout=subprocess.PIPE).stdout.decode('utf-8').split('\n')
min, avg, max = ping_result[-2].split('=')[-1].split('/')[:3]
statistics['network_latency'] = dict(
{
@esirK
esirK / disk.py
Last active August 15, 2021 07:50
import shutil
import subprocess
statistics = {}
# Top command on mac displays and updates sorted information about processes.
top_command = subprocess.run(['top', '-l 1', '-n 0'], stdout=subprocess.PIPE).stdout.decode('utf-8').split('\n')
# Disk usage
import subprocess
import re
statistics = {}
matcher = re.compile('\d+')
# Memory usage
total_ram = subprocess.run(['sysctl', 'hw.memsize'], stdout=subprocess.PIPE).stdout.decode('utf-8')
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
vmLines = vm.split('\n')
import os
import subprocess
import re
statistics = {}
# Get Physical and Logical CPU Count
physical_and_logical_cpu_count = os.cpu_count()
statistics['physical_and_logical_cpu_count'] = physical_and_logical_cpu_count
"""