Skip to content

Instantly share code, notes, and snippets.

View MohamedFawzy's full-sized avatar
:electron:

Mohamed Fawzy MohamedFawzy

:electron:
  • Noon
  • Dubai
View GitHub Profile
@MohamedFawzy
MohamedFawzy / gist:a184ba9ae3cf2405b91a
Created May 1, 2015 16:08
Decision tree pseudocode
ID3 Pseudocode
id3(examples, attributes)
'''
examples are the training examples. attributes is a list of
attributes that may be tested by the learned decison tree. Returns
a tree that correctly classifies the given examples. Assume that
the targetAttribute, which is the attribute whose value is to be
predicted by the tree, is a class variable.
'''
# input
# values stored in array v
# wighets stored in array wt
#length of array n
# knapsack capcity stored in w
#A naive recursive implementation of 0-1 Knapsack Problem
# Returns the maximum value that can be put in a knapsack of
# capacity W
def knapSack(w, wt, v, n):
#Dynamic Programming based Python Program for 0-1 Knapsack problem
# Returns the maximum value that can be put in a knapsack of capacity W
def knapSack(W, wt, val, n):
K = [[0 for x in range(W+1)] for x in range(n+1)]
#build table k[][] in bottom up manner
@MohamedFawzy
MohamedFawzy / node-and-npm-in-30-seconds.sh
Created March 22, 2018 10:48 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@MohamedFawzy
MohamedFawzy / greeting.zep
Created May 8, 2018 12:54
hello world simple extension using zephir lang
namespace HelloWorld;
class Greeting
{
public static function say()
{
echo "Hello World!";
}
}
@MohamedFawzy
MohamedFawzy / zephir_helloworld.php
Created May 8, 2018 13:11
zephir helloworld api frm php
<?php
echo HelloWorld\Greeting::say()."\n";
wget -P ~/.local/share/fonts https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/JetBrainsMono.zip \
&& cd ~/.local/share/fonts \
&& unzip JetBrainsMono.zip \
&& rm JetBrainsMono.zip \
&& fc-cache -fv