Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@Ustice
Ustice / Boolean Algebra for Programmers in a Nutshell.md
Last active January 9, 2024 20:16
Boolean Algebra in a nutshell for JS/TS programmers

Boolean Algebra in a nutshell for JS/TS programmers

There are a lot of strategies that you will hear about in the Javascript community for keeping your conditionals from becoming a tangled mess. This isn't like them. This is someting different. MATH! Boolean Algebra to be exact. I use it all the time to simplify complex conditionals. There are two things that you need to know: de Morgan's Theorem, and Karnaugh (pronounced CAR-no) Maps. (Don't worry, there is no test)

de Morgan's Theorem

De Morgan's Theorem is great distributing nots (!), and for when you want to convert an && to an ||, or back. This is it:

 !(A && B) = !A || !B
@laerciobernardo
laerciobernardo / hexIEEEtoFloat.js
Last active January 21, 2024 14:48
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) {
@voluntas
voluntas / webrtc.rst
Last active January 23, 2024 06:57
WebRTC の未来
@jimmywarting
jimmywarting / cjs-in-esm.md
Last active January 27, 2024 18:02
using cjs in esm runtime (NodeJS)
@WebReflection
WebReflection / executable-standalone-module.md
Last active March 4, 2024 20:55
NodeJS Executable Standalone Module

Update

If you're OK in having a node-esm executable, please consider this solution.

#!/usr/bin/env sh
# the /usr/local/bin/node-esm executable
input_file=$1
shift
exec node --input-type=module - $@ <$input_file
@ericoporto
ericoporto / 1.Instructions.md
Created October 19, 2020 02:10 — forked from WesThorburn/1.Instructions.md
Linux: Compile C++ to WebAssembly and JavaScript using Emscripten and CMake

Linux: Compile C++ to WebAssembly and JavaScript using Emscripten and CMake

Download and Install Emscripten

  • My preferred installation location is /home/user
  • Get the latest sdk: git clone https://github.com/emscripten-core/emsdk.git
  • Enter the cloned directory: cd emsdk
  • Install the lastest sdk tools: ./emsdk install latest
  • Activate the latest sdk tools: ./emsdk activate latest
  • Activate path variables: source ./emsdk_env.sh
  • Configure emsdk in your bash profile by running: echo 'source "/home/user/emsdk/emsdk_env.sh"' >> $HOME/.bash_profile
@varqox
varqox / recording_application_and_microphone.md
Last active March 7, 2024 17:59
How to record multiple applications and microphone into one audio file on Linux using PulseAudio

How to record multiple applications and microphone into one audio file on Linux

Step 0. Terminology

Sinks are for output, sources are for input. To stream source to sink a loopback must be created. More shall you find there.

Step 1. Create output sink that will be recorded

Our output sink will be named recording.

pacmd load-module module-null-sink sink_name=recording sink_properties=device.description=recording
@NULLx76
NULLx76 / openssl.sh
Created September 15, 2020 22:37
OpenSSL generate ed25519 and RSA
# Generate ed25519 privkey
openssl genpkey -algorithm ed25519 -out privkey.pem
# export its pubkey
openssl pkey -in privkey.pem -pubout -out pubkey.pem
# Generate RSA privkey
openssl genrsa -des3 -out private.pem 2048
# export its pubkey
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@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) => {