Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@amishshah
amishshah / ogg-containers.md
Last active June 12, 2023 21:16
A guide to the Ogg container format for demuxing opus audio

You take a stream/buffer of binary data. The start of your data is a "Page", which has a header followed by data.

Header

You need to read the following data from the header (see https://xiph.org/ogg/doc/framing.html for more detail)

  • capture_pattern - bytes 0 to 3, must read OggS
  • stream_structure_version - byte 4, must be 0
  • header_type_flag - byte 5, a bitflag that tells you metadata about the page (is it a new packet? is a packet continued here? is it the first/last page of the stream?)
  • absolute granule position - bytes 6 to 13, not needed unless you want seeking
  • stream serial number - bytes 14 to 17, a serial number given to each stream contained in the Ogg file. This is important for playing Ogg files that contain other streams, such as video or cover art. You need to identify and only bother parsing the Opus stream.
@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.'
@wernight
wernight / inotifyexec.py
Last active June 27, 2023 22:47
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.
@bagder
bagder / http3.php
Last active July 26, 2023 14:33
HTTP/3 with PHP/CURL
if (!defined('CURL_HTTP_VERSION_3')) {
define('CURL_HTTP_VERSION_3', 30);
}
$ch = curl_init("https://cloudflare-quic.com/");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3);
curl_exec($ch);
@robertrypula
robertrypula / web-socket-server.js
Created February 11, 2021 20:50
WebSocket - binary broadcast example (pure NodeJs implementation without any dependency)
// Copyright (c) 2019-2021 Robert Rypuła - https://github.com/robertrypula
/*
+--------------------------------------------------+
| Binary broadcast WebSocket server in pure NodeJs |
+--------------------------------------------------+
Based on great article created by Srushtika Neelakantam:
https://medium.com/hackernoon/implementing-a-websocket-server-with-node-js-d9b78ec5ffa8
@cure53
cure53 / wasm.md
Last active October 17, 2023 00:16
Calling alert from WASM

Calling alert from WebAssembly (WASM)

This very simple and minimal tutorial documents in a few easy steps how to play with WebAssembly (WASM) and get first results within minutes.

While the code below is mostly useless, it will show, how to call the alert function from within a WASM file and thus demonstrate how to import and export DOM objects.

Of course, this exercise has no real use. It is just meant to show, that getting started with WASM isn't hard. And there is no need for a complex build-chain, tons of tools or a dedicated VMs. Just use a browser, one online tool and that's it.

And Now?

@gildas-lormeau
gildas-lormeau / unzip
Created September 12, 2021 20:24
Basic unzip implementation based on zip.js and Deno
#!/bin/sh
~/.deno/bin/deno run --allow-net --allow-write --allow-read --unstable unzip.js "$@"
@Jozo132
Jozo132 / float32encoding.js
Last active November 15, 2023 07:47
JavaScript (Node.js) IEEE 754 Single precision Floating-Point (32-bit) binary conversion from and to both Hex and Bin
/* ##### float32encoding.js #####
MIT License
- Forked 'toFloat' from https://gist.github.com/laerciobernardo/498f7ba1c269208799498ea8805d8c30
- Forked 'toHex' from stackoverflow answer https://stackoverflow.com/a/47187116/10522253
- Modifyed by: Jozo132 (https://github.com/Jozo132)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@TotallyNotChase
TotallyNotChase / host.json
Last active December 9, 2023 19:46
Native Messaging - Rust
{
"name": "pingpong",
"description": "Native messaging host example",
"path": "path/to/release_executable",
"type": "stdio",
"allowed_origins": [
"chrome-extension://extension_id/"
]
}

Originally posted at https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2011/august/javascript-cryptography-considered-harmful/

Javascript Cryptography Considered Harmful

WHAT DO YOU MEAN, "JAVASCRIPT CRYPTOGRAPHY"?

We mean attempts to implement security features in browsers using cryptographic algoritms implemented in whole or in part in Javascript.

You may now be asking yourself, "What about Node.js? What about non-browser Javascript?". Non-browser Javascript cryptography is perilous, but not doomed. For the rest of this document, we're referring to browser Javascript when we discuss Javascript cryptography.