Skip to content

Instantly share code, notes, and snippets.

View maneesh29s's full-sized avatar
😄
Happy

Maneesh Sutar maneesh29s

😄
Happy
View GitHub Profile
@maneesh29s
maneesh29s / vectorized_functions_with_dask_cpu.ipynb
Created December 21, 2024 11:30
Gist contains notebooks , which demonstrate how we can use JAX to use vectorized functions with dask arrays. Also contains Numba example for CPU.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maneesh29s
maneesh29s / ci-notifier.sh
Last active August 19, 2024 13:13
A shell script which can quickly check the status of gitlab-ci pipeline from your terminal. On macos, this can send a notification if the pipeline status is "failed"
#!/usr/bin/env bash
set -e
# A script which can be run as a cron job
# which will notify you if the pipeline has failed
# Input as arguments:
# $1: gitlab project id
# $2: ref to track, e.g. name of the branch. Default 'main'
@maneesh29s
maneesh29s / timer.cpp
Last active April 12, 2024 12:39
Timer class. Takes std::chrono::type as template for timer unit
template <typename T>
class Timer {
private:
std::chrono::time_point<std::chrono::high_resolution_clock> start;
std::chrono::time_point<std::chrono::high_resolution_clock> end;
public:
void start_timer() {
this->start = std::chrono::high_resolution_clock::now();
}
@maneesh29s
maneesh29s / std_generator.cpp
Last active September 28, 2023 06:04
Random Distribution Generator using standard library methods (c++17 and above). Random data is generated and stored in a 2D array of size 4x3.
#include <array>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <random>
using Vec3D = std::array<float, 3>;
int main() {
  std::array<Vec3D, 4> arr;
@maneesh29s
maneesh29s / compare_fits.sh
Last active July 7, 2023 05:29
Compares all fits files in 2 given directories, using `fitsdiff`. `fitsdiff` is available in astropy conda/pip package.
#!/usr/bin/env bash
if [[ $# -ne 2 ]]
then
echo "Usage: $0 first_dir second_dir";
echo "Both inputs are directories containing the FITS images to compare";
exit 1;
fi
@maneesh29s
maneesh29s / ssh_agent_init.sh
Created July 1, 2023 06:12
A bash script to manage ssh agent session within multiple terminal. Add this in your `~/.bashrc`
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
@maneesh29s
maneesh29s / sse2neon.h
Created April 10, 2023 04:14
A header file which converts SSE insttructions into NEON
#ifndef SSE2NEON_H
#define SSE2NEON_H
// This header file provides a simple API translation layer
// between SSE intrinsics to their corresponding Arm/Aarch64 NEON versions
//
// This header file does not yet translate all of the SSE intrinsics.
//
// Contributors to this work are:
// John W. Ratcliff <jratcliffscarab@gmail.com>
@maneesh29s
maneesh29s / bench_endian_conversion.cpp
Created April 4, 2023 07:23
This programs tests the performance difference caused due to endian conversion
// simple swapping without data types
#include <assert.h>
#include <chrono>
#include <cstring>
#include <iostream>
#include <ratio>
#include <vector>
#define SIZE_CAN_FLOAT 4
@maneesh29s
maneesh29s / generics-using-macros.c
Last active March 8, 2023 06:59
Interesting way of how we can use macros, to define function (bodies) having a generic code. To understand whats happening, look at the pre-processor output using "-E" flag
// simple swapping without data types
#include <stdio.h>
#define SWAP(x, y) \
tmp2 = *x; \
*x = *y; \
*y = tmp2;
#define DEFINE_SWAP(FUN_SWAP, T) \
void FUN_SWAP(T *x, T *y) { \
@maneesh29s
maneesh29s / intrinsic_support_check.cpp
Created February 27, 2023 07:00
Gist to check which intrinsics are present in a machine
#include <iostream>
int main(int argc, char const *argv[])
{
#ifdef __amd64__
std::cout << "__amd64__ detected" << std::endl;
#endif
#ifdef __x86_64__
std::cout << "__x86_64__ detected" << std::endl;
#endif