Skip to content

Instantly share code, notes, and snippets.

@deepns
deepns / mmap_parent_child.c
Created August 22, 2020 22:28
mmap between parent and child processes
#include <stdio.h>
#include <sys/wait.h> // for waitpid
#include <sys/mman.h> // for mmap
#include <unistd.h> // for fork
/*
* An example of communicating between parent and child processes through
* shared memory using mmap
*/
@deepns
deepns / check_url_exists.py
Last active October 31, 2020 19:28
A util function to check whether a given URL exists or not
import urllib.request
# NOTE: Python 3.6+ installations on macOS require an extra step to work with
# https links due to certificate access issues.
# Here is a snippet from the release notes.
# This package includes its own private copy of OpenSSL 1.1.1.
# The trust certificates in system and user keychains managed by the Keychain Access application and the security
# command line utility are not used as defaults by the Python ssl module. A sample command script is included
@deepns
deepns / ssh_utils.py
Last active March 28, 2021 23:13
A wrapper class to run commands on remote host over SSH
import logging
import paramiko
import sys
logging.basicConfig(
format='%(name)s,%(levelname)s,%(asctime)s, %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p',
encoding='utf-8')
class Node:
"""
@deepns
deepns / vscode-rest-client-samples.http
Created April 9, 2021 03:20
Sample HTTP requests using vscode rest-client extension
# Sample HTTP requests using vscode rest-client extension
# Lines with ### serves as a marker for the extension to insert
# links to send requests
### A simple GET Request
# Get list of sites supported by stackexchange APIs
GET https://api.stackexchange.com/2.2/sites
### Get list of tags by site
GET https://api.stackexchange.com/2.2/tags?site=stackoverflow
@deepns
deepns / syntax_highlighting.py
Created May 13, 2021 02:35
Syntax highlighting in Python using Pygments
# Syntax highlighting code in Python using pygments
# install pygments if not installed already
# pip3 install pygments
# sample languages used here: markdown, json
from pygments import highlight
from pygments.lexers import get_lexer_by_name
# Formatting the output to be sent to a terminal
# Hence using Terminal256Formatter. Many other formatters
@deepns
deepns / generate_ssl_certs.sh
Last active December 11, 2021 17:14
A bash script to generate SSL certificates using openssl
#! /usr/bin/env bash
# TODO
# Generate self-signed cert without root-ca
# Generate the private key and self-signed cert for the root CA
generate_root_ca()
{
ROOT_CA=$1
@deepns
deepns / notes.json
Last active July 16, 2024 07:42
Collection of my tech notes/tips/things-to-remember/flash-cards
[
{
"id": 101,
"description": "GoogleSheets - Convert currency for a particular date",
"tags":[
"google",
"sheets",
"functions",
"shortcuts"