Skip to content

Instantly share code, notes, and snippets.

View rezamarzban's full-sized avatar
🎯
Focusing

rezamarzban

🎯
Focusing
View GitHub Profile
@rezamarzban
rezamarzban / VSWR.py
Last active December 11, 2025 11:32
Local vswr
import cmath
import math
# Define the chain as a simple list of tuples: ('type', value, 'unit')
# Types: 'R' for resistor, 'L' for inductor, 'C' for capacitor, 'Source' for AC Source
# Units for R/Source: 'ohm', 'kohm', 'mohm'
# Units for L: 'nH', 'uH', 'mH', 'H'
# Units for C: 'fF', 'pF', 'nF', 'uF', 'F'
# Example (AC Source with 0 impedance included as first element):
chain = [
@rezamarzban
rezamarzban / mag_tube_anode.ipynb
Created November 14, 2025 06:14
Mag_tube_anode.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rezamarzban
rezamarzban / mag.py
Created November 7, 2025 05:29
Hull split-anode design, Pulse width: 0.56 μs (time to reach $V_{bd}$). Off time: 50 μs. Duty cycle: 1.1%, 1 mm glass coating, conservative thermal limits
import math
import numpy as np
import matplotlib.pyplot as plt
# Constants
epsilon_0 = 8.85e-12 # F/m (vacuum permittivity)
mu_0 = 4 * math.pi * 1e-7 # H/m (vacuum permeability)
k_glass = 1.0 # W/m·K (thermal conductivity of glass)
epsilon_r = 5.0 # relative permittivity of glass
delta_T_max = 50.0 # Maximum temperature rise (°C)
@rezamarzban
rezamarzban / rlc.ipynb
Last active October 28, 2025 06:48
rlc.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
# Parameters
R = 0.01
L = 1e-6
C = 1e-7
f = 50e3 # 50 kHz
omega = 2 * np.pi * f
* RLC circuit with 50kHz square wave input
V1 1 0 PULSE(0 5 0 10n 10n 10u 20u)
R1 1 2 0.01
L1 2 3 0.1u
C1 3 0 1n
.tran 10n 2000m 1999.8m
.option numdgt=9
.save all
#!/bin/bash
set -e
# -------------------------------------------------------------------
# Check and install prerequisites
# -------------------------------------------------------------------
PKGS=(git curl tar make libtool autoconf automake pkg-config)
MISSING=()
for pkg in "${PKGS[@]}"; do
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
@rezamarzban
rezamarzban / build.sh
Last active October 8, 2025 08:50
WASI COMPILED WASM of ngspice
#!/bin/bash
set -e
# -------------------------------------------------------------------
# Check and install prerequisites
# -------------------------------------------------------------------
PKGS=(git curl tar make libtool autoconf automake pkg-config)
MISSING=()
for pkg in "${PKGS[@]}"; do
if ! dpkg -s "$pkg" >/dev/null 2>&1; then

Installing and Using udocker in Termux

To run a small Docker image like Alpine in Termux using udocker (a user-space Docker alternative without root or a daemon), execute the following commands sequentially in your Termux shell. This setup handles installation, pulling the lightweight Alpine image (~5MB), and running a simple container. Note that you'll need to set an environment variable each session for proot support.

Step 1: Update packages and install dependencies

pkg update && pkg upgrade -y
pkg install -y python-pip proot
@rezamarzban
rezamarzban / Php.md
Last active September 25, 2025 09:30

To run Nginx and PHP in Termux, you can install both from the Termux package repository and configure them to work together using PHP-FPM. Here is a summary of the key steps:

Installing Nginx in Termux

  • Install Nginx with the command: pkg install nginx
  • Nginx files are located in $PREFIX/share/nginx/ or /data/data/com.termux/files/usr/share/nginx/
  • Start Nginx server by running: nginx
  • Default web files go to $PREFIX/share/nginx/html
  • You can access the server locally at localhost:8080

Installing PHP in Termux