Skip to content

Instantly share code, notes, and snippets.

@NickyAlan
NickyAlan / video_paint.py
Created January 30, 2024 16:52
copy image to clipboard then paste to paint each frame
import cv2
import numpy as np
from PIL import Image
from io import BytesIO
import pyautogui as pg
from time import sleep
import win32clipboard as w32c
VIDEO_PATH = "mn.mp4"
cap = cv2.VideoCapture(VIDEO_PATH)
@NickyAlan
NickyAlan / mp4explorer.py
Created November 27, 2023 14:08
play video in file explorer
# Might ruin your SSD
import cv2
import time
import numpy as np
VIDEO_PATH = "video.mp4"
FOLDER = "playground" # folder that play video, create this folder for sure!
ROWS, COLS = 7, 4 # number of images
cap = cv2.VideoCapture(VIDEO_PATH)
# pip install ttkbootstrap
import ttkbootstrap as ttk
FONT = ('calibri', 18)
class App(ttk.Window) :
def __init__(self) :
super().__init__(themename='darkly')
self.title('app')
self.geometry('600x300')
# colab version : https://colab.research.google.com/drive/1BgPchQi2KjQ9Bae2lAJx6SRaLu0sO9ye?usp=sharing
import pandas as pd
#parameters
columnNames = ['smoking', 'lbw']
a00 = [0,0]
a01 = [0,1]
a10 = [1,0]
a11 = [1,1]
NO_STUDENT = int(input('number of student : '))
def write_file(no_student=NO_STUDENT):
with open('std.txt', 'w') as file :
for student in range(no_student) :
fname,lname, age = input(f'student {student+1} : ').split()
file.writelines(f'{fname} {lname} {age}\n')
print(f' -- add : {fname} {lname} {age}')
def plot_decision_boundaries(clusterer, X, resolution=500, show_centroids=True,
show_xlabels=True, show_ylabels=True):
mins = X.min(axis=0) - 0.1
maxs = X.max(axis=0) + 0.1
xx, yy = np.meshgrid(np.linspace(mins[0], maxs[0], resolution),
np.linspace(mins[1], maxs[1], resolution))
Z = clusterer.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
#cmap
def plot_boundaries(model,xlabel,ylabel,title,figsize):
h = .02 # step size in the mesh
x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
np.arange(y_min, y_max, h))
plt.figure(figsize=figsize)
Z = model.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
# 0001 - 9999
num = []
for i in range(100,10000):
n = str(i)
if len(n) != 4 :
n = '0' + n
if n[0] != n[1] and n[0] != n[2] and n[0] != n[3] and n[1] != n[2] and n[1] != n[3] and n[2] != n[3] :
num.append(n)
<div class="fromspeech">
<div class="from1">
<div id="div11">{{speech}}</div>
<button id="button1" onclick="CopyToClipboard('div11')">Click to copy</button>
</div>
<div class="from1">
<div id="div12">{{result}}</div>
<button id="button2" onclick="CopyToClipboard('div12')">Click to copy</button>
</div>
</div>
crete media folder with piority same as static folder
[settings.py]
import os
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
[urls.py] at main project
from django.conf import settings
from django.conf.urls.static import static