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
# Code by Farooq Karimi Zadeh <[email protected]> | |
# Under CC0 1.0 | |
from html.parser import HTMLParser | |
class MyParser(HTMLParser): | |
def handle_starttag(self, tag, attrs): | |
attrs = dict(attrs) | |
if tag == "img": | |
src = attrs["src"] if "src" in attrs else "" |
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 Customer: | |
account = Account() | |
name = "Far the chickenkiller" | |
... | |
class Account: | |
no = ... # some big integer | |
rials = 10000 # 1000 toman | |
dollars = 1.0 # one dollar only |
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
""" | |
Warshall algorithm | |
This calculates transitive closure for a given binary matrix | |
Author: Farooq Karimi Zadeh | |
Code is under CC0 1.0 | |
""" | |
from pprint import pprint | |
def pretty_print_matrix(matrix): |
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
// Code by Rust beginner, Farooq Karimi Zadeh | |
// Under CC0 1.0 | |
// Warning! Code might not be idiomatic | |
fn main() { | |
let mut bin_matrix = [ | |
[0, 1, 0, 0], | |
[1, 0, 1, 0], | |
[0, 0, 0, 1], | |
[0, 0, 0, 0] |
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
# By Farooq Karimi Zadeh under CC0. | |
import wave | |
import struct | |
from dataclasses import dataclass | |
from typing import List | |
@dataclass | |
class SoundClip16b: |
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
# Code by Farooq Karimi Zadeh under MIT/X11 | |
import random | |
from typing import List, Tuple | |
Fitness = float | |
class Chromosome: |
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 typing import List, Tuple | |
from pprint import pprint | |
import random | |
def empty_slots(board: List[List[int]]) -> List[Tuple[int, int]]: | |
result = [(x//8, x%8) for x in range(64)] | |
for i, row in enumerate(board): | |
for j, slot in enumerate(row): | |
if slot != 0: | |
for k in range(8): |
OlderNewer