Skip to content

Instantly share code, notes, and snippets.

View alirezarpi's full-sized avatar
🎯
Focusing

Alireza Khalili alirezarpi

🎯
Focusing
View GitHub Profile
@aasmpro
aasmpro / bankers_algorithm.py
Last active April 10, 2023 03:58
Python implementation of Banker's algorithm, written in Python 3
def main():
processes = int(input("number of processes : "))
resources = int(input("number of resources : "))
max_resources = [int(i) for i in input("maximum resources : ").split()]
print("\n-- allocated resources for each process --")
currently_allocated = [[int(i) for i in input(f"process {j + 1} : ").split()] for j in range(processes)]
print("\n-- maximum resources for each process --")
max_need = [[int(i) for i in input(f"process {j + 1} : ").split()] for j in range(processes)]
@umrashrf
umrashrf / aws_ses.bash
Created July 26, 2016 19:05
Amazon AWS CLI - SES SEND EMAIL
sudo pip install awscli
aws configure
aws ses send-email \
--from "john@gmail.com" \
--destination "ToAddresses=mike@gmail.com" \
--message "Subject={Data=from ses,Charset=utf8},Body={Text={Data=ses says hi,Charset=utf8},Html={Data=,Charset=utf8}}"
@claymcleod
claymcleod / pycurses.py
Last active May 1, 2024 14:44
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 3, 2024 18:53
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kipanshi
kipanshi / gist:4007717
Created November 3, 2012 15:53
Django float format and intcomma optimization
import cProfile
from django.template.defaultfilters import floatformat as floatformat_django
from django.contrib.humanize.templatetags.humanize import intcomma as intcomma_django
num = 100000
float_num = 1 / 3.0
def floatformat(value, places=2):
@spikebike
spikebike / client.go
Created March 29, 2012 01:13
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)