This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
process.title = 'http2server'; | |
console.error('SERVER PID', process.pid); | |
/* ---------- Linux early tuning ------------------------------ */ | |
if (process.platform === 'linux') { | |
try { | |
require('fs').writeFileSync('/proc/sys/net/core/somaxconn', '65535'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:typed_data'; | |
import 'dart:math'; | |
// SIMD-optimized big integer operations using Float32x4 and Int32x4 | |
class SIMDBigInt { | |
static final _rng = Random.secure(); | |
// Convert regular int to SIMD-friendly chunks | |
static Float32x4List toFloat32x4List(List<int> values) { | |
final padded = List<int>.from(values); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// --- CORE TYPES --- | |
// Entity is a unique identifier. | |
type Entity uint32 | |
// ComponentType is the identifier for a component type, used for bitmasking. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class LRUCache<K, V> { | |
private readonly keys: K[]; | |
private readonly values: V[]; | |
private readonly accessOrder: number[]; // Index-based linked list | |
private readonly keyToIndex = new Map<K, number>(); | |
private readonly maxSize: number; | |
private head = 0; | |
private tail = 0; | |
private size = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Buffer } = require("buffer"); | |
// Run length encoding | |
// O(n) for both compression and decompression, O(1) additional space during processing | |
// A,A,A,A,B,B,C,C,C,C,C => (A,4),(B,2),(C,5) | |
export function compressRLE(buffer: Buffer) { | |
if (!buffer.length) return Buffer.alloc(0); | |
const out = []; | |
let val = buffer[0], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'dart:typed_data'; | |
import 'package:shelf/shelf.dart'; | |
import 'package:shelf/shelf_io.dart' as io; | |
import 'package:shelf_web_socket/shelf_web_socket.dart'; | |
import 'package:web_socket_channel/web_socket_channel.dart'; | |
// Message types, same as in the JS version. | |
enum MessageType { | |
statusUpdate(0x01), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns random-forest | |
(:require [clojure.java.io :as io] | |
[clojure.string :as str]) | |
(:import [java.util Arrays Random] | |
[jdk.incubator.vector FloatVector VectorSpecies VectorOperators])) | |
(set! *warn-on-reflection* true) | |
(set! *unchecked-math* :warn-on-boxed) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# binary-compatible-proxy-generator.sh | |
# Creates a binary-compatible sandboxed proxy for ELF executables using nsjail | |
set -e | |
if [ $# -lt 1 ]; then | |
echo "Usage: $0 <original-binary> [nsjail-options]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit immediately if a command exits with a non-zero status | |
set -e | |
# Function to check if the script is run as root | |
check_root() { | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 |
NewerOlder