Skip to content

Instantly share code, notes, and snippets.

View aalhour's full-sized avatar
🪂

Ahmad Alhour aalhour

🪂
View GitHub Profile
@aalhour
aalhour / Ackermann
Last active August 29, 2015 14:23
Implementation of the Ackermann formula as discussed on ComputerPhile (https://www.youtube.com/watch?v=i7sm9dzFtEI).
public class AckermannFormula
{
public static long Ackermann(long m, long n)
{
if (m == 0) return (n+1);
else if (n == 0) Ackermann(m-1, 1);
else return Ackermann(m-1, Ackermann(m, n-1));
}
}
@aalhour
aalhour / AckermannMemoized
Last active August 29, 2015 14:23
Recursively-memoized implementation of the Ackermann formula as discussed on ComputerPhile (https://www.youtube.com/watch?v=i7sm9dzFtEI).
public class AckermannFormulaMemoized
{
public static long AckermannMemoized(long m, long n)
{
long ans = 0;
string key = String.Format("{0},{1}", m, n);
if (memory.ContainsKey(key)) {
return memory[key];
} else {
public enum ToyType { Car = 0, House = 1 };
public static class ToysFactory
{
private static IToy _newToy { get; set; }
public static IToy CreateToy(ToyType type)
{
if (type == ToyType.Car)
{
public class TreeNode<T> where T : IComparable<T>
{
public T Value { get; set; }
public TreeNode<T> Left { get; set; }
public TreeNode<T> Right { get; set; }
public TreeNode<T> Parent { get; set; }
}
public static class TreeTraversalIterative
{
@aalhour
aalhour / TreeTraversalRecursive.cs
Last active September 4, 2015 07:09
Recursive traversals of a binary tree.
public class TreeNode<T> where T : IComparable<T>
{
public T Value { get; set; }
public TreeNode<T> Left { get; set; }
public TreeNode<T> Right { get; set; }
public TreeNode<T> Parent { get; set; }
}
public static class TreeTraversalRecursive
{
@aalhour
aalhour / frontendDevlopmentBookmarks.md
Last active September 9, 2015 11:42 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@aalhour
aalhour / microkanren.py
Created December 22, 2015 11:13 — forked from cheery/microkanren.py
Microkanren tryout.
import itertools
# Microkanren programs are 'goal' functions that take in a
# state and return a stream of states that satisfy the given goal.
# I am interested about microkanren because it presents a logic
# programming kernel which fits into a dynamically typed language.
# Anything could go as a variable, but I wanted names for variables.
class Variable(object):
@aalhour
aalhour / mealy-coroutine.py
Created February 17, 2016 21:49 — forked from zultron/mealy-coroutine.py
Mealy FSM implemented with Python coroutines in a ZMQ IOLoop
#!/usr/bin/python
'''
Copyright (c) 2014 John Morris <john@zultron.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@aalhour
aalhour / tmux-cheatsheet.markdown
Created February 27, 2016 11:54 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@aalhour
aalhour / .tmux.conf.grey
Created March 3, 2016 11:21
TMUX Config Snippets
# 256 colors
set -g default-terminal "screen-256color"
set -g status-bg colour235
set -g status-fg white
set -g status-attr bright
set -g status-right-length 50
set -g status-left-length 50
# default window title colors