Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View RReverser's full-sized avatar
🇺🇦

Ingvar Stepanyan RReverser

🇺🇦
View GitHub Profile
@RReverser
RReverser / ClangWarnGlobals.cpp
Last active November 2, 2022 01:51 — forked from shardest/.gitignore
Clang plugin by John Bartholomew for finding globals and non-const static variables, unpacked
// -Wglobals Clang plugin
//
// Based on example plugins and searching Clang's API documentation.
// BEWARE! This is my first ever attempt at a Clang plugin.
//
// Written by John Bartholomew <jpa.bartholomew@gmail.com>
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
url total_opt_br total_strip_br regression_abs regression_pct
https://oso-web-demo.s3.us-west-2.amazonaws.com/de568a042820fcd97a6f.module.wasm 335016 305069 29947 9.8
https://sigmausd.io/d0324a003154b2d64e31.module.wasm 273841 252292 21549 8.5
https://pc.meitu.com/public/dist/js/lib/RenderModule.wasm 343220 316664 26556 8.4
https://gulch.io/client-1.25.5.wasm.wasm 179059 165584 13475 8.1
https://app.roboxmaker.com/aker-app.wasm 654078 608232 45846 7.5
https://sdkathlos.it/avatar/insalute//js_wordpress/nyumaya.wasm 255076 237325 17751 7.5
https://playground.buttplug.world/dist/8b4ec1dfc3ee2ffb9df7.module.wasm 753814 704467 49347 7.0
https://solve.prod.portal.onscale.com/d102b71af6dc744954ce.module.wasm 587557 549528 38029 6.9
https://eventin.space/tflite-wasm/tflite-wasm-simd.wasm 493826 462458 31368 6.8
addEventListener('fetch', event => {
if (event.request.method === 'PUT') {
event.respondWith(handleRequest(event));
}
});
async function handleRequest(event) {
let response = await fetch(event.request);
if (!response.ok) return response;
let urls = ['/'];
@RReverser
RReverser / embind-asyncify.sh
Last active June 24, 2020 17:51
Embind + Asyncify
# Install tip-of-tree Emscripten
$ emsdk install tot
$ emsdk activate tot
# Build with Embind and Asyncify enabled
$ emcc --bind -s ASYNCIFY mylib.cpp -o mylib.html
// Create a Worker we want to share memory with:
let w = new Worker(`data:text/javascript,
onmessage = ({data: memory}) => {
// Got WebAssembly.Memory once, log same instance forever with no further postMessages:
setInterval(() => console.log('Current buffer in worker:', memory.buffer), 5_000);
}
`);
// Create a shared growable memory:
let m = new WebAssembly.Memory({ initial:1, maximum: 65536, shared: true });
// Send memory to the worker:
const TEXT_ENCODER = new TextEncoder();
const WASM_PAGE_SIZE = 1 << 16;
function encodeStringToBinary(str) {
// Initially allocate enough space for the case where 1 char requires 1 byte (ASCII-only).
let dest = new WebAssembly.Memory({ initial: Math.ceil(str.length / WASM_PAGE_SIZE) });
let writePos = 0;
for (;;) {
// Write starting from the last written position.
@RReverser
RReverser / better-console-log.js
Last active May 9, 2019 21:07
Better console.log in Node
// UPD:
// Now available as npm module!
// Check out https://github.com/RReverser/better-log for details.
console.log = (function (log, inspect) {
return function () {
return log.apply(this, Array.prototype.map.call(arguments, function (arg) {
return inspect(arg, { depth: 1, colors: true });
}));
};
#!/usr/bin/env python
# Use with
# > cargo test --no-run # print compilation failures if any
# > RUST_TEST_THREADS=1 cargo test -q -- --logfile tests.log 2>failures.log; ../convert-test-log.py
import xml.etree.cElementTree as ET
import re
failure_re = re.compile(r"""thread '(.*?)' panicked at '(.*?)', tests/test\.rs:\d+:\d+
extern crate bincode;
extern crate cidr;
extern crate hex_slice;
extern crate rmp_serde;
extern crate serde;
extern crate serde_bytes;
extern crate serde_cbor;
#[macro_use]
extern crate serde_derive;
pub struct IpCidr(::cidr::IpCidr);
impl Debug for IpCidr {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Debug::fmt(&self.0, f)
}
}
impl Deref for IpCidr {
type Target = ::cidr::IpCidr;