Skip to content

Instantly share code, notes, and snippets.

View alexsanqp's full-sized avatar
💭
plus-minus

Oleksandr K. alexsanqp

💭
plus-minus
View GitHub Profile
@alexsanqp
alexsanqp / suno_api.py
Last active July 13, 2025 20:20
This script provides a simple, dependency-light Python client to interact directly with the unofficial Suno AI API. It allows you to programmatically generate music, poll for the completion status of your tracks, and download the final audio files. #russiaterroriststate #sunoai #sunoapi
import requests
import time
import os
import json
from typing import List, Dict, Any
from dotenv import load_dotenv
class ApiConfig:
BASE_URL = "https://studio-api.prod.suno.com"
GENERATE_ENDPOINT = "/api/generate/v2-web/"
export const memorizeFn = <T extends () => void>(fn: T, size = 5, duration = 0): any => {
const cache: Map<string, any> = new Map<string, any>();
if (duration) {
setInterval(() => cache.clear(), duration);
}
return (...args: any[]): any => {
const key: string = JSON.stringify(args);
if (!cache.has(key)) {
cache.set(key, (fn as any)(...args));
@alexsanqp
alexsanqp / run-outside-event-manager.service.ts
Last active April 25, 2019 12:52
Triggers an event listener outside the angular zone.
import { Inject, Injectable, NgZone } from '@angular/core';
import { EVENT_MANAGER_PLUGINS, EventManager } from '@angular/platform-browser';
export const RUN_OUTSIDE: string = '.run-outside';
/**
* @example
*
* @NgModule({
* // ...
@alexsanqp
alexsanqp / point.class.ts
Last active April 24, 2019 17:28
A point representing a location in (x,y) coordinate space, specified in integer precision.
/**
* A point representing a location in (x,y) coordinate space, specified in integer precision.
*/
export class Point {
/**
* The X coordinate of this Point.
* @default 0
*/
protected x: number;
@alexsanqp
alexsanqp / dimension.class.ts
Last active April 24, 2019 17:28
The Dimension class encapsulates the width and height of a component (in integer precision) in a single object.
/**
* The Dimension class encapsulates the width and height
* of a component (in integer precision) in a single object.
*/
export class Dimension {
/**
* The width dimension; negative values can be used.
* @default 0
*/
protected width: number;
@alexsanqp
alexsanqp / get-polygon-centroid.ts
Last active April 24, 2019 17:33
Polygon centroid - typescript or javascript
/**
* https://en.wikipedia.org/wiki/Centroid#Of_a_polygon
*/
public getPolygonCentroid(vertices: number[][]): { lat: number, lon: number } {
const centroid: { lat: number, lon: number } = { lat: 0, lon: 0 };
const vertexCount: number = vertices.length;
let area: number = 0;
let x0: number = 0; // Current vertex X
let y0: number = 0; // Current vertex Y