Skip to content

Instantly share code, notes, and snippets.

@Elucidation
Elucidation / PythonDataStructures.md
Last active February 11, 2023 10:47
Python Data Structure Cheat Sheet for Interviewing

Python Data Structure Cheat Sheet

If you're interviewing in Python, learn how to code the following data structures / algorithms in python.

List

lists: a = [] or a = list()

@Elucidation
Elucidation / saddle_nonmax.py
Last active June 23, 2017 21:58
Saddle and non-max suppression
import numpy as np
from time import time
def getSaddlePoints(img_gray):
img = np.array(img_gray, dtype=np.float32)
gx, gy = np.gradient(img) # row / col -> y / x
gxx, gxy = np.gradient(gx)
gyx, gyy = np.gradient(gy)
@Elucidation
Elucidation / fork_sync.md
Last active May 20, 2016 20:50
Forking/Syncing Cheatsheet

Step One - Fork Repo

Following these Forking instructions

  1. Go to main/repo and fork it from the top right.
  2. Go to your forked repo your/repo (ex. Elucidation/repo) and get the clone address.
  3. Clone it on your local machine, ex. git clone git@github.com:Elucidation/repo.git

Step Two - Sync fork to upstream

@Elucidation
Elucidation / tetrate.py
Last active January 20, 2016 00:03
4th tetration of 40
def tetrate(a,n):
out = a
for i in range(n-1):
out = out**a
return out
# tetrate(40,4) =
# 690947404219008741222457800129817403411828583413419520419493111831295996413873594644805829445269007203995211615456663016683728495892887369173668195222901927225437605087145618916756687286387933281790174074684078938262974467604784504763521359034420653071639082548294385696121810109894690269688251211866942190570741018859207103333855549659655229457782352250042455188987961990124944566498789120284582054941823848464802195541126726348928999918099721485453487401380891755517663053038386565720934821567824791577310003251521417167426434629082475853747403599157286524656983883765627013038288978340142955459897974440740304697156024080272436830680911744557318966752684607298163681209415027914199719422248693063526880285790311725074566359149791435595982224008237251470592045469117925451215448215721571573814881052721875693562344721819290641270406459206087399926880360229424951866819559416133622268646706822678131045957565756209939994
// Generate an SVG bar plot of temperatures with axes
var dataset; // global dataset populated by d3.csv, used by plotData
function plotData()
{
//Width and height
var w = 800;
var h = 400;
var svg = d3.select("body")
@Elucidation
Elucidation / Ultrasonic_arduino_example.ino
Last active December 27, 2015 22:16
Simple example for how to measure distance from the SainSmart Ultrasonic Module HC-SR04 Distance Sensor, no external libraries needed.I bought it here: http://www.amazon.com/SainSmart-Ultrasonic-Distance-Mega2560-Duemilanove/dp/B004U8TOE6/
// Define the TRIG and ECHO pins used by the ultrasonic sensor, in my case they were pins 4 and 5.
#define TRIG 4
#define ECHO 5
void setup() {
// Initialize the serial communication
Serial.begin(9600);
// Set up pins
pinMode(TRIG, OUTPUT);