Skip to content

Instantly share code, notes, and snippets.

@RubaXa
RubaXa / youtube-queue.js
Last active September 6, 2024 07:14
JavaScript Snippet for Youtube Subscriptions that automatically adds clips to the Player (сс https://t.me/musicisalreadytaken)
(async () => {
const $ = (s, e = document) => e.querySelector(s);
const $$ = (s, e = document) => e.querySelectorAll(s);
const pause = (ms) => new Promise(r => setTimeout(r, ms));
let videos = [...$$('#contents ytd-expanded-shelf-contents-renderer').values()];
if (!videos.length) {
videos = [...$$('#contents.ytd-rich-grid-renderer .ytd-rich-grid-renderer').values()];
}
async handler(argv, {console, describe, options, style}) {
// Print command description
console.important(describe);
// Prompt user for option or use default
const value = await console.cli.require(options.val);
// Print 'value' with style and color
console.log('value:', style.bold.cyan(value), style.gray(argv.val));
}
@RubaXa
RubaXa / cli.test.ts
Created May 30, 2021 12:21
CLI: Тестовая команда
import {createCommand} from '@mail-core/cli';
export const test = createCommand({
name: 'test',
describe: 'Тестовая команда',
options: {
val: {
desc: 'Any value',
type: 'string',
@RubaXa
RubaXa / global.ts
Last active June 3, 2020 19:46
globalThis globalLocation &
export const noop = () => {};
export const nativeGlobalThis = (0
|| typeof globalThis === 'object' && globalThis
|| typeof window === 'object' && window
|| typeof global === 'object' && global
|| {}
) as Window;
export const globalLocation = nativeGlobalThis.location || {
package main
import (
"fmt"
"log"
"github.com/gothing/draft"
"github.com/gothing/draft-demo/auth"
)
// InitEndpointScheme - инициализация описания «конца»
func (a *AuthLogin) InitEndpointScheme(s *draft.Scheme) {
// Проект, которому принадлежит «конец»
s.Project("auth")
// Метод доступен всем
s.Access(draft.Access.All)
// Базовый метод для всех кейсов
s.Method(draft.Method.POST)
// AuthLoginResponse — ответ на запрос
type AuthLoginResponse struct {
// инлайн комментарий с наследованием родительского
UserID types.UserID `comment:"{super}, авторизованного пользователя"`
}
package types
type Login string
func (v Login) TypeDescription() string {
return "Login пользователя (он же email, телефон или соц. аккаунт)"
}
func GenLogin() Login {
return "fast.test@mail.ru"
type Key = string;
type Val = string | number;
type KeyValue<
K extends Key,
P extends Key, // Дополнительные поля (!)
V extends Val,
> = (
& Record<K, V>
& Record<P, any>
);
type Key = string;
type Val = string | number;
type KeyValue<K extends Key, V extends Val> = {
[X in K]: V;
}
type CompostedObject<KEY extends Key, T extends KeyValue<KEY, Val>[]> =
FlattenObject<
ToIntersect<
{
[K in keyof T]: T[K] extends KeyValue<KEY, Val>