Skip to content

Instantly share code, notes, and snippets.

View ebrahimebrahim's full-sized avatar
🍉

Ebrahim Ebrahim ebrahimebrahim

🍉
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Snake Game</title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
}
@ebrahimebrahim
ebrahimebrahim / running_mean.py
Created November 24, 2022 20:15
running mean with numpy
import numpy as np
from numpy.typing import NDArray
class RunningMean:
"""Like numpy.mean but aggregates data in chunks at a time."""
def __init__(self, axis=None, keepdims=False):
"""For axis and keepdims, see the documentation of these arg names in numpy.mean"""
self.axis=axis
self.keepdims=keepdims
@ebrahimebrahim
ebrahimebrahim / cambria_math_install.sh
Created October 19, 2022 15:56
install cambria math and times new roman fonts on ubuntu
# some annoying document formatting requirements made me to this in tex:
# \setmathfont{Cambria Math}
# \setmainfont{Times New Roman}
# and of course these microsoft fonts are not found when compiling with xelatex on ubuntu
# this gist helps set up the texlive environment in ubuntu to find the fonts
# thanks to maxwelleite: https://gist.github.com/maxwelleite/10774746
# their script is way better and more automated, but I didn't want to sudo an entire script,
# so below I have extracted the commands I want and made it clear where sudo is needed
# I recommend running the below one by one to check that each step works
@ebrahimebrahim
ebrahimebrahim / slicer_plot_data.py
Last active March 16, 2022 19:09
use a class to manage the nodes involved in a slicer plot view
# To try this example, save this to a file slicer_plot_data.py, then execute Slicer from the command line
# with the arguments `--python-script slicer_plot_data.py`.
import slicer, qt, vtk
PLOT_TYPES = {
"line" : slicer.vtkMRMLPlotSeriesNode.PlotTypeLine,
"bar" : slicer.vtkMRMLPlotSeriesNode.PlotTypeBar,
"scatter" : slicer.vtkMRMLPlotSeriesNode.PlotTypeScatter,
"scatterbar" : slicer.vtkMRMLPlotSeriesNode.PlotTypeScatterBar,