Skip to content

Instantly share code, notes, and snippets.

View hesan-aminiloo's full-sized avatar
🎯
Focusing

Hesan Aminiloo hesan-aminiloo

🎯
Focusing
  • Fidibo
  • Tehran - Iran
View GitHub Profile
const blob = new Blob([combinedBuffer], { type: mimeType });
const url = URL.createObjectURL(blob);
video.src = url;
@hesan-aminiloo
hesan-aminiloo / video-player.js
Created May 13, 2025 12:33
get video from indexed db an combine them
// Get a specific chunk
const getVideoChunk = async (chunkId) => {
try {
const db = await initDB();
return new Promise((resolve, reject) => {
const transaction = db.transaction(['chunks'], 'readonly');
const store = transaction.objectStore('chunks');
const request = store.get(chunkId);
@hesan-aminiloo
hesan-aminiloo / store-db.js
Created May 13, 2025 12:21
store video and metadata to db
const storeCompleteVideo = async (metadata, chunks) => {
try {
const db = await initDB();
return new Promise((resolve, reject) => {
const transaction = db.transaction(['metadata', 'chunks'], 'readwrite');
transaction.onerror = (event) => {
reject(event.target.error);
};
@hesan-aminiloo
hesan-aminiloo / db-init.js
Created May 13, 2025 12:17
init the database
let dbInstance = null;
// Initialize the database once and store the connection
const initDB = () => {
return new Promise((resolve, reject) => {
if (dbInstance) {
// Using existing database connection
resolve(dbInstance);
return;
}
const metadata = {
id: videoId,
title: videoFile.name,
mimeType: videoFile.type,
size: arrayBuffer.byteLength,
chunkCount: chunks.length,
dateAdded: new Date().toISOString()
};
@hesan-aminiloo
hesan-aminiloo / chunkfile.js
Created May 13, 2025 12:02
chunk video file
const arrayBuffer = await videoFile.arrayBuffer();
const chunkSize = 1024 * 1024; // 1MB chunks
const chunks = [];
let offset = 0;
while (offset < arrayBuffer.byteLength) {
const size = Math.min(chunkSize, arrayBuffer.byteLength - offset);
const chunk = arrayBuffer.slice(offset, offset + size);
chunks.push(chunk);
offset += size;
@hesan-aminiloo
hesan-aminiloo / App.tsx
Created May 10, 2025 09:43
Main memory game Application file
import './App.css'
import { Controls } from './components/Controls'
import { Lights } from './components/Lights'
import { Score } from './components/Score'
import { useGame } from './hooks/useGame'
function App() {
const {
blinkSeq,
isBlinking,
import { Colors } from "./colors";
import styles from "./JSExports.module.scss";
export const JSExports = () => {
return (
<div>
<p>
Used scss and css and JS to access these colors, kinda complicated but
useful AF
import variables from "./JSExports.module.scss";
export const Colors = variables;
@import './variables';
$primary-color: var(--primary-color);
$secondary-color: var(--secondary-color);
.boxes {
display: flex;
justify-content: space-around;
&__box {