Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@joshua-gould
joshua-gould / node-fetch-file-url.js
Last active April 23, 2024 06:21
node-fetch file URL
const fs = require('fs');
const path = require('path');
const nodeFetch = require('node-fetch');
const Request = nodeFetch.Request;
const Request = nodeFetch.Response;
fetch = function (url, options) {
const request = new Request(url, options);
if (request.url.substring(0, 5) === 'file:') {
return new Promise((resolve, reject) => {
@d0ruk
d0ruk / websocket-server.js
Created July 28, 2017 10:04
websocket server
/**
* Copyright (c) 2007-2013, Kaazing Corporation. All rights reserved.
*/
// The Definitive Guide to HTML5 WebSocket
// Example WebSocket server
// See The WebSocket Protocol for the official specification
// http://tools.ietf.org/html/rfc6455
@jimmywarting
jimmywarting / readme.md
Last active December 9, 2025 17:33
Cors proxies
Exposed headers
Service SSL status Response Type Allowed methods Allowed headers
@sttk
sttk / windowSize.html
Last active May 10, 2023 21:27
Window size
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Window Size</title>
<style>
html { font-size: 12px; }
div.fixed { position: fixed; left: calc(100% - 100px); top: 20px; }
div.fixed > a { font-size: 14px; }
</style>
@astoeckel
astoeckel / stream_local_audio.sh
Last active October 12, 2021 06:05
Stream audio from pulse audio as opus stream via UDP/RTP
#!/bin/sh
pacat \
--device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \
--rate=48000 \
--record | \
opusenc \
--expect-loss=25 \
--max-delay=0 \
--framesize=2.5 \
@dcollien
dcollien / multipart.js
Last active July 17, 2024 03:47
Parse multi-part formdata in the browser
var Multipart = {
parse: (function() {
function Parser(arraybuf, boundary) {
this.array = arraybuf;
this.token = null;
this.current = null;
this.i = 0;
this.boundary = boundary;
}
@domenic
domenic / 1-service-worker.js
Last active December 11, 2024 13:52
Service worker stream transferring
"use strict";
const worker = new Worker("worker.js");
self.onfetch = e => {
const transform = new TransformStream(); // creates an identity transform
e.respondWith(new Response(transform.readable));
// Give the worker the writable end. An identity transform stream will just shuffle
// bytes written there into transform.readable.
@sudesh955
sudesh955 / websocket.js
Last active April 19, 2025 22:25
Server side WebSocket
'use strict';
const crypto = require('crypto')
, EventEmitter = require('events')
const badRequest = 'HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: 0'
, goodResponse = 'HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade' +
'\r\nSec-WebSocket-Accept: '
, magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
, two32 = Math.pow(2, 32)
@laerciobernardo
laerciobernardo / hexIEEEtoFloat.js
Last active December 11, 2024 07:30
Convert Hexadecimal IEEE754 to Float in Javascript
var str = '0x41FC6733';
function parseFloat(str) {
var float = 0, sign, order, mantiss,exp,
int = 0, multi = 1;
if (/^0x/.exec(str)) {
int = parseInt(str,16);
}else{
for (var i = str.length -1; i >=0; i -= 1) {
if (str.charCodeAt(i)>255) {
@ssledz
ssledz / bash-cheat-sheet
Created May 21, 2016 14:36
BASH Cheat Sheet
B A S H C H E A T S H E E T
to page output forward (only): command filename | more
to page output forward & back: command filename | less
to print a dataset: lp datasetname (-d printerid) (-o landscape)
USE OF QUOTATION MARKS
echo "$varname" = echo The value of \$varname is \"$varname\"
= echo "The value of \$varname is \"$varname\"."
$fred='Four spaces between these words.'