Skip to content

Instantly share code, notes, and snippets.

View mahi424's full-sized avatar

Mahaveer Chouhan mahi424

View GitHub Profile
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <port_number>"
exit 1
fi
PORT=$1
PID=$(lsof -t -i:$PORT)

in bark/generation.py

checkpoint = torch.load(ckpt_path, map_location=device, weights_only=False)
import os
os.environ["SUNO_OFFLOAD_CPU"] = "True"

🚀 Aria2 + AriaNg Mac Setup Guide

Aria2 is a lightweight, powerful download utility. AriaNg is a modern web frontend for Aria2, providing a clean UI for managing downloads.


1. Install Aria2

Open Terminal and run:

import torch
import torchaudio as ta
from chatterbox.tts import ChatterboxTTS
# Detect device (Mac with M1/M2/M3/M4)
# Note: MPS requires macOS 14+ for FFT operations used in this model
# Using CPU for compatibility with older macOS versions
device = "cpu"
map_location = torch.device(device)
print(f"Using device: {device} (CPU forced for FFT compatibility)")

Using Snowflake ID (Twitter's ID Generation Algorithm) If you want a more structured approach, you can use Twitter's Snowflake algorithm, which generates time-based unique IDs.

You can use the Leaf-Snowflake library:

<dependency>
    <groupId>com.sankuai.inf.leaf</groupId>
    <artifactId>leaf-core</artifactId>
 1.0.2
const { Connection, Keypair, Transaction, SystemProgram, sendAndConfirmTransaction, PublicKey } = require('@solana/web3.js');
const { createMemoInstruction } = require('@solana/spl-memo');
const bs58 = require('bs58').default;
// Network configuration
const NETWORK_URLS = {
mainnet: 'https://api.mainnet-beta.solana.com',
devnet: 'https://api.devnet.solana.com',
testnet: 'https://api.testnet.solana.com'
};
@mahi424
mahi424 / generate-authenticator-code.js
Created January 22, 2025 05:46
generate-authenticator-code.js
const crypto = require("crypto");
/**
* Generate a time-based OTP (similar to Google Authenticator).
*
* @param {string} userId - Unique user ID.
* @param {string} secretKey - A shared secret key (keep it secure).
* @param {number} interval - Validity period of the OTP in seconds (default is 60 seconds).
* @returns {string} A 6-digit OTP.
*/
create table pacts.events like stage.events;
create table pacts.oms like stage.oms;
create table pacts.tms like stage.tms;
insert into pacts.oms select * from stage.oms_order;
class Heap {
s = []
constructor() {
}
insert(item) {
this.s.push(item); // Add item to the end of the heap
let i = this.s.length - 1; // Index of the newly added item
console.log({ i, heap: this.s });