Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@jimmywarting
jimmywarting / cjs-in-esm.md
Last active January 27, 2024 18:02
using cjs in esm runtime (NodeJS)
@yashraj1120
yashraj1120 / server.c
Created March 26, 2023 19:07
simple response server
// webserver.c
// https://bruinsslot.jp/post/simple-http-webserver-in-c/
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/socket.h>
@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 &amp;&amp; B) = !A || !B
@lukaslihotzki
lukaslihotzki / polyfill_worklet_import.js
Last active October 1, 2022 14:02
Polyfill to support "import" in worklet scripts in Firefox
const wrappedFunc = Worklet.prototype.addModule;
Worklet.prototype.addModule = async function(url) {
try {
return await wrappedFunc.call(this, url);
} catch (e) {
if (e.name != 'AbortError') {
throw e;
}
// assume error is caused by https://bugzilla.mozilla.org/show_bug.cgi?id=1572644

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.

@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 "$@"
@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
@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
@zed
zed / ping_pong.c
Last active January 30, 2023 07:05
Native messaging "ping_pong" example in C
/*** Native messaging "ping_pong" example in C.
*
* It is reimplementation of the corresponding Python example from
* https://github.com/mdn/webextensions-examples/tree/master/native-messaging
*
* # Python 3.x version
* # Read a message from stdin and decode it.
* def getMessage():
* rawLength = sys.stdin.buffer.read(4)
* if len(rawLength) == 0:
@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