Skip to content

Instantly share code, notes, and snippets.

View freaktechnik's full-sized avatar
🚞
I like trains

Martin Giger freaktechnik

🚞
I like trains
View GitHub Profile
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* This implements server-timestamps for IRC.
* http://ircv3.net/specs/extensions/server-time-3.2.html
*/
this.EXPORTED_SYMBOLS = ["capServerTime", "tagServerTime"];
# HG changeset patch
# User Martin Giger <[email protected]>
# Parent b9cd88a0878f441423c99b7335ee393f4c7d1df1
Bug 1302447 - Add tag handling infrastructure r=clokep
diff --git a/chat/protocols/irc/irc.js b/chat/protocols/irc/irc.js
--- a/chat/protocols/irc/irc.js
+++ b/chat/protocols/irc/irc.js
@@ -148,16 +148,22 @@ function _setMode(aAddNewMode, aNewModes
if (hasMode && !aAddNewMode)
const panel = new Panel({...});
const runLoop = (text, i = 0) => {
// do something
self.port.once("updated-something", runLoop.bind(null, text, i + 1));
self.port.emit("update-something", data);
};
panel.port.on("text-changed", (text) => {
runLoop(text);
const promises = []; // Array filled with Promises
const channels = 3; // Amount of channels
const worker = (prevResult) => {
if(promises.length) {
return promises.pop().then(worker).then((result) => {
const ret = [ result ];
if(prevResult) {
ret.push(...prevResult));
}
const run = async (allowRefresh) => {
const response = await this.runRequest(methid, url, data);
if(this.requireRefresh(response) && allowRefresh)
return 'refresh';
else if(response.error)
throw response;
else
return response;
};
"use strict";
// Require some stuff
const { myMethod } = require("my-method");
// Init code
myMethod("initializing");
...
// Cleaning up
@freaktechnik
freaktechnik / ensureSetTimeout.js
Last active July 19, 2016 21:45
Makes sure setTimeout waits long enough.
function ensureSetTimeout(cb, s) {
var callTime = Date.now();
setTimeout(function() {
var cbTime = Date.now();
if(cbTime - s == callTime)
cb();
else
ensureSetTimeout(cb, s - (cbTime - callTime))
}, s);
@freaktechnik
freaktechnik / elementary-apps.md
Last active April 26, 2024 22:11
Nice elementary packages I like to add
function aWaitForSuccess({ name, timeout, validator }) {
let def = promise.defer();
function wait(validator) {
validator().then((success) => {
if(success) {
ok(true, "Validator function " + name + " returned true");
def.resolve();
} else {
setTimeout(() => wait(validator), timeout);
diff --git a/devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js b/devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js
index b14e031..fe2cb14 100644
--- a/devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js
+++ b/devtools/client/webconsole/test/browser_bug664688_sandbox_update_after_navigation.js
@@ -42,7 +42,7 @@ add_task(function* () {
yield waitForMessages(msgForLocation1);
// load second url
- content.location = TEST_URI2;
+ yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI2);