Skip to content

Instantly share code, notes, and snippets.

View qqwqqw689's full-sized avatar
:octocat:

qqwqqw689

:octocat:
  • China
View GitHub Profile
@qqwqqw689
qqwqqw689 / file.md
Created July 13, 2024 14:34
Number of Binary Trees for given Preorder Sequence length.
@qqwqqw689
qqwqqw689 / Producer_Consumer.cpp
Created July 19, 2024 01:39
Producer-Consumer-Problem.
#include <iostream> // Includes the standard I/O library
#include <queue> // Includes the queue library for queue operations
#include <thread> // Includes the thread library for threading operations
#include <mutex> // Includes the mutex library for synchronization
#include <condition_variable> // Includes the condition_variable library for thread communication
std::mutex mtx; // Declares a mutex for critical section management
std::condition_variable cond_var; // Declares a condition variable for blocking and waking threads
std::queue<int> buffer; // Declares a queue to act as the buffer
const unsigned int MAX_BUFFER_SIZE = 10; // Sets the maximum size of the buffer
@qqwqqw689
qqwqqw689 / screenshot.md
Last active September 7, 2024 06:26
Window Screen Capture Using Pywin32.
import win32gui, win32ui, win32con

def test_get_screenshot():
    # define your monitor width and height
    w, h = 1920, 1080

    # for now we will set hwnd to None to capture the primary monitor
    #hwnd = win32gui.FindWindow(None, window_name)
    hwnd = None
@qqwqqw689
qqwqqw689 / I2C_LCD_driver.py
Created September 12, 2024 16:22
I2C_LCD_driver python
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Original code found at:
# https://gist.github.com/DenisFromHR/cc863375a6e19dce359d
"""
Compiled, mashed and generally mutilated 2014-2015 by Denis Pleic
Made available under GNU GENERAL PUBLIC LICENSE
@qqwqqw689
qqwqqw689 / prng.c
Created September 14, 2024 04:42
Portable pseudorandom number generator in c.
/* Portable pseudorandom number generator
* Based on a 24,55 Fibonacci generator, using 55/503 rejection
* c.f.- TAoCP, 3.2.2(7), for j=24,k=55,m=2^64
*
* THIS FILE IS PUBLIC DOMAIN CODE.
*
* Written by Bob Adolf.
* Attribution is appreciated but by no means legally required.
*
* This function is sufficient for most non-crypto applications.