Skip to content

Instantly share code, notes, and snippets.

View aerosayan's full-sized avatar
:octocat:
ASM/C/C++ to rule them all !

Sayan Bhattacharjee aerosayan

:octocat:
ASM/C/C++ to rule them all !
  • Previously working in - Sukra Helitek Inc.
  • Chennai, India
View GitHub Profile
@aerosayan
aerosayan / main.rs
Created March 20, 2024 21:34 — forked from rexim/main.rs
The Most Memory Safe Buffer Overflow in Rust!
// The Most Memory Safe Buffer Overflow in Rust!
//
// Consider all the code below under Public Domain
//
// How to build:
// $ rustc main.rs
//
// Wrong password:
// $ printf "hello\n" | ./main
//
@aerosayan
aerosayan / ramp-3d.geo
Created November 15, 2023 07:04
3D Compression Corner Ramp GMSH Generator File
//
// L2-->
// P5 P4
// +------------------+
// ^ | | L3
// | | | |
// L1 | + v
// | L4 . P3
// | .
// +----------+
@aerosayan
aerosayan / myalltoall.f90
Created September 16, 2022 15:45 — forked from plampite/myalltoall.f90
A Fortran example of a deadlock avoiding MPI loop among all processes, using a single-line round robin algorithm to schedule the order of communications for each process
program myalltoall
!Program to show a simple implementation of a deadlock avoiding mpi loop among all processes which,
!in principle, is similar to an alltoall loop. However, the main purpose of the technique shown here is to
!properly reorder shortest (i.e., each process with just few others) non-blocking communication loops,
!in order to alleviate the burden on the communication side (as each exchange is matched, everything
!is exchanged very quickly). Here, it is tested against the the mpi_allreduce intrinsic with MPI_SUM
!on a single real variable, but IT IS NOT a replacement for allreduce (nor alltoall or any other intrinsic).
use, intrinsic :: iso_fortran_env, only : int32, real64
use mpi
implicit none
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <string.h>
#define streq(a, b) (!strcmp((a), (b)))
#ifndef __USE_GNU
#define __USE_GNU
@aerosayan
aerosayan / rdtsc.c
Created January 20, 2022 01:27 — forked from savanovich/rdtsc.c
Using RDTSC instruction that returns CPU TSC (Time Stamp Counter)
/*
https://en.wikipedia.org/wiki/Time_Stamp_Counter
https://ru.wikipedia.org/wiki/Rdtsc
*/
#include <stdio.h>
typedef unsigned long long uint64;
int main() {
@aerosayan
aerosayan / latency.txt
Created January 18, 2022 16:02 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@aerosayan
aerosayan / pickle-payload.py
Created October 20, 2020 12:39 — forked from mgeeky/pickle-payload.py
Python's Pickle Remote Code Execution payload template.
#!/usr/bin/python
#
# Pickle deserialization RCE payload.
# To be invoked with command to execute at it's first parameter.
# Otherwise, the default one will be used.
#
import cPickle
import sys
import base64
import re
import sys
urls=[]
try:
file_name=sys.argv[1]
replacement=sys.argv[2]
except:
print("[!] Enter urls file name")
@aerosayan
aerosayan / Eigen Cheat sheet
Created March 30, 2020 12:16 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@aerosayan
aerosayan / 1-1000.txt
Created March 19, 2020 07:15 — forked from deekayen/1-1000.txt
1,000 most common US English words
the
of
to
and
a
in
is
it
you
that