Skip to content

Instantly share code, notes, and snippets.

View image72's full-sized avatar

image72 image72

View GitHub Profile
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
// https://blog.logrocket.com/build-video-streaming-server-node/
router.get('/video/:id', (req, res) => {
const videoPath = `assets/${req.params.id}.mp4`;
const videoStat = fs.statSync(videoPath);
const fileSize = videoStat.size;
const videoRange = req.headers.range;
if (videoRange) {
const parts = videoRange.replace(/bytes=/, "").split("-");
const start = parseInt(parts[0], 10);
const end = parts[1]
@image72
image72 / dl2.bookmarklet.js
Created October 19, 2023 02:31
aria2 downloads
const link = window.prompt("Enter URL");
fetch("http://127.0.0.1:6800/jsonrpc", {
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded"
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "someID",
method: "aria2.addUri",
@image72
image72 / Peer-to-Peer-Cue-System-receive.html
Last active September 8, 2023 15:13
WebRTC peer to peer, simple codes.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Peer-to-Peer Cue System --- Reciever</title>
<style>
body {
font-family: 'DejaVu Sans', Arial, Helvetica, sans-serif;
@image72
image72 / zip.js
Last active September 5, 2023 03:06
compress functions with standard test.
const zlib = require('zlib');
async function deflate(data) {
const encoder = new TextEncoder();
const input = encoder.encode(data);
const deflatedChunks = [];
const compressionStream = new CompressionStream('deflate');
const writableStream = new WritableStream({
write(chunk) {
@image72
image72 / chartjs-webcomponent.html
Created August 15, 2023 09:06
wrap chartjs to web component
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Chart.js Web Component</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@image72
image72 / webdav-vs-rest.md
Created July 30, 2023 16:05 — forked from PVince81/webdav-vs-rest.md
Webdav vs REST
Operation Webdav REST
@image72
image72 / mocker.js
Created July 28, 2023 17:40
auto mock response via request points.
#!/usr/bin/env node
// websocketd --port 8058 ./mocker.js
const querystring = require('querystring');
const qs = process.env?.QUERY_STRING.replace('QUERY_STRING=', '');
const qsObj = querystring.parse(qs);
process.stdin.resume();
process.stdin.setEncoding('utf8');
@image72
image72 / readLineAssync.js
Created July 28, 2023 16:09 — forked from mauroao/readLineAssync.js
Node.js - Read line from stdin asynchronously (async / await)
const readline = require('readline');
const readLineAsync = () => {
const rl = readline.createInterface({
input: process.stdin
});
return new Promise((resolve) => {
rl.prompt();
rl.on('line', (line) => {