Skip to content

Instantly share code, notes, and snippets.

View codepediair's full-sized avatar
🏠
Working from home

Mahdi codepediair

🏠
Working from home
View GitHub Profile
@codepediair
codepediair / textEditor.py
Created December 31, 2022 08:47
create a text editor with python and tkinter
# $ sudo apt-get install python3-tk
# Importing Required libraries & Modules
from tkinter import *
from tkinter import messagebox
from tkinter import filedialog
# Defining TextEditor Class
class TextEditor:
# Defining Constructor
@codepediair
codepediair / functionUseCase.c
Last active January 1, 2023 14:11
why we use functions
#include <stdio.h>
int isPrime(int n){
for (int i=2; i < n; i++){
if (n % i == 0){
return 0;
}
}
return 1;
}
@codepediair
codepediair / wikiSearchEngin.py
Created January 5, 2023 08:28
find articles in Wikipedia with python
from tkinter import *
import wikipedia
def get_data():
entry_value = entry.get()
answer.delete(1.0, END)
try:
answer_value = wikipedia.summary(entry_value)
answer.insert(INSERT, answer_value)
@codepediair
codepediair / simpleAi.py
Created January 8, 2023 07:26
simplest ai built with python
import random
greetings = ["Hello!", "What's up?!", "Howdy!", "Greetings!"]
goodbyes = ["Bye!", "Goodbye!", "See you later!", "See you soon!"]
keywords = ["music", "pet", "book", "game"]
responses = ["Music is so relaxing!", "Dogs are man's best friend!", "I know about a lot of books.", "I like to play video games."]
print(random.choice(greetings))
user = input("Say something (or type bye to quit): ")
from tkinter import *
import ctypes
import random
import tkinter
# For a sharper window
# ctypes.windll.shcore.SetProcessDpiAwareness(1)
# Setup
root = Tk()
import cv2
import numpy as np
from tkinter.filedialog import *
photo = askopenfilename()
img = cv2.imread(photo)
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
grey = cv2.medianBlur(grey, 5)
edges = cv2.adaptiveThreshold(grey, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 9)
@codepediair
codepediair / simpleBlockChain.py
Created February 20, 2023 14:24
create a simple block chain with mining and fetch
import datetime
import json
import hashlib
from flask import Flask, jsonify
class Blockchain:
def __init__(self):
self.chain = []
self.create_blockchain(proof=1, previous_hash='0')

deploy site to github pages

  1. run this command to regenerate the files
hugo
  1. go to github and create a repository whit this name

<user_name>.github.io/ for me codepediair.github.io/mysite

  1. and push all codes
@codepediair
codepediair / index.html
Created February 23, 2023 07:31
spoiler Text In Html, Css and JavaScript
<head>
<link rel="stylesheet" href="./main.css">
</head>
<body>
<div class="container" dir="rtl">
برنامه نویسی خوب کسی است که <span class="spoiler">بیشتر یاد میگیرد </span>
</div>
<script src="./script.js"></script>
</body>
@codepediair
codepediair / index.html
Created March 2, 2023 18:43
responsive grid page with bootstrap
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="./style.css">