Skip to content

Instantly share code, notes, and snippets.

View Mizzlr's full-sized avatar

Mushtaque Ahamed A Mizzlr

View GitHub Profile
// a function that take one argument x and returns itself
function(x) { return x;}
// a function that take nothing; but this will not be used
// naming a function is do as
var functionName = function (x) { // do something with x
return x;
};
// also
function functionName(x) { //...
return x;
module Main where
-- recursive square root function
rsqrt x n = if n == 1 then sqrt x else sqrt (x + rsqrt x (n-1))
-- product expansion of pi upto n terms
productPi n = 2 * product [ 2 / (rsqrt 2 i) | i <-[1..n]]
main = do
putStr "Actual value of pi: "
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
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
@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 │
├─────────┼─────────┤
@Mizzlr
Mizzlr / DNA.txt
Created June 13, 2016 23:43
A sample DNA strand of length 200
CTGCCGCAAGCCGATCGGAGATCGCAGGTGAGAACCGCAG
TAATTGGTCTAGGTGGGAGCGACGCCATACCTCTACGGCA
CACACACACTCGTTTGATATTCCTAGGTGCGCGTTCTTCC
TACAGACATCGTGTGAGATATGTACCCACATTCAAAGAAA
ACTAGATCAAGTTGCTTGACCCGCTGGAGACGGGCCTGGT
@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 / 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 / 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 / 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