Skip to content

Instantly share code, notes, and snippets.

View AlyShmahell's full-sized avatar
💭
I may be slow to respond.

Aly Shmahell AlyShmahell

💭
I may be slow to respond.
  • European Union
View GitHub Profile
@AlyShmahell
AlyShmahell / mandelbrot.py
Created June 24, 2020 03:43 — forked from justecorruptio/mandelbrot.py
Python script to generate a Mandelbrot set.
J=1;exec'''z="";b=-1.6;exec'
x=y=0;exec"x,y=2*x*y+J,y*y-x
*x+b;"*20;z+=" O"[x*x+y*y<2]
;b+=.040;'*60;print z;J-=.10
;'''.replace('\n','')*20#Jay
@AlyShmahell
AlyShmahell / brainfuck.py
Created June 24, 2020 03:41 — forked from justecorruptio/brainfuck.py
Tiny brainfuck interpreter.
import sys,os;M=[0]*30000;A=[]
p=k=x=0;S=open(sys.argv[1]).read()
while x<len(S):exec"""M[p]+=1
M[p]-=1 M[p]=ord(os.read(0,1)or"\\0")
os.write(1,chr(M[p])) p-=p>0 p+=1
k=A.append(x)if+M[p]else+1 x=A.pop()-1
k+=1 0 k-=1 0""".split()['+-,.<>[][+]+'
.find(S[x]+'+'*(k>0))];M[p]&=255;x+=1
@AlyShmahell
AlyShmahell / mutual_info.py
Created September 16, 2019 04:15 — forked from GaelVaroquaux/mutual_info.py
Estimating entropy and mutual information with scikit-learn
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
These computations rely on nearest-neighbor statistics
'''
import numpy as np
# Full example for my blog post at:
# https://danijar.com/building-variational-auto-encoders-in-tensorflow/
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
tfd = tf.contrib.distributions
@AlyShmahell
AlyShmahell / VSCodeExtension.py
Created October 22, 2018 14:39 — forked from harry-cpp/VSCodeExtension.py
VSCode extension for Nautilus
# VSCode Nautilus Extension
#
# Place me in ~/.local/share/nautilus-python/extensions/, restrart Nautilus, and enjoy :)
# mkdir -p ~/.local/share/nautilus-python/extensions && cp -f VSCodeExtension.py ~/.local/share/nautilus-python/extensions/VSCodeExtension.py && nautilus -q
#
# This script was written by cra0zy and is released to the public domain
from gi import require_version
require_version('Gtk', '3.0')
require_version('Nautilus', '3.0')
@AlyShmahell
AlyShmahell / bottle_example.py
Created July 24, 2018 00:30 — forked from Arthraim/bottle_example.py
a python web framework bottle's example
#coding: utf-8
from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template
@route('/')
@route('/index.html')
def index():
return '<a href="/hello">Go to Hello World page</a>'
@route('/hello')
def hello():
@AlyShmahell
AlyShmahell / _chi2.c
Created July 18, 2018 11:33 — forked from dfm/_chi2.c
How to wrap C code in Python
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@AlyShmahell
AlyShmahell / _chi2.c
Created July 18, 2018 11:33
How to wrap C code in Python
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@AlyShmahell
AlyShmahell / WritingPseudocode.md
Created June 16, 2018 12:15 — forked from camilstaps/WritingPseudocode.md
How to write good pseudocode

How to write good Pseudocode

This is an unfinished list of remarks on how to write good pseudocode.

What is pseudocode?

Pseudocode is a loosely defined way of transmitting the concept of an algorithm from a writer to a reader. Central is the efficiency of this communication, not the interpretability of the code by an automated program (e.g., a parser).

@AlyShmahell
AlyShmahell / matrix_product_state_obc_tikz.tex
Created June 9, 2018 14:14 — forked from stared/matrix_product_state_obc_tikz.tex
TikZ code drawing Matrix Product State in tensor diagram notation (i.e. Penrose graphical notation). Get pdf, ps or svg.
\documentclass{standalone}
%% for compilation with htlatex (to produce svg image),
%% uncomment the line below:
% \def\pgfsysdriver{pgfsys-tex4ht.def}
\usepackage{tikz}
\tikzstyle{tensor}=[rectangle,draw=blue!50,fill=blue!20,thick]