Skip to content

Instantly share code, notes, and snippets.

View omo's full-sized avatar

Hajime Morrita omo

  • Mountain View, CA
View GitHub Profile
# -*- coding: utf-8 -*-
import os
import json
import urllib
import urllib2
import requests
URL = "https://api.github.com/gists"
#PADDING_SIZE = 1024 # This works
<!DOCTYPE>
<script>
window.Document.prototype.hello = function() {
alert("Hello!");
}
</script>
<h1>Call document.hello() for me.</h1>
@omo
omo / gist:9986103
Created April 5, 2014 01:08
HTML Imports: Discussion over Async/Progressive Loading

HTML Imports: Discussion over Async/Progressive Loading

There are concerns around HTML Imports that does sync or blocking loading as the default. I’d like to address these concerns. Especially I’d like to understand the actual use cases that “sync” loading hurts. This document aims to be a portal of that effort.

What to Block

Before discussing use cases, let’s clarify which part of page loading process HTML Imports possibly blocks. The blocking model of HTML Imports is modeled after the one for external stylesheets. There are two main bits of the blocking:

The <script> elements

@omo
omo / gist:11274718
Created April 25, 2014 01:03
List of IPC Messages
IPC_MESSAGE_ROUTED4(ExtensionMsg_Response, int , bool , base::ListValue , std::string )
IPC_MESSAGE_ROUTED5(ExtensionMsg_MessageInvoke, std::string , std::string , std::string , base::ListValue , bool )
IPC_MESSAGE_CONTROL1(ExtensionMsg_SetFunctionNames, std::vector<std::string>)
IPC_MESSAGE_CONTROL2(ExtensionMsg_SetSystemFont, std::string , std::string )
IPC_MESSAGE_CONTROL1(ExtensionMsg_ActivateExtension, std::string )
IPC_MESSAGE_CONTROL1(ExtensionMsg_Loaded, std::vector<ExtensionMsg_Loaded_Params>)
IPC_MESSAGE_CONTROL1(ExtensionMsg_Unloaded, std::string)
IPC_MESSAGE_CONTROL1(ExtensionMsg_SetScriptingWhitelist, extensions::ExtensionsClient::ScriptingWhitelist)
IPC_MESSAGE_ROUTED1(ExtensionMsg_ExecuteCode, ExtensionMsg_ExecuteCode_Params)
IPC_MESSAGE_CONTROL1(ExtensionMsg_UpdateUserScripts, base::SharedMemoryHandle)
@omo
omo / gist:30c01500ddb5e27fcba8
Created July 4, 2014 23:57
status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch)
status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch) {
....
ScopedLocalRef<jobject> receiverObj(env, NULL);
bool skipCallbacks = false;
for (;;) {
uint32_t seq;
InputEvent* inputEvent;
status_t status = mInputConsumer.consume(&mInputEventFactory,
@omo
omo / gist:2790ecf8a9434f5f41c4
Created July 4, 2014 23:57
int NativeInputEventReceiver::handleEvent(int receiveFd, int events, void* data)
int NativeInputEventReceiver::handleEvent(int receiveFd, int events, void* data) {
....
if (events & ALOOPER_EVENT_INPUT) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
status_t status = consumeEvents(env, false /*consumeBatches*/, -1, NULL);
mMessageQueue->raiseAndClearException(env, "handleReceiveCallback");
return status == OK || status == NO_MEMORY ? 1 : 0;
}
@omo
omo / gist:b2b0a5d4d680bf5ad39f
Created July 5, 2014 00:07
status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consumeBatches, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent)
status_t InputConsumer::consume(InputEventFactoryInterface* factory,
bool consumeBatches, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent) {
...
*outSeq = 0;
*outEvent = NULL;
// Fetch the next input message.
// Loop until an event can be returned or no additional events are received.
while (!*outEvent) {
if (mMsgDeferred) {
...
@omo
omo / bar_plot.R
Last active August 29, 2015 14:04
qplot(x=year, y=injuries, data=t_per_year, geom="bar", stat="identity")
@omo
omo / trace.py
Created December 17, 2014 18:08
#!/usr/bin/env python
import json
import sys
import pandas as pd
import matplotlib.pyplot as plt
def delay_of(sync, chrd):
ret = []
si = 0
import json
import sys
import pandas as pd
import matplotlib.pyplot as plt
from optparse import OptionParser
def make_dataframe(raw_events, name):
#start_ts = {}
filtered = [ dict(e.items() + e["args"].items()) for e in raw_events if e["name"] == name ]