Skip to content

Instantly share code, notes, and snippets.

@mahar
mahar / rcParams.py
Created May 6, 2020 08:09
rcParams Python
fig_width_pt = 246. # Get this from LaTeX using \the\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean#/1.5 # height in inches
figW = fig_width #*2
fig_size = [figW,fig_height]
params = {'backend': 'pdf',
'axes.labelsize': 12,
@mahar
mahar / The Technical Interview Cheat Sheet.md
Created August 3, 2016 11:55 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@mahar
mahar / import_csv_to_mongo
Last active September 8, 2015 12:59 — forked from mprajwala/import_csv_to_mongo
Store CSV data into mongodb using python pandas
#!/usr/bin/env python
import sys
import pandas as pd
import pymongo
import json
def import_content(filepath):
mng_client = pymongo.MongoClient('localhost', 27017)
@mahar
mahar / detect_local_max.py
Created September 2, 2015 15:50
Detect local maxima in python
#https://gist.github.com/agrimaldi/781740
#!/usr/bin/env python2.7
import scipy.ndimage as ndimage
import numpy as np
def local_maxima(array, min_distance = 1, periodic=False, edges_allowed=True):
"""Find all local maxima of the array, separated by at least min_distance."""
array = numpy.asarray(array)
cval = 0
@mahar
mahar / polaritonic_slab_3D.scm
Last active August 29, 2015 13:58
Reflection and Transmission by a polaritonic slab
; MEEP code for the calculation of the transmission and reflection spectra
; for a polaritonic SiC slab under normal incidence.
;
; Two calculations are needed.
; 1) A reference calcuation without the slab (to get the incident flux)
; meep-mpi ref?=true polaritonic_slab_3D.ctl > flux_inc.out
; 2) With the structure:
; meep-mpi ref?=false polaritonic_slab_3D.ctl > flux_inc.out
;
(use-output-directory )