Skip to content

Instantly share code, notes, and snippets.

View KarimJedda's full-sized avatar
🥔
Potatoes

Karim KarimJedda

🥔
Potatoes
View GitHub Profile
@KarimJedda
KarimJedda / i_got_to_move_it_move_it.py
Created March 21, 2017 17:46
No sleep mode for mac
import pyautogui
import time
import random
screenWidth, screenHeight = pyautogui.size()
currentMouseX, currentMouseY = pyautogui.position()
while True:
pyautogui.moveTo(random.randint(1, 1000), random.randint(1, 500))
time.sleep(20)
@KarimJedda
KarimJedda / nginx_date_format.sh
Last active June 11, 2020 18:32
Nginx date format change
vim /etc/nginx/nginx.conf:
#add:
log_format mycombined '$remote_addr - $remote_user [$time_iso8601] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
access_log /var/log/nginx/access.log mycombined;
nginx -s reload
@KarimJedda
KarimJedda / tail_nginx_awk_simple.sh
Created June 11, 2020 18:53
Piping Nginx logs to AWK and format
# Get all the logs
tail -f /var/log/nginx/access.log |
# Extract IP and Timestamp for example
awk '{print $1 " " substr($4, 2, length($4) - 7)}' FPAT='[^ ]*|"[^"]*"|\\[[^]]*\\]'
@KarimJedda
KarimJedda / init_sqlite_logger.sh
Created June 11, 2020 18:57
Create sqlite Database
sqlite3 /home/logger/logs.db "create table todo (ip TEXT, timestamp TEXT, status_code TEXT, bytes_sent TEXT, request_method TEXT, request_url TEXT, request_protocol TEXT, referrer TEXT, user_agent TEXT);"
@KarimJedda
KarimJedda / tail_to_sqlite.sh
Last active June 11, 2020 18:58
Tailing Nginx logs to SQLite
tail -f /var/log/nginx/access.log | \
# parsing every line
gawk '{print $1 " " substr($4, 2, length($4) - 8) " " $6 " " $7 " " substr($5, 2, length($5) -2) " " substr($8, 2, length($8)-2) " " $9; system("")}' FPAT='[^ ]*|"[^"]*"|\\[[^]]*\\]' | \
# inserting every new line into sqlite
(while read ip timestamp status_code bytes_sent request_method request_url request_protocol referrer user_agent; do sqlite3 -batch /home/logger/logs.db "insert into todo (ip, timestamp, status_code, bytes_sent, request_method, request_url, request_protocol, referrer, user_agent) values (\"$ip\",\"$timestamp\", \"$status_code\", \"$bytes_sent\", \"$request_method\", \"$request_url\", \"$request_protocol\" ,\"$referrer\" , $user_agent);"; done )
@KarimJedda
KarimJedda / loggingsqlite.service
Created June 13, 2020 12:13
Nginx to Sqlite Logger Service
[Unit]
Description=Nginx Sqlite Logging service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=logger
ExecStart=/bin/bash /home/logger/logging.sh &> /var/log/sqliter/errors.log
@KarimJedda
KarimJedda / ffmpeg-livestream-to-streaming-sites-vaapi-nvenc.md
Created January 4, 2021 04:02 — forked from Brainiarc7/ffmpeg-livestream-to-streaming-sites-vaapi-nvenc.md
ffmpeg livestreaming to youtube via Nvidia's NVENC and Intel's VAAPI on supported hardware

Streaming your Linux desktop to Youtube and Twitch via Nvidia's NVENC and VAAPI:

Considerations to take when live streaming:

The following best practice observations apply when using a hardware-based encoder for live streaming to any platform:

  1. Set the buffer size (-bufsize:v) equal to the target bitrate (-b:v). You want to ensure that you're encoding in CBR mode.

  2. Set up the encoders as shown:

@KarimJedda
KarimJedda / hngen.py
Last active September 27, 2021 12:51 — forked from grantslatton/hngen.py
A program that uses Markov chains to generate probabilistic Hacker News titles.
# coding: utf8
import urllib.request
import re
import sys
from collections import defaultdict
from random import random
import time
"""
# No need to run this
@KarimJedda
KarimJedda / meta-tags.md
Created January 28, 2022 18:26 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags
@KarimJedda
KarimJedda / docker.md
Created February 28, 2022 21:32 — forked from FreddieOliveira/docker.md
This tutorial shows how to run docker natively on Android, without VMs and chroot.

Docker on Android 🐋📱

Edit 🎉

All packages, except for Tini have been added to termux-root. To install them, simply pkg install root-repo && pkg install docker. This will install the whole docker suite, left only Tini to be compiled manually.


Summary