Skip to content

Instantly share code, notes, and snippets.

@ghazanhaider
ghazanhaider / gist:3c1a09be62e9a9859263eb37fbc2c359
Created February 22, 2026 06:07
Installing Joplin Server on Amazon Linux 2023
sudo yum install docker
sudo systemctl start docke
sudo systemctl enable docker.service
sudo usermod -aG docker $USER
sudo curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m) -o /usr/libexec/docker/cli-plugins/docker-compose
sudo chmod +x /usr/libexec/docker/cli-plugins/docker-compose
docker compose version
# Shows: "Docker Compose version v5.0.2"
cat <<EOF > docker-compose.yml
version: '3'
@ghazanhaider
ghazanhaider / driver.md
Last active September 5, 2025 14:57
Kernel driver model

Bus

  • Bus probes all devices
  • Bus registers all drivers usable for the bus
  • Bus then 'binds' driver to each device discovered:
    • When device_register is called for a device, it is inserted into the end of this list.
    • The bus object also contains a list of all drivers of that bus type.
    • These are the two events which trigger driver binding.
    • If a match is found, the device's driver field is set to the driver and the driver's probe callback is called.
    • This gives the driver a chance to verify that it really does support the hardware, and that it's in a working state.
  • When a driver is attached to a device, the device is inserted into the driver's list of devices.
@ghazanhaider
ghazanhaider / gist:15328e1c82389afdf705c40abe857c5d
Last active September 11, 2024 22:50
Setting up SAM-BA across architectures
# Microchip SAM-BA is only released for x86_64 architecture and will not run on arm64
# These steps allow it to be run under Ubuntu arm64 using qemu-user successfully
- Install Ubuntu (24.04.01)
- sudo apt install:
qemu-user
qemu-user-static
gcc-aarch64-linux-gnu
binutils-aarch64-linux-gnu
# How to increase the size of an LVM based disk
# Step1: Increase underlying disk size (qemu, vmware etc)
# Step2:
cfdisk /dev/nvme0n1p3
pvresize /dev/nvme0n1p3
lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv -r
@ghazanhaider
ghazanhaider / task_scheduler.c
Created April 26, 2023 21:51
Simple task scheduler
#include<stdio.h>
// task functions
void taskOne (void) { puts("Thread 1\n"); }
void taskTwo (void) { puts("Thread 2\n"); }
void taskThree (void) { puts("Thread 3\n"); }
// Function array of tasks
void *funcArray[] = {
&taskOne,
# Simplest server socket example
#
import socket
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.bind(('127.0.0.1',8080))
s.listen(1)
conn,addr = s.accept()
# Create CA
openssl genrsa -des3 -out ./ssl/rootCA.key -passout file:./ssl/pass 2048
# Check: openssl rsa -in ssl/rootCA.key -check
openssl req -x509 -new -nodes -key ./ssl/rootCA.key -sha256 -days 1024 -out ./ssl/rootCA.pem -passin file:./ssl/pass -subj "/C=PK/ST=Balochistan/L=Quetta/O=Hajiabad/CN=ca.ghazan.work"
# Check: openssl x509 -in ./ssl/rootCA.pem -text
# Create self signed cert
@ghazanhaider
ghazanhaider / AT Commands
Last active October 5, 2018 05:17
SIM900 AT commands
# Basic Checks
AT+COPS? // Show network operator
AT+COPN // All network operators
# SMS
AT+CMFG=1 // Enable txt mode SMS
AT+CMGS="+NUMBER" // Start SMS to this number, end in 0x1a (no newline)
AT+CMGR=1 // Receive and read SMS
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing></servicing>
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<UILanguage>en-US</UILanguage>
@ghazanhaider
ghazanhaider / named-zone
Created August 18, 2017 21:06
named zones
; forward zonefile for test.com
$ORIGIN test.com.
$TTL 1h
test.com. IN SOA ns.test.com. username.test.com. ( 2007120710 1d 2h 4w 1h )
test.com. IN NS ns
test.com. IN A 192.168.2.1
ns IN A 192.168.2.1
win IN A 192.168.2.2
vcenter IN A 192.168.2.10