Skip to content

Instantly share code, notes, and snippets.

View bnjbvr's full-sized avatar

Benjamin Bouvier bnjbvr

View GitHub Profile
@bnjbvr
bnjbvr / pr.md
Created March 25, 2013 10:40 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@bnjbvr
bnjbvr / gist:5344958
Last active December 16, 2015 00:09 — forked from seanmonstar/gist:5286698
rss-2-tent-bridge

Tent <-> RSS Bridge

Needs a name (smoke-signals?)

This is an open source, hosted, bi-directional bridge of Tent and RSS. It would be hosted somewhere, and installed as an app against your tent server.

Using Python, because it doesn't make us claw our eyes out. Likely with the Flask framework.

Register as an app

@bnjbvr
bnjbvr / gist:6750933
Last active December 24, 2015 05:29
Proxy all Math calls
var proxy = {
get: function(target, name, receiver) {
var original = target[name];
return function() {
// for instance, print all arguments
for(var i = 0; i<arguments.length;++i)
print(arguments[i]);
return original.apply(receiver, arguments)
}
@bnjbvr
bnjbvr / gist:e268b2eba1f6dc32b4ec
Last active August 29, 2015 14:13 — forked from padenot/gist:64d001ee1e396794331c
SIMD example for padenot
if (window.SIMD) {
// yay, SIMD available, let's do a little stereo mixdown routine
for (var i = 0; i < bufsize; i+=4) {
var lhs = SIMD.float32x4(left[i+0], left[i+1],
left[i+2], left[i+3]),
rhs = SIMD.float32x4(right[i+0], right[i+1],
right[i+2], right[i+3]);
var mixdown = SIMD.float32x4.add(lhs, rhs);
SIMD.float32x4.store(center, i, mixdown);
}
static bool add (JSContext *cx, unsigned argc, jsval *vp){
JS::CallArgs args = CallArgsFromVp(argc, vp);
std::cout<<(args[0].toInt32()+args[1].toInt32());
RootedFunction func(cx, JS_ValueToFunction(cx, args[2]));
// JSFunction* function;
JS::RootedValue rval(cx);
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
JS_CallFunction(cx, global, &func, 0, nullptr, &rval);
return true;
}
@bnjbvr
bnjbvr / gist:a54828e75328d4922d89
Created March 27, 2015 19:55
Transform a (err, ..., callback) based function into a Promise-based function
function promisify(func) {
return function(...args) {
return new Promise(function(resolve, reject) {
func(...args, function(err, ...rest) {
if (err)
return reject(err);
resolve(...rest);
});
});
}
### Keybase proof
I hereby claim:
* I am bnjbvr on github.
* I am bnjbvr (https://keybase.io/bnjbvr) on keybase.
* I have a public key whose fingerprint is FB2E 08CF ADFF 7CE0 6067 A3A2 4864 9898 2667 C10E
To claim this, I am signing this object:
const wasmEvalText = (txt, maybeImports) => new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(txt)), maybeImports);
let module = new WebAssembly.Module(wasmTextToBinary(`
(module
(import "global" "func" (result i32))
(table (import "env" "table") 3 anyfunc)
(func (export "func_0") (result i32)
call 0 ;; calls the import, which is func #0
)
(memory (export "mem") 10)
@bnjbvr
bnjbvr / pubsub.rs
Last active May 16, 2017 14:53
server.rs
#[derive(Debug)]
pub enum Command {
Publish(String),
Retrieve
}
#[derive(Debug)]
pub enum Error {
VerbMissing,
UnknownVerb,
@bnjbvr
bnjbvr / perf integration
Last active April 15, 2020 13:20
Misc spidermonkey commands
1. When running configure, pass the `--enable-perf` configuration option. Re-build the shell.
2. Run the shell with
```
IONPERF=func perf record $jsshell --no-wasm-multi-value --shared-memory=off --wasm-compiler=cranelift /path/to/script.js
```
An ExecutableAllocator is leaked on shutdown, which causes an assertion to
trigger: `Assertion failure: m_refCount == 1, at /home/ben/code/mozilla-inbound/js/src/jit/ExecutableAllocator.cpp:51`