Skip to content

Instantly share code, notes, and snippets.

View jeremyroman's full-sized avatar

Jeremy Roman jeremyroman

View GitHub Profile
class ValueSerializer {
class Delegate {
/*
* Delegate serializes the module content and returns an ID representing it.
* Using v8::WasmCompiledModule::GetTransferrableModule is recommended for efficiency,
* but a V8 client could do something else (like store the wire bytes, or store
* a URL to remote server that hosts wasm modules, or something else).
*/
virtual Maybe<uint32_t> GetWasmCompiledModuleId(
Isolate* isolate, Local<WasmCompiledModule> wasm_module);
@jeremyroman
jeremyroman / api-dictionary.cc
Created March 14, 2017 20:54
v8::DictionarySchema to make reading dictionaries fast
Local<DictionarySchema> DictionarySchema::New(Isolate* v8_isolate,
Local<Value> keys[],
int keyCount) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
i::Handle<i::DictionarySchema> schema = i::DictionarySchema::New(isolate, keyCount);
for (int i = 0; i < keyCount; i++) {
Handle<Object> key = Utils::OpenHandle(keys[i]);
uint32_t array_index;
Utils::ApiCheck(key->IsName() || key->ToArrayIndex(&array_index),
@jeremyroman
jeremyroman / api_signature.cc
Created December 22, 2016 19:59
WDYT of templating APISignature::ParseArgumentsImpl
namespace {
class V8ParsingBuffer {
public:
V8ParsingBuffer(std::vector<v8::Local<v8::Value>> values, v8::Isolate* isolate)
: values_(values), isolate_(isolate) {}
void AddNull() { values_.push_back(v8::Null(isolate)); }
std::nullptr_t GetParsedArgumentBuffer() { return nullptr; }
void AddParsedArgument(v8::Local<v8::Value> value) { values_->push_back(value); }
private:
@jeremyroman
jeremyroman / pre-commit
Created January 15, 2016 16:58
pre-commit hook
#!/bin/sh
if [[ "$(git symbolic-ref HEAD)" = "refs/heads/master" ]]; then
echo "Refusing to commit on master." >&2
exit 1
fi
@jeremyroman
jeremyroman / gist:255e8b820c7d64479af1
Created July 8, 2015 14:37
SimpleShaperTest excerpt
class TestFontSelector : public FontSelector {
public:
static PassRefPtr<TestFontSelector> create(const String& path)
{
WebUnitTestSupport* unitTestSupport = Platform::current()->unitTestSupport();
String filePath = unitTestSupport->webKitRootDir() + path;
RefPtr<SharedBuffer> fontBuffer = static_cast<PassRefPtr<SharedBuffer>>(unitTestSupport->readFromFile(filePath));
return adoptRef(new TestFontSelector(FontCustomPlatformData::create(fontBuffer.get())));
}
@jeremyroman
jeremyroman / textblob-counter.diff
Created September 24, 2014 21:14
text blob counting patch
diff --git a/Source/core/rendering/TextPainter.cpp b/Source/core/rendering/TextPainter.cpp
index 3901813..4133ea0 100644
--- a/Source/core/rendering/TextPainter.cpp
+++ b/Source/core/rendering/TextPainter.cpp
@@ -178,6 +178,8 @@ static bool graphicsContextAllowsTextBlobs(GraphicsContext* context)
return !context->strokeGradient() && !context->strokePattern() && !context->fillGradient() && !context->fillPattern();
}
+static unsigned long g_totalBlobsPainted = 0;
+
<!DOCTYPE html>
<script src="foam/core/bootFOAM.js"></script>
<link rel="stylesheet" href="foam/core/foam.css">
<script>
MODEL({
name: 'Gadget',
properties: ['id', 'inventor'],
});
@jeremyroman
jeremyroman / README.md
Created July 10, 2014 19:11
DAOListView + DAOListView = ???

Expected: can see three lists of detail views. Actual: can only see the first one; inspecting the DOM reveals that all three of the nested list views have the same ID (in my case, view3)

@jeremyroman
jeremyroman / index.html
Created July 8, 2014 21:26
DAOListView + Array = wtf?
<!DOCTYPE html>
<script src="foam/core/bootFOAM.js"></script>
<link rel="stylesheet" href="foam/core/foam.css">
<script>
MODEL({
name: 'Widget',
properties: ['gizmo'],
});
@jeremyroman
jeremyroman / setuid.c
Last active August 29, 2015 13:56
setuid by id
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[]) {
uid_t uid = (uid_t) atoi(argv[1]);
setuid(uid);
execl("/bin/sh", "sh", (char*) 0);
return 1;
}