Skip to content

Instantly share code, notes, and snippets.

View adamallaf's full-sized avatar
👾

Adam Allaf adamallaf

👾
View GitHub Profile
@adamallaf
adamallaf / cpu_temperature.sh
Created February 16, 2024 18:29
Read CPU temperature in degrees Celsius
#!/bin/sh
cat /sys/class/thermal/thermal_zone0/temp | sed 's/\(.\)..$/.\1°C/'
@adamallaf
adamallaf / vnc.sh
Created February 16, 2024 18:24
VNC over SSH
#!/bin/bash
TMP_FILE=`mktemp`
echo -e "[*] Creating SSH tunnel on port 5901..."
tail -f $TMP_FILE | ssh -L 5901:localhost:5901 user@a.b.c.d >/dev/null 2>&1 &
TUNNEL_PID="$!"
echo -e "[*] SSH tunnel created [pid: $TUNNEL_PID]"
sleep 1
rm -r $TMP_FILE
echo "[*] Starting vncviewer..."
vncviewer 127.0.0.1:1
@adamallaf
adamallaf / eth0.sh
Created February 16, 2024 13:00
Setting up network devices with ip
#!/usr/bin/sh
IPADDRESS="`hostname -I | tr -d ' \n'`"
NEWIP='a.b.c.d'
if [ "$IPADDRESS" = "$NEWIP" ]
then
echo "same ip"
exit
fi
ip address flush dev eth0
ip route flush dev eth0
@adamallaf
adamallaf / env_var_parser.c
Created December 30, 2023 11:50
Environment vaiable parser
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[], char* env[]) {
printf("%d\n", argc);
printf("%s\n", argv[0]);
printf("%s\n", env[0]);
char** ptr = env;
size_t len = strlen(*ptr);
@adamallaf
adamallaf / HTTPServer.ps1
Created January 24, 2023 14:12 — forked from jakobii/HTTPServer.ps1
A Basic Powershell Webserver
# You Should be able to Copy and Paste this into a powershell terminal and it should just work.
# To end the loop you have to kill the powershell terminal. ctrl-c wont work :/
# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
@adamallaf
adamallaf / m_get_ip.py
Last active January 23, 2023 09:59
C get ip function equivalent in python3
import fcntl
import socket
import struct
"""
char *get_ip(char *iname) {
int fd;
struct ifreq ifr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
@adamallaf
adamallaf / _toggle_mic.sh
Last active August 29, 2021 13:54
mic toggle script used for key shortcut
#!/bin/sh
# 🎙 ✔︎ ✘
MICSTATUS=`amixer set Capture toggle | grep "\[on\]"`
if [ -z "$MICSTATUS" ]; then
notify-send "." --icon="/path/to/mic_mute_64w.png" -t 100
else
notify-send "." --icon="/path/to/mic_unmute_64w.png" -t 100
fi
@adamallaf
adamallaf / git-deployment.md
Created September 20, 2020 22:35 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@adamallaf
adamallaf / create_repo.sh
Last active January 23, 2023 22:30
Create git repository shell script for synology nas
#!/usr/bin/env sh
create_git_repository() {
if [ -z "$1" ]
then
echo "Usage: ./create_repo.sh NAME"
return
fi
cd /volume1/git/
git --bare init $1.git
@adamallaf
adamallaf / hexdump.py
Created January 20, 2020 05:55
pyHex dump
import argparse
import os
import sys
class HexDumpLine:
__slots__ = ['address', 'data']
def __init__(self, address, data):
self.address = address