Skip to content

Instantly share code, notes, and snippets.

View behnambm's full-sized avatar
:electron:
Focusing

Behnam behnambm

:electron:
Focusing
View GitHub Profile
// ---------------------------------------------------------------- 1. API contract
// POST https://api.bazaar-pay.ir/auth/v1/get-access-token/
// body: {"refresh_token": "<refresh>"}
// 200: {"access_token": "<new access>"}
// 401: refresh token is dead -> user must log in again
data class RefreshRequest(@SerializedName("refresh_token") val refreshToken: String)
data class RefreshResponse(@SerializedName("access_token") val accessToken: String)
interface AuthApi {
│ Error: error creating security group │
│ with arvan_security_group.terraform_security_group,
│ on main.tf line 104, in resource "arvan_security_group" "terraform_security_group":
| 104: resource "arvan_security_group" "terraform_security_group" {
│
│ json: cannot unmarshal bool into Go struct field SecurityGroup.data.readonly of type string
resource "arvan_security_group" "terraform_security_group" {
region = var.region
description = "Terraform-created security group"
name = "tf_security_group"
rules = [
{
direction = "ingress"
protocol = "icmp"
},
{
@behnambm
behnambm / tight-loop.go
Created April 13, 2025 19:37
A sample of tight loop in Go
package main
func main() {
counter := 0
for {
counter++
}
}
@behnambm
behnambm / ga-cpu-scheduling.py
Created May 7, 2024 19:10
GA CPU job scheduling
import random
# Define the number of jobs and their processing times
NUM_JOBS = 5
processing_times = [10, 6, 8, 7, 3] # Example processing times for each job
# Genetic Algorithm parameters
POPULATION_SIZE = 50
NUM_GENERATIONS = 100
CROSSOVER_RATE = 0.8
import math
import threading
import tkinter as tk
import numpy as np
from numpy import random
class TravelingSalesmanProblem:
def __init__(self, num_cities):
# Define the number of cities
@behnambm
behnambm / tsp-tabu.py
Created March 2, 2024 18:04
TSP-Tabu Search
import random
import numpy as np
# Define the distance matrix between cities
# In this example, we generate random distances for demonstration purposes
def generate_distance_matrix(num_cities):
distances = np.random.randint(10, 100, size=(num_cities, num_cities))
np.fill_diagonal(distances, 0) # Diagonal elements are zero
return distances