Skip to content

Instantly share code, notes, and snippets.

View sergi's full-sized avatar
🎯
Focusing

Sergi Mansilla sergi

🎯
Focusing
View GitHub Profile
// Accumulators
// =============================================================================
//
// A tiny library for reactive programming that offers blazing fast generic
// collection manipulation, asyncronous flow control and the ability to
// represent infinitely large collections.
//
// Copyright Gordon Brander, 2013. Released under the terms of the [MIT license](http://opensource.org/licenses/MIT).
//
// Background:
@sergi
sergi / contact_datastore.md
Last active August 29, 2015 14:03
Ideas on using 'full-text-like' on IdexedDB

Alternatives to duplicating and indexing fields in Contacts Datastore

Grouping and indexing several fields in the Contacts Datastore requires some duplication, extra-processing and potential problems synchronizing data from the original datastore to the Contacts indexed one. The idea is to come up with alternatives, or at the very least minimize the amount of data that has to be duplicated.

In any case, we should minimize the amount of fields that are indexed to the essential ones. That is name-related, phone, etc. Fields that are likely to have many null values such as organization should not be indexed.

Full-text search

The idea here would be to take the fields we want to index and concatenate them in a string like "Sergi Mansilla Telenor +311234567" or similar. The key of that string would be the same as the key of the original contact, so that we know what the origin is.

@sergi
sergi / simulate_jsonp.js
Created July 30, 2014 21:55
Simulate JSONP
script.src = "data:text/javascript;base64," + btoa(
"callback(" + JSON.stringify(dummyData) + ")"
);
@sergi
sergi / launch_tests.sh
Last active August 29, 2015 14:05
Running tests on Firefox OS
NIGHTLY="/Applications/FirefoxNightly.app/Contents/MacOS"
launch_tests() {
cd $GAIADIR
if [ ! -d profile/extensions/httpd ] ; then
DEBUG=1 make
fi
$NIGHTLY/firefox --no-remote -profile $GAIADIR/profile-debug/ http://test-agent.gaiamobile.org:8080/ &
# HG changeset patch
# User Sergi Mansilla <[email protected]>
# Date 1413206712 -7200
# Node ID 8738464c211d0821954c017236e20500b76756b8
# Parent f547cf19d10415162339116376904b94241874ca
Bug 1070961 - No retry count is shown when user enters PIN2 to edit FDN contacts.r=echen
diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl
--- a/dom/icc/interfaces/nsIIccProvider.idl
+++ b/dom/icc/interfaces/nsIIccProvider.idl
diff --git a/dom/icc/Icc.cpp b/dom/icc/Icc.cpp
--- a/dom/icc/Icc.cpp
+++ b/dom/icc/Icc.cpp
@@ -317,8 +317,7 @@
already_AddRefed<DOMRequest>
Icc::UpdateContact(const JSContext* aCx, const nsAString& aContactType,
- JS::Handle<JS::Value> aContact, const nsAString& aPin2,
- ErrorResult& aRv)
+ JS::Handle<JS::Value> aContact, ErrorResult& aRv)
@sergi
sergi / RIL_MATRIX.txt
Created October 21, 2014 16:05
RIL_MATRIX
I/Gecko ( 120): -*- RadioInterfaceLayer: Received 'RIL:GetCardLockRetryCount' message from content process
I/Gecko ( 120): RIL Worker: [0] Received chrome message {"lockType":"pin2","requestId":"id{dbc7a938-4b9c-401c-85e6-dc1bcce85b15}","rilMessageClientId":0,"rilMessageToken":29,"rilMessageType":"iccGetCardLockRetryCount"}
I/Gecko ( 120): -*- RadioInterface[0]: Received message from worker: {"lockType":"pin2","requestId":"id{dbc7a938-4b9c-401c-85e6-dc1bcce85b15}","rilMessageClientId":0,"rilMessageToken":29,"rilMessageType":"iccGetCardLockRetryCount","errorMsg":"RequestNotSupported","success":false}
I/Gecko ( 463): -*- RILContentHelper: Received message 'RIL:CardLockRetryCount': {"clientId":0,"data":{"lockType":"pin2","requestId":"id{dbc7a938-4b9c-401c-85e6-dc1bcce85b15}","rilMessageClientId":0,"rilMessageToken":29,"rilMessageType":"iccGetCardLockRetryCount","errorMsg":"RequestNotSupported","success":false}}
I/Gecko ( 463): -*- RILContentHelper: fire request error, id: id{dbc7a938-4b9c-401c-85e
@sergi
sergi / RIL_MATRIX2.txt
Created October 21, 2014 16:09
RIL_MATRIX2
I/Gecko ( 120): -*- RadioInterfaceLayer: Received 'RIL:GetCardLockRetryCount' message from content process
I/Gecko ( 120): RIL Worker: [0] Received chrome message {"lockType":"pin2","requestId":"id{297a3181-47de-4eeb-8059-13649ed0fd34}","rilMessageClientId":0,"rilMessageToken":32,"rilMessageType":"iccGetCardLockRetryCount"}
I/Gecko ( 120): -*- RadioInterface[0]: Received message from worker: {"lockType":"pin2","requestId":"id{297a3181-47de-4eeb-8059-13649ed0fd34}","rilMessageClientId":0,"rilMessageToken":32,"rilMessageType":"iccGetCardLockRetryCount","errorMsg":"RequestNotSupported","success":false}
I/Gecko ( 463): -*- RILContentHelper: Received message 'RIL:CardLockRetryCount': {"clientId":0,"data":{"lockType":"pin2","requestId":"id{297a3181-47de-4eeb-8059-13649ed0fd34}","rilMessageClientId":0,"rilMessageToken":32,"rilMessageType":"iccGetCardLockRetryCount","errorMsg":"RequestNotSupported","success":false}}
I/Gecko ( 463): -*- RILContentHelper: fire request error, id: id{297a3181-47de-4eeb-805
@sergi
sergi / arrow_scope.js
Created October 28, 2014 09:10
Arrow functions scope
var o = {
traditionalFunc: function () {
// Normal function, bound as expected
console.log('traditionalFunc this === o?', this === o);
},
arrowFunc: () => {
// Arrow function, bound to scope where it's created
console.log('arrowFunc this === o?', this === o);
console.log('arrowFunc this === window?', this === window);
}
var DBNAME = 'tabgrenade';
var DBVERSION = 1;
var STORENAME = 'keyvaluepairs';
var db = null;
function withStore(type, f) {
if (db) {
f(db.transaction(STORENAME, type).objectStore(STORENAME));
} else {
var openreq = indexedDB.open(DBNAME, DBVERSION);