Skip to content

Instantly share code, notes, and snippets.

View jimblandy's full-sized avatar

Jim Blandy jimblandy

View GitHub Profile
diff --git a/devtools/server/actors/object.js b/devtools/server/actors/object.js
--- a/devtools/server/actors/object.js
+++ b/devtools/server/actors/object.js
@@ -397,17 +397,22 @@ ObjectActor.prototype = {
obj._safeGetters = null;
continue;
}
let result = getter.call(this.obj);
if (result && !("throw" in result)) {
shibui:src$ obj~/js/src/js
js> let u = 1/5, t = 3/5
js> u + u + u === t
false
js> 2**53 + 1 + 1 === 2**53 + 2
false
js> 2**52 + 1 + 1 === 2**52 + 2
true
js>
@jimblandy
jimblandy / jsfun.h.patch
Created February 12, 2018 21:34
Remove `wasm` member from `JSFunction`
diff --git a/js/src/jsfun.h b/js/src/jsfun.h
--- a/js/src/jsfun.h
+++ b/js/src/jsfun.h
@@ -123,31 +123,28 @@ class JSFunction : public js::NativeObje
friend class JSFunction;
js::Native func_; /* native method pointer or null */
union {
// Information about this function to be used by the JIT, only
// used if isBuiltinNative(); use the accessor!
const JSJitInfo* jitInfo_;
@jimblandy
jimblandy / write.cc
Created February 2, 2018 05:40
Dumb benchmark of memory initialization and file writing speeds
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@jimblandy
jimblandy / EnterExit.cpp
Created January 18, 2018 21:45
Dumb-as-paste function call tracing
class EnterExit {
pid_t pid;
char thread_name[100];
const char* label;
void* ptr;
public:
EnterExit(const char* label, void* ptr)
: pid(getpid()),
label(label),
@jimblandy
jimblandy / devtools-mochitest-toy.patch
Created January 11, 2018 20:20
Sample patch for a really lightweight devtools mochitest
diff --git a/devtools/server/tests/mochitest/chrome.ini b/devtools/server/tests/mochitest/chrome.ini
--- a/devtools/server/tests/mochitest/chrome.ini
+++ b/devtools/server/tests/mochitest/chrome.ini
@@ -18,16 +18,17 @@ support-files =
inspector-helpers.js
inspector-search-data.html
inspector-styles-data.css
inspector-styles-data.html
inspector-traversal-data.html
large-image.jpg
@jimblandy
jimblandy / math.el
Last active January 3, 2018 17:54
Simple differentiation in elisp
(require 'ert)
(defun derivative (v e)
(pcase e
((pred symbolp) (if (eq e v) 1 e))
((pred numberp) 0)
(`(+) 0)
(`(+ ,x . ,ys) (expr+ (derivative v x)
(derivative v (apply #'expr+ ys))))
(`(*) 0)
@jimblandy
jimblandy / foo.html
Last active December 7, 2017 18:50
Top-level `let` versus `var`
<body>
<script src="foo1.js"></script>
<script src="foo2.js"></script>
<script>
console.log('var1: ', var1);
console.log('var2: ', var2);
console.log('window.var1: ', window.var1);
console.log('window.var2: ', window.var2);
</script>
@jimblandy
jimblandy / playground.rs
Created November 27, 2017 00:54 — forked from anonymous/playground.rs
Rust code shared from the playground
#![allow(unused_variables)]
/// Given an array of `true` or `false` values (the type `bool`),
/// return a new array whose `i`'th element is true iff `array[i]`
/// and `array[i+1]` are different.
///
/// Rust numbers array elements starting with zero. Since `array` has 80
/// elements, its first element is `array[0]`, and its last element is
/// `array[79]`. The function's return value is similar.
///
@jimblandy
jimblandy / playground.rs
Created November 27, 2017 00:29 — forked from anonymous/playground.rs
Rust code shared from the playground
#![allow(unused_variables)]
fn show_line(array: [bool; 80]) {
for i in 0..80 {
if array[i] {
print!("+");
} else {
print!(" ");
}