Skip to content

Instantly share code, notes, and snippets.

@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
#include<targets/AT91SAM7s512.h>
int main(void)
{
PIOA_OER |= PIOA_OER_P18_MASK ;
while (1) {
for (int x=0;x<0x00100000;x++) {
PIOA_SODR |= PIOA_SODR_P18_MASK ;
}
#include <targets/AT91SAM7.h>
.global main
main:
# Output enable
ldr r0, =(PIOA_BASE + PIOA_OER_OFFSET)
ldr r1, =PIOA_OER_P18_MASK
str r1, [r0]
loopreset: