Skip to content

Instantly share code, notes, and snippets.

View Taremeh's full-sized avatar
🎓
Studying

Tarek Taremeh

🎓
Studying
View GitHub Profile
# read davids results
import json
import pandas as pd
import os
def compute_best_epochs_david(directory='./trials', objective="max", folds=8):
# Get a list of all Excel files in the directory
files = [file for file in os.listdir(directory) if file.endswith('.json')]
@Taremeh
Taremeh / results_collector.py
Created August 28, 2023 16:54
results_collector.py
import os
import shutil
import argparse
def main(source_folder, destination_folder):
# Create the destination folder if it doesn't exist
if not os.path.exists(destination_folder):
os.makedirs(destination_folder)
# Traverse the source folder and its subdirectories
@Taremeh
Taremeh / mutual_recursion_is_even_is_odd.py
Last active October 5, 2022 14:22
Mutual Recursion Example
# Sources:
# http://www.idc-online.com/technical_references/pdfs/information_technology/Mutual_Recursion_in_Python.pdf
# https://library.oapen.org/handle/20.500.12657/26092
def is_even(n):
if n == 0:
return True
else:
return is_odd(n-1)
@Taremeh
Taremeh / generate_code_images.ipynb
Last active July 18, 2022 16:47
Automatically create Images of Code Snippets using Selenium + Carbon
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Taremeh
Taremeh / count_recursions.py
Last active June 27, 2022 18:48
Python function to detect and count recursive functions using Abstract Syntax Trees (AST). Detects recursive calls in function return statements and function bodies. Also detects mutual recursion up to 2nd degree (e.g. is_even calling is_odd calling is_even and so on)
# helper function to identify recursive functions
def count_recursions(code: str) -> int:
self_recursion_functions = set()
mutual_recursion_candidates = {}
mutual_recursion_functions = set()
nodes = ast.parse(code)
function_nodes = []
# get all function nodes
for node in nodes.body:
import math
import time
import asyncio
from datetime import datetime
import websockets # from websockets import WebSocketServer, WebSocketServerProtocol, ConnectionClosedError, ConnectionClosedOK
from functools import partial
import json
from response_object import ResponseObject
import redis
@Taremeh
Taremeh / db-transfer-parser.php
Created February 4, 2017 18:59
One-Time Retrieve Parser (Just for experimental purpose)
<?php
/* ONE-TIME SCRIPT TO RETRIEVE MUSIC PIECE INFORMATIONS FROM PETRUCCI-DB */
/* DEV: Tarek Alakmeh, Dec 2016 */
/* ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
! ! ! ! ! ATTENTION: ! ! ! ! ! !
! ! This Code isn't made for ! !
! ! production: Just experi- ! !
! ! mental purpose! Thx :) ! ! !