Skip to content

Instantly share code, notes, and snippets.

@cheadrian
cheadrian / CustomScrollView.js
Last active December 14, 2023 12:10
Custom scroll view indicator with Reanimated and Gesture
/*
* Check the Snack demo here:
* https://snack.expo.dev/@cheadrian/custom-scroll-view-indicator-with-reanimated-and-gesture
* Article with gif and features:
* https://che-adrian.medium.com/b78b238067b3?source=friends_link&sk=66df3163984fbcacbf9f7f4193b92e25
*/
import { useEffect, useRef, useState } from 'react';
import { View, StyleSheet } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
@cheadrian
cheadrian / edge_detection_compare_adjust.py
Created December 10, 2023 22:10
Adaptive Threshold, Sobel, Morph Close comparison with Matplotlib sliders
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
def sobel_edge_detector(img, threshold=50):
grad_x = cv.Sobel(img, cv.CV_64F, 1, 0)
grad_y = cv.Sobel(img, cv.CV_64F, 0, 1)
grad = np.sqrt(grad_x**2 + grad_y**2)
grad_norm = (grad * 255 / grad.max()).astype(np.uint8)
@cheadrian
cheadrian / !README.md
Last active December 14, 2023 23:25
AliExpress Merge Boss Bot - OpenCV, UiAutomator2

AliExpress Merge Boss Bot

Overview

This repository contains a Python script for an automation bot designed to interact with the Merge Boss game. The bot uses the uiautomator2 library and requires specific dependencies to be installed.

To run this I recommend you first to make it running on PC in order to modify the position parameters, but if you have an display with similar resolution 1080 x 2400 or aspect ratio it should work by default, so you can setup directly using Termux on your Android device.

Check this article to see demo gifs and images.

@cheadrian
cheadrian / !Readme.md
Last active February 26, 2024 14:05
Hardware PWM FAN control for Raspberry Pi

This is using https://pypi.org/project/rpi-hardware-pwm/ Python library in order to generate an PWM signal using integrated Raspberry Pi hardware PWM driver to control the fan speed.

⚠️ If you are using Raspberry Pi 5, set RPI_5 to True!

sudo pip3 install rpi-hardware-pwm

Make sure you connect the control port of the fan to the pin 12. You can also use pin 35, but change PWM_CHANNEL to 1.

Inside the /boot/config.txt you should have set dtoverlay=pwm-2chan

import numpy as np
from collections import namedtuple, deque
from itertools import count
import random, datetime, os, copy, glob, math, time, asyncio, base64, shutil
import cv2
import gym, ray
from gym import Env, spaces
from gym.spaces import Box
@cheadrian
cheadrian / #1. README.md
Last active March 27, 2023 18:24
Node-RED chatbots using RedBot, WhatsApp Link, ChatGPT, Dall-e 2, Email

These are the flows witch you can import into your Node-RED.

Contains OpenAI API examples for ChatGPT and Dall-e 2 combined with chat platforms, like Messenger, Whatsapp Business, Whatsapp Personal and Telegram.

There's also an example with email conversation.

You can find the list of articles which you can use with these files on Medium, here.

@cheadrian
cheadrian / FillRatioPDF.py
Created February 14, 2023 08:58
PDF page fill ration counter, drag and drop, GUI Tkinter
import fitz
import tkinter as tk
from tkinter import ttk
from tkinter import *
from tkinter import filedialog
from tkinterdnd2 import DND_FILES, TkinterDnD
def on_drop(file_path):
# Split multiple files:
paths = file_path.split(' ')
@cheadrian
cheadrian / !Huawei Ads and Tracking Blocking.md
Last active December 5, 2023 05:28
Adaway Huawei Blocklist for Ads, Tracking, Metrics, Gspace
@cheadrian
cheadrian / Chrome Extension Manifest V3 Firebase Javascript.md
Last active March 19, 2024 07:30
Insert Firebase inside website using Chrome Extension with Manifest V3. Web Version 9 CDN modular Firebase Firestore local JS.
@cheadrian
cheadrian / 1. Manifest V3 Firebase Chrome.md
Last active July 15, 2023 21:13
Insert Firebase functions inside website using Chrome Extension. Web Version 9 CDN modular Firebase Firestore.