Skip to content

Instantly share code, notes, and snippets.

View sshekh's full-sized avatar
:octocat:
Learning new things!

Saurav Shekhar sshekh

:octocat:
Learning new things!
View GitHub Profile
@znstrider
znstrider / gist:a52147584908f1e5413844204688fbe1
Created February 10, 2020 13:10
matplotlib function to make text objects with color highlighted substrings
def colored_text_ax(s, x, y,
color = 'w',
ax = None,
xlim = None,
highlight_colors = ['C0'],
hpadding = 0,
**kwargs):
'''
takes a string with substrings in {} to be highlighted according to highlight colors:
'The weather is {sunny} today. Yesterday it {rained}.', color = 'w', highlight_colors = ['yellow', 'grey']

A Tour of PyTorch Internals (Part I)

The fundamental unit in PyTorch is the Tensor. This post will serve as an overview for how we implement Tensors in PyTorch, such that the user can interact with it from the Python shell. In particular, we want to answer four main questions:

  1. How does PyTorch extend the Python interpreter to define a Tensor type that can be manipulated from Python code?
  2. How does PyTorch wrap the C libraries that actually define the Tensor's properties and methods?
  3. How does PyTorch cwrap work to generate code for Tensor methods?
  4. How does PyTorch's build system take all of these components to compile and generate a workable application?

Extending the Python Interpreter

PyTorch defines a new package torch. In this post we will consider the ._C module. This module is known as an "extension module" - a Python module written in C. Such modules allow us to define new built-in object types (e.g. the Tensor) and to call C/C++ functions.

@vasanthk
vasanthk / System Design.md
Last active October 28, 2025 05:19
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@parmentf
parmentf / GitCommitEmoji.md
Last active October 29, 2025 09:52
Git Commit message Emoji
@bishboria
bishboria / springer-free-maths-books.md
Last active September 25, 2025 06:28
Springer made a bunch of books available for free, these were the direct links
@tonious
tonious / avl.c
Created November 18, 2011 21:13
A quick AVL tree implementation in c.
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <assert.h>
struct avl_node_s {