Skip to content

Instantly share code, notes, and snippets.

View sunipkm's full-sized avatar
💭
Just a mirror for the Sun :)

Sunip Mukherjee sunipkm

💭
Just a mirror for the Sun :)
View GitHub Profile
@sunipkm
sunipkm / py_tidbits.md
Created May 1, 2023 17:43
Python Tidbits

Python Tidbits

Usual imports and setting nice fonts

# %% Imports
from __future__ import annotations
from collections.abc import Iterable
import datetime as dt
from functools import partial
import lzma
import pickle
@sunipkm
sunipkm / test_simd.cpp
Created November 4, 2022 18:17
Test x86 SIMD extensions support
/*
Check SSE/AVX support.
This application can detect the instruction support of
SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, SSE5, and AVX.
*/
#include <iostream>
#include <string.h>
#include <stdint.h>
#ifdef _MSC_VER
@sunipkm
sunipkm / get_default_ip.c
Created May 21, 2022 02:21
Get default interface IP address
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#define NETWORK_WINDOWS
#define _CRT_RAND_S
typedef int ssize_t;
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
@sunipkm
sunipkm / xterm_pos.c
Created May 15, 2022 03:33
Cursor Positioning in Xterm or similar
#include <stdio.h>
#define clear() printf("\033[H\033[J")
#define gotoxy(x,y) printf("\033[%d;%dH", (y), (x))
int main(void)
{
int number;
clear();
@sunipkm
sunipkm / ssl_cert_verify.md
Created May 13, 2022 20:12
OpenSSL Certificate Validation Resources

OpenSSL Certificate Parsing

Parsing X.509 Certificates with OpenSSL and C

Zakir Durumeric | October 13, 2013

While OpenSSL has become one of the defacto libraries for performing SSL and TLS operations, the library is surprisingly opaque and its documentation is, at times, abysmal. As part of our recent research, we have been performing Internet-wide scans of HTTPS hosts in order to better understand the HTTPS ecosystem (Analysis of the HTTPS Certificate Ecosystem, ZMap: Fast Internet-Wide Scanning and its Security Applications). We use OpenSSL for many of these operations including parsing X.509 certificates. However, in order to parse and validate certificates, our team had to dig through parts of the OpenSSL code base and multiple sources of documention to find the correct functions to parse each piece of data. This post is intended to document many o

#!/bin/bash
# This Works is placed under the terms of the Copyright Less License,
# see file COPYRIGHT.CLL. USE AT OWN RISK, ABSOLUTELY NO WARRANTY.
#
# COPYRIGHT.CLL can be found at http://permalink.de/tino/cll
# (CLL is CC0 as long as not covered by any Copyright)
OOPS() { echo "OOPS: $*" >&2; exit 23; }
[ -z "`pidof openssl`" ] || OOPS "openssl running, consider: killall openssl"
@sunipkm
sunipkm / parse_tle.md
Created December 2, 2021 21:45
Obtain TLE and read line by line
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	FILE *pp = popen("wget -q -O- http://celestrak.com/NORAD/elements/stations.txt", 
 "r");
@sunipkm
sunipkm / ANSI.md
Created October 19, 2021 03:19 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27
@sunipkm
sunipkm / arm_chroot.md
Created October 7, 2021 02:41
ARM `chroot` from x86-64
  1. Install qemu-user-static (one time)
  2. Copy qemu-arm-static to /path/to/chroot/bin to execute ARM binaries on x86_64 (any time a new chroot environment is set up)
  3. Mount proc, dev and sys: for i in proc sys dev; do sudo mount -o bind /$i /path/to/chroot/$i; done
  4. Chroot into the directory: sudo chroot /path/to/chroot qemu-arm-static /bin/bash
  5. Do stuff, Ctrl+D to exit.
  6. Unmount proc, dev and sys: for i in proc sys dev; do sudo umount /path/to/chroot/$i; done
  7. sync any changes you made.
@sunipkm
sunipkm / adrv_kern.md
Last active June 12, 2025 17:14
Compiling HDL and kernel for ADRV

General overview

The basic flow of the process of compiling the linux kernel for the ADRV with customized pin layout and device configuration is as follows:

  1. Cloning the HDL repo, switching to a stable release (and obtaining the relevant release of Vivado HLx Design Suite).
  2. Executing make in the relevant (ADRV9364Z7020) project directory to make the Vivado project for the SOM.
  3. Patching the system_top.v files and common/*.xdc files for the project as required, then synthesize, implement and generate the bitstream for the design. Go to File &rarr Export &rarr Export Hardware to export the .hdf file.
  4. Follow the procedure here to build the device tree blob, which exposes the devices enabled in the HDL design phase to the Linux kernel. ~~Note that, you may need to edit the .dts or .dtsi files generated during this process to enable sysfs drivers for some de