Skip to content

Instantly share code, notes, and snippets.

View shalinmangar's full-sized avatar

Shalin Shekhar Mangar shalinmangar

View GitHub Profile
@alexbowe
alexbowe / tree_iterators.py
Last active July 5, 2023 23:41
Method to simplify many programming interview tree questions.
'''
Interview hack: Memorize preorder/inorder/postorder tree ITERATORS (no recursion) and their reverses.
It simplifies a disproportionate number of questions to simple for loops (see below).
I consider the implementations below the simplest way to memorize the iterative tree traversal algorithms,
because they are so similar to each other, and to their respective recursive versions.
Notes:
- We only visit a node after we have expanded its children (i.e. added them to the stack) in the desired order.
- `x is curr` does the expanded flagging for us, because we always expand the current node.
@bishboria
bishboria / springer-free-maths-books.md
Last active July 17, 2025 06:34
Springer made a bunch of books available for free, these were the direct links
@aidanhs
aidanhs / gist:5ac9088ca0f6bdd4a370
Last active September 25, 2024 11:17
Rust binary tree worked example

PLEASE DON'T USE THIS GUIDE

It's over 9 years old (as of 2024-02-18), there are many better guides! You might like https://rust-unofficial.github.io/too-many-lists/

% Let's build a binary tree!

Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:

  1. must have a value
@markrmiller
markrmiller / beast.sh
Last active June 14, 2020 19:02
The best Lucene / Solr beasting script in the world. TM.
#!/usr/bin/env bash
#set -x #echo on
#echo "args:$@"
# The best Lucene / Solr beasting script in the world. TM. 4.3.0
#
# This script will fire off N independent test runs for a class, X of them in parallel.
#
# A results.log file is written to the {results-dir}. A non zero exit status indicates a failed run.
@nickloewen
nickloewen / bret_victor-reading_list.md
Last active July 7, 2025 03:53
Bret Victor’s Reading List

This is a plain-text version of Bret Victor’s reading list. It was requested by hf on Hacker News.


Highly recommended things!

This is my five-star list. These are my favorite things in all the world.

A few of these works have had an extraordinary effect on my life or way of thinking. They get a sixth star. ★

@antirez
antirez / srt.tcl
Created December 20, 2010 17:00
stretch / sync an SRT subtitle file to exactly match your video file.
# Quick hack to stretch the .srt subtitles to match the one of your video.
# Check the time of the first and last sentence in your video file, then
# use this tool to convert the .srt file into one matching your video with:
#
# tclsh srt.tcl file.srt <your start time> <your end time> > output.srt
#
# Example:
#
# tclsh srt.tcl my.srt 00:00:24,000 00:44:15,000 > ~/Desktop/new.srt
#
/* Traits: a simple way to make fake objects for testing. */
/* Because Mockito is cool but my brain says no to mocking libraries! ;-) */
/* Here's our simple Foo class with an expensive
call that is network dependent - getFromApi() */
class Foo {
def getFromApi() {
http(blargh)