Skip to content

Instantly share code, notes, and snippets.

View hmelenok's full-sized avatar
🙊
Coding

Mykyta Khmel hmelenok

🙊
Coding
View GitHub Profile
@hmelenok
hmelenok / html_to_csv.py
Created October 30, 2023 19:01
Google Takeout YouTube watched video HTML to CSV script (exports to: Products,Video title,Video Link,Channel Name,Channel Link,Date)
from bs4 import BeautifulSoup
import csv
# Load the content from the HTML file
with open('input.html', 'r', encoding='utf-8') as file:
content = file.read()
soup = BeautifulSoup(content, 'lxml')
# Prepare a list to hold the extracted data
@hmelenok
hmelenok / youtube_categories.py
Created October 30, 2023 18:58
Populate Youtube category by videos id's
import requests
import json
API_KEY = 'YOUR_YOUTUBE_API_KEY'
VIDEO_IDS = ['1Ds2G7lcrxA', 'AnotherVideoID', ...] # Replace with your list of video IDs
BASE_URL = "https://www.googleapis.com/youtube/v3/videos"
def get_video_details(video_id):
params = {
'part': 'snippet',
@hmelenok
hmelenok / remove-colors-bg-in-dom.js
Created December 16, 2022 10:19
remove colors from bg of elements
Array.from(document.querySelectorAll('.edit-detailed-section *')).filter(el => {
if(el.style["background-color"] === 'rgb(255, 255, 255)' || el.style["background-color"] === 'white'){
el.style["background-color"] = '';
}
});
//Remove any color
Array.from(document.querySelectorAll('.edit-detailed-section *')).filter(el => {
if(el.style["background-color"]){
@hmelenok
hmelenok / useVisibilityChange.tsx
Created May 10, 2022 07:45
visibilitychange with react useSyncExternalStore
export function useVisibilityChange(serverFallback: boolean) {
const getServerSnapshot = () => serverFallback;
const [getSnapshot, subscribe] = useMemo(() => {
return [
() => document.visibilityState === 'visible',
(notify: () => void) => {
window.addEventListener('visibilitychange', notify);
return () => {
window.removeEventListener('visibilitychange', notify);
@hmelenok
hmelenok / de-glossary.json
Created January 11, 2022 10:55
Example of translation file
{
//Simple key->translation
"search": "Suchen",
"noResults": "Keine Suchergebnisse gefunden",
"publish": "Veröffentlichen",
"cancel": "Abbrechen",
"save": "Speichern",
//nested key->key->translation
"fileTypes": {
"document": "Dokument",
@hmelenok
hmelenok / Component.tsx
Created January 11, 2022 10:44
i18n in React usage
import {useTranslation} from 'react-i18next';
const Index: FC = () => {
const {t} = useTranslation();
return (
<MainLayout pageTitle={t(`app-1.common.pageTitle`)}>
{t(`app-1.common.pageTitle`)}
</MainLayout>
);
}
@hmelenok
hmelenok / i18n.ts
Created January 11, 2022 10:43
React example of app library initialization
import i18NextLib from 'i18next';
import {initReactI18next} from 'react-i18next'; //To have a react context
import {resources} from 'dictionary-package/lib/bundles/app-1'; //reduce bundles if there is many
import {defaultInterpolation} from 'dictionary-package/lib/lib/helpers'; // day-to-day functions to format text
const i18next = i18NextLib.createInstance();
i18next.use(initReactI18next).init({
lng: 'en',
resources,
@hmelenok
hmelenok / crowdin.yml
Created January 11, 2022 10:41
Sync file structure with Crowdin
files:
- source: /src/resources/en/**/*.json
translation: /src/resources/%two_letters_code%/**/%original_file_name%
/**
* Now
*/
import Api from './api';
import {ContentApi} from './index';
Api.API_HOST = 'x';
Api.AUTH_TOKEN = 'y';
@hmelenok
hmelenok / upload.ts
Created August 25, 2021 07:39
Upload Uppy file
const taskId = ''; //TODO: get task if from prev mutaition
const raw = JSON.stringify({
filename: 'Screenshot 2021-08-20 at 12.06.13.png',
type: 'image/png',
});
const {key: uploadKey, uploadId} = await fetch('https://api.gsstaging.net/cpw/uppy/s3/multipart', {
method: 'POST',
headers: {
'x-cpw-task-id': taskId,