Skip to content

Instantly share code, notes, and snippets.

View senior-sigan's full-sized avatar

Ilya Siganov senior-sigan

View GitHub Profile
@senior-sigan
senior-sigan / main.cpp
Created April 9, 2024 18:10
Wave simulation
#include <raylib.h>
#include <stdlib.h>
#include <vector>
#include <cmath>
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
const float pi = 3.14159265358979;
@senior-sigan
senior-sigan / tfmini.py
Created December 13, 2023 13:28
TFmini lidar
'''A driver for Benewake TFMini time-of-flight distance sensor
see: https://cdn.sparkfun.com/assets/1/4/2/1/9/TFmini_Plus_A02_Product_Manual_EN.pdf
see: https://www.arduino.cc/reference/en/libraries/tfmini/
Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 Byte8
0x59 0x59 Dist_L Dist_H Strength_L Strength_H Temp_L Temp_H Checksum
Byte0 0x59, frame header, same for each frame
Byte1 0x59, frame header, same for each frame
@senior-sigan
senior-sigan / yt2spt.py
Created November 21, 2023 18:23
Converts youtube playlist into spotify
import json
import requests
import spotipy
from spotipy.oauth2 import SpotifyOAuth
SPOTIFY_SCOPE = 'playlist-read-collaborative playlist-modify-private playlist-modify-public playlist-read-private'
YT_API_KEY = '??'
SPOTIFY_CLIENT_ID = '??'
SPOTIFY_SECRET = '??'
@senior-sigan
senior-sigan / tk_inter_gif.py
Last active May 6, 2023 20:08
Play gif animation with python tkinter
from tkinter import *
from PIL import Image, ImageTk
def get_gif_frames(path, speed=33):
img = Image.open(path)
gif_speed = img.info.get('duration', 0) or speed
frames = []
for i in range(img.n_frames):
img.seek(i)
@senior-sigan
senior-sigan / maven_bulk_deploy.py
Created March 20, 2023 14:24
Script to build maven deploy:deploy-file commands to upload local m2 repository to a remote gitlab/github maven package registry
"""
Deploys local maven repository to a remote one.
Requires python 3.x and Maven 3.2.x and higher (lower versions of Maven might work in certain setups,
but have issues with SNI).
"""
import os
import os.path as osp
import argparse
from typing import Dict, List, Union
/**
* Async function to wait for true-ish result from `fn`.
* Usefull if you are waiting for a global value to be set.
* For example: you connect dynamic scipt and wait it to be initialized.
*/
export function waitFor<T>(
fn: () => T | undefined | null,
timeout = 100, // milliseconds
maxRetries = 10,
signal?: AbortSignal,
@senior-sigan
senior-sigan / index.html
Created January 19, 2023 14:11
Omsky Gamedev about timers, tweens
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<canvas width="600" height="400"></canvas>
@senior-sigan
senior-sigan / Makefile
Last active November 16, 2022 14:21
Shared memory demo
CC = clang
CFLAGS = -pedantic -pedantic-errors -Wall -Werror -Wextra
LDFLAGS =
.PHONY: all
all: build_sender build_receiver
./sender /shmem1
./receiver /shmem1
.PHONY: build_sender
@senior-sigan
senior-sigan / drop_duplicates.py
Created February 9, 2021 15:49
Find image duplicates in the directory
import numpy as np
from PIL import Image
import argparse
import os
from tqdm import tqdm
from glob import glob
import json
from multiprocessing import Pool
# pip install numpy pillow tqdm
@senior-sigan
senior-sigan / .clang-format
Last active September 21, 2020 17:18
C++ code style linting and autoformat: Google style with snake_case for functions and methods. Without suffixes and prefixes.
# Run manually to reformat a file:
# clang-format -i --style=file <file>
BasedOnStyle: Google
ColumnLimit: 100
UseTab: Never
SpaceAfterTemplateKeyword: false
AllowShortFunctionsOnASingleLine: Empty
DerivePointerAlignment: false
PointerAlignment: Left