Skip to content

Instantly share code, notes, and snippets.

View aleksandergurin's full-sized avatar

Oleksandr Gurin aleksandergurin

View GitHub Profile
@aleksandergurin
aleksandergurin / react-scrolling-example.css
Created September 28, 2023 16:53
React scrolling example (CSS)
.wrapper {
width: 200px;
height: 100px;
overflow-y: scroll;
}
.item {
border: 1px solid lightblue;
background: lightsalmon;
height: 18px;
@aleksandergurin
aleksandergurin / react-scrolling-example.js
Created September 28, 2023 16:52
React scrolling example
import {useEffect, useMemo, useRef, useState} from "react"
import './App.css'
const NUM_OF_ITEMS = 10
function App() {
const [selected, setSelected] = useState(0)
Disable your internet connection and go to your URL.
Browser will shouw you a connection error, but you will be able to specify
"Always open this site in...".
@aleksandergurin
aleksandergurin / howto-python.md
Last active May 15, 2020 15:21
Miscellaneous python howto

Howto

Generate fake data with Faker

Install

pip install faker

Basic usage

@aleksandergurin
aleksandergurin / howto-postgres.md
Last active May 8, 2020 10:20
HOWTO PostgreSQL

Howto for PostgreSQL

Simple many-to-one model

CREATE TABLE artists (
    artist_id serial PRIMARY KEY,
    name text
);
@aleksandergurin
aleksandergurin / django-orm-recipes.md
Last active April 14, 2020 14:02
Django ORM recipes

Django ORM recipes

Miscellaneous

Enable debug logging

import logging

logger = logging.getLogger('django.db.backends')
logger.setLevel(logging.DEBUG)
import av
def extract_first_frame():
it = iter(av.open('../video.mp4').decode(video=0))
video_frame = next(it).reformat(width=640, height=480, format='rgb24') # av.video.frame.VideoFrame instance
# From VideoFrame you can obtain PIL.Image, numpy array etc.
rgb24_image = video_frame.to_image() # PIL.Image instance
rgb24_image.show() # show image