Skip to content

Instantly share code, notes, and snippets.

View fiefdx's full-sized avatar

Haitao Yang fiefdx

View GitHub Profile
@fiefdx
fiefdx / ftp-server.py
Created April 11, 2025 04:56 — forked from sonpython/ftp-server.py
Simple FTP server in Micropython
#
# Small ftp server for ESP8266 ans ESP32, Pico W Micropython
#
# Based on the work of chrisgp - Christopher Popp and pfalcon - Paul Sokolovsky
#
# The server accepts passive mode only.
# It runs in foreground and quits, when it receives a quit command
# Start the server with:
#
# import ftp
import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"
@fiefdx
fiefdx / aesecb.py
Created June 20, 2024 08:05 — forked from sachadee/aesecb.py
Python AES ECB Encryption
import base64
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad,unpad
#AES ECB mode without IV
data = 'I love Medium'
key = 'AAAAAAAAAAAAAAAA' #Must Be 16 char for AES128
def encrypt(raw):
@fiefdx
fiefdx / dual_i2s_player.py
Created June 18, 2024 18:05 — forked from todbot/dual_i2s_player.py
Demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico in CircuitPython
# dual_i2s_player.py -- demonstrate using two I2S stereo DACs at once on RP2040 / Raspberry Pi Pico
# 19 May 2023 - @todbot / Tod Kurt
# video of this code: https://www.youtube.com/watch?v=CgqECxhqJEo
import time, board, audiocore, audiobusio
# qtpy rp2040 pins
# in this case, board.* names just match silkscreen, don't indicate functionality
lck1_pin, bck1_pin, dat1_pin = board.MISO, board.MOSI, board.SCK
lck2_pin, bck2_pin, dat2_pin = board.SCL, board.SDA, board.TX
@fiefdx
fiefdx / README.md
Created June 5, 2024 11:32 — forked from amroamroamro/README.md
[Python] Fitting plane/surface to a set of data points

Python version of the MATLAB code in this Stack Overflow post: https://stackoverflow.com/a/18648210/97160

The example shows how to determine the best-fit plane/surface (1st or higher order polynomial) over a set of three-dimensional points.

Implemented in Python + NumPy + SciPy + matplotlib.

quadratic_surface

@fiefdx
fiefdx / cuda_11.8_installation_on_Ubuntu_22.04
Created June 5, 2024 11:14 — forked from MihailCosmin/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@fiefdx
fiefdx / install_cuda_11_ubuntu_2004.md
Created March 18, 2024 13:34 — forked from ksopyla/install_cuda_11_ubuntu_2004.md
How to install CUDA toolkit 11 at ubuntu 20.04

Step by step instruction how to install CUDA 11 Ubuntu 20.04

NVidia Ubuntu 20.04 repository for CUDA 11

If you need CUDA Tolkit 11 with nvcc, other tools and libraries you can install it from NVIDIA Ubunutu 20.04 repository.

Add Ubuntu 20.04 repository

@fiefdx
fiefdx / rpi-configure-locales.md
Created June 29, 2023 14:37 — forked from tomysmile/rpi-configure-locales.md
Raspberry Pi: Reconfigure Locales

Reconfigure your RPi Locales

First you need to install the locales you want:

sudo dpkg-reconfigure locales

Then refresh your current environment:

@fiefdx
fiefdx / embed_vtk_qt5.py
Created March 31, 2023 01:44 — forked from paskino/embed_vtk_qt5.py
Minimal working example of VTK embedding in PyQt with Qt5
#!/usr/bin/env python
import sys
import vtk
from PyQt5 import QtCore, QtWidgets
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent = None):
@fiefdx
fiefdx / ffmpeg-commands.sh
Created March 2, 2023 07:55 — forked from 44213/ffmpeg-commands.sh
ffmpeg commands.
# To extract the sound from a video and save it as MP3:
ffmpeg -i <video.mp4> -vn <sound>.mp3
# To convert frames from a video or GIF into individual numbered images:
ffmpeg -i <video.mpg|video.gif> <frame_%d.png>
# To combine numbered images (frame_1.jpg, frame_2.jpg, etc) into a video or GIF:
ffmpeg -i <frame_%d.jpg> -f image2 <video.mpg|video.gif>
# To quickly extract a single frame from a video at time mm:ss and save it as a 128x128 resolution image: