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
def cache_block_range(word_addresses, m, n, tag_width, address_width, K): | |
block_size = 2 ** m | |
index_mask = (1 << n) - 1 | |
tag_mask = (1 << tag_width) - 1 | |
# Cache: Dictionary of lists for each set (index), each with up to K ways | |
cache = {i: [{'tag': None} for _ in range(K)] for i in range(1 << n)} | |
# LRU tracking: LRU[index] keeps track of LRU order for K ways in that index | |
LRU = [[j for j in range(K)] for _ in range(1 << n)] |
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
def cache_block_range(word_addresses, m, n, tag_width, address_width): | |
block_size = 2 ** m | |
index_mask = (1 << n) - 1 | |
tag_mask = (1 << tag_width) - 1 | |
# Cache structure: list of dictionaries to hold index, tag, and data range | |
cache = [] | |
mv_count, mt_count, hit_count = 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
const STAGES = { IF: 1, ID: 2, EX: 3, MEM: 4, WB: 5 }; | |
const removeParentheses = (str) => str.replace(/.*\(|\)/g, ""); | |
const printRed = (text) => process.stdout.write(`\x1b[31m${text}\x1b[0m`); | |
function detectDataHazards(instructions) { | |
let destStage; | |
process.stdout.write("\n\n---------------------TEST----------------------\n"); | |
const hazards = instructions.map(() => Array(3).fill(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
const YOUR_TEXT = "كتاب العين للخليل بن أحمد الفراهيدي" | |
function arabicToHebrew(str) { | |
const mapping = { | |
"ا": "א", | |
"ب": "ב", | |
"ج": "ג'", | |
"د": "ד", | |
"ذ": "ד'", | |
"ه": "ה", |
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
// ==UserScript== | |
// @name IPA for translate.google | |
// @namespace https://gist.github.com/adielBm/21762fe5e964071cb820a0c46896da34 | |
// @version 2024-06-27 | |
// @description Convert phonetic transcription to IPA on Google Translate | |
// @author adielBm | |
// @match https://translate.google.com/* | |
// @grant none | |
// @updateURL https://gist.githubusercontent.com/adielBm/21762fe5e964071cb820a0c46896da34/raw | |
// @downloadURL https://gist.githubusercontent.com/adielBm/21762fe5e964071cb820a0c46896da34/raw |
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
import { writeFile, readFile } from 'node:fs'; | |
import fetch from "node-fetch"; | |
async function getCoordinatesByAddress(address) { | |
const api = `https://maps.googleapis.com/maps/api/geocode/json?address=${address}&key=MY_API_KEY`; | |
const response = await fetch(api); | |
const data = await response.json(); | |
return data; | |
} |