This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/usr/local/bin/python3 | |
""" | |
Back-up PHP web projects and not include the modules or vendor directories, will put back up in same DIR as script' | |
* need TAR installed on machine | |
To run: $ python3 backup_projects.py | |
""" | |
from datetime import datetime | |
from pathlib import Path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Used in https://github.com/im4aLL/roolith-event | |
class Event { | |
private static $events = []; | |
public static function listen($name, $callback) { | |
self::$events[$name][] = $callback; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
TableEntry = namedtuple('Element', 'hash key value') | |
class HashTable(object): | |
DEFAULT_SIZE = 8 | |
EMPTY_VALUE = TableEntry(None, None, None) | |
DELETED_VALUE = TableEntry(None, None, None) | |
LOAD_FACTOR = 2 / 3 | |
MIN_FACTOR = 1 / 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, val): | |
self.val = val | |
self.leftChild = None | |
self.rightChild = None | |
def get(self): | |
return self.val | |
def set(self, val): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Hash Tables | |
Usage : | |
'python -i hashex.py' | |
The goal of a hash table is to map a keyword to a placeholder that contains the value you stored. | |
We will define 3 functions : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BinarySearchTree { | |
private $_root; | |
public function __construct() { | |
// setup sentinal node | |
$this->_root = new BinarySearchNode(null); | |
} | |
public function getRoot() { | |
return $this->hasNode() ? $this->_root->right : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create the key-value object | |
class KeyValue: | |
def __init__(self,key,value): | |
self.key=key | |
self.value=value | |
class HashTable: | |
#initiate an empty list that will store all key value pair based on the KeyValue object | |
def __init__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HashTable { | |
private $_array = array(); | |
private $_size = 10000; | |
public function __construct($size=0) { | |
$size = (int)$size; | |
if ($size > 0) { |
NewerOlder