Skip to content

Instantly share code, notes, and snippets.

View Mizzlr's full-sized avatar

Mushtaque Ahamed A Mizzlr

View GitHub Profile
@Mizzlr
Mizzlr / factorial.py
Last active June 13, 2016 09:02
Most Beautiful Equation Ever
import math, tabulate
def factorial(x):
pi = math.pi
e = math.exp(1)
exponent = -x + pi ** e / (e ** (2 * pi) * x) + \
pi ** e / (e ** (2 * pi) * x + 2 * pi ** e)
return x ** x * math.sqrt(2 * pi * x) * math.exp(exponent)
if __name__ == '__main__':
@Mizzlr
Mizzlr / factorial.output.txt
Created June 13, 2016 09:03
The output generated by factorial.py
╒═════╤════════════════╤═════════════════════╕
│ x │ factorial(x) │ math.factorial(x) │
╞═════╪════════════════╪═════════════════════╡
│ 1 │ 0.999575 │ 1 │
├─────┼────────────────┼─────────────────────┤
│ 2 │ 1.99951 │ 2 │
├─────┼────────────────┼─────────────────────┤
│ 3 │ 5.99942 │ 6 │
├─────┼────────────────┼─────────────────────┤
│ 4 │ 23.9991 │ 24 │
@Mizzlr
Mizzlr / LangtonAnt.pde
Created June 13, 2016 09:28
Processing 3 gist for Simulation of Langton's Ant
// Create a 2D array for the grid
int[][] grid;
// each cell is 4x4 pixel
int cellSize = 4;
// the whole grid is 125x125 cells
int gridSize = 125;
int cellStartX = 0;
int cellStartY = 0;
// enumerate directions
@Mizzlr
Mizzlr / equalizer.matlab
Last active September 22, 2020 20:07
Matlab script to equalize a song.
#! /usr/bin/octave -qf
pkg load signal
% read the file name
fprintf('\n\nInitializing equalizer ...\n');
% setting default values for Equalizer
Equalizer.type = 'Custom';
Equalizer.amps = [7 7 2 0.25 0];
Equalizer.freqs = [100 500 1000 5000 10000];
@Mizzlr
Mizzlr / atree.py
Last active June 14, 2016 09:50
Aggregator Tree Data Structure
class ATree:
"Aggregator Tree Data Structure"
def __init__(self):
self.count = 0
self.children = {}
def __repr__(self):
return "<ATree: %d\n\t%s>" \
% ((self.count, self.children)) \
if self.children else "<ATree: %d>" \
@Mizzlr
Mizzlr / mysqrt.hs
Last active June 13, 2016 18:42
Fast Square Root Algorithm, Code in Haskell
module Main where
-- x -> number whose sqrt has to be found
-- y -> approximate guessed sqrt of x
mysqrt x y = let z = x + y ^ 2
in z / (4 * y) + x * y / z
main = do
-- lets compute sqrt(10) with guess=3
putStr "Actual Value: "
@Mizzlr
Mizzlr / DNA.txt
Created June 13, 2016 23:43
A sample DNA strand of length 200
CTGCCGCAAGCCGATCGGAGATCGCAGGTGAGAACCGCAG
TAATTGGTCTAGGTGGGAGCGACGCCATACCTCTACGGCA
CACACACACTCGTTTGATATTCCTAGGTGCGCGTTCTTCC
TACAGACATCGTGTGAGATATGTACCCACATTCAAAGAAA
ACTAGATCAAGTTGCTTGACCCGCTGGAGACGGGCCTGGT
@Mizzlr
Mizzlr / atree.output.txt
Created June 14, 2016 01:12
Output of ATree algorithm and Data Structure
Block of size=15 is
CACCACCTTGTGGAG
ATree as dict:
╒═════════╤═════════╕
│ chunk │ count │
╞═════════╪═════════╡
│ │ 15 │
├─────────┼─────────┤
│ A │ 3 │
├─────────┼─────────┤
PFont font;
void setup(){
background(0);
size(500,500);
noLoop();
// you can find this file in my LangtonAnt project
// at https://github.com/Mizzlr/LangtonAnt
// place FreeMonoBold.ttf in a directory named data
// under the Parent directory recursivePi
Actual value of pi: 3.141592653589793
Product expansion upto n terms:
1 --> 2.82842712474619
2 --> 3.0614674589207183
3 --> 3.1214451522580524
4 --> 3.1365484905459393
5 --> 3.140331156954753
10 --> 3.1415914215112
100 --> 3.141592653589797