Skip to content

Instantly share code, notes, and snippets.

View Wurushu's full-sized avatar
😆

Wurushu Wurushu

😆
  • Taiwan
View GitHub Profile
@Wurushu
Wurushu / curl_test.sh
Last active March 27, 2025 10:56
Test HTTP API with simultaneous request with CURL shell script or Apache Bench
#!/bin/bash
URL="http://localhost:8081"
FILE="test.mp3"
REQUEST_COUNT=$1
for i in $(seq 1 $REQUEST_COUNT); do
curl -X POST -F "file=@$FILE" "$URL" > "curl_response/output_$i.log" 2> "curl_response/error_$i.log" &
done
@Wurushu
Wurushu / react_no_re-render.tsx
Created February 27, 2025 07:55
React component prevent re-render with useRef, useCallback, useMemo trick.
import React, { useEffect, useCallback, useRef, useMemo } from "react";
import { View } from "react-native";
import { Appbar } from "react-native-paper";
import { Stack, useNavigation } from "expo-router";
export default function App(): React.JSX.Element {
const navigation = useNavigation();
const [stage, setStage] = React.useState(0);
const stageRef = useRef(stage);
@Wurushu
Wurushu / video_streaming_server.py
Created February 24, 2025 10:47
A simple HTTP server (video streaming support) with Python
#!/usr/bin/env python3
import sys
import os
from http.server import SimpleHTTPRequestHandler, CGIHTTPRequestHandler, HTTPServer
class VideoHTTPRequestHandler(SimpleHTTPRequestHandler):
def do_GET(self):
"""Handle GET request, supporting video streaming (Range Requests)."""
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],