Skip to content

Instantly share code, notes, and snippets.

View digitarald's full-sized avatar
🏳️‍🌈

Harald Kirschner digitarald

🏳️‍🌈
View GitHub Profile
class Pubsub
constructor: ->
@topics = []
@scopes = []
@methods = []
acquire: (host) ->
@acquired = true
host.pubsub = @
@digitarald
digitarald / bookmarklet.url
Created September 14, 2012 00:11
Bookmarklet mozApps.install and launch - Reads manifest from text selection or current URL
javascript:(function(a,b){if(/\/$/.test(b))b+="manifest.webapp";var c=a.install(b);c.onsuccess=c.onerror=function(){if(c.error)alert(b+"/n"+c.error.name);else c.result.launch()}})(navigator.mozApps,(getSelection().toString()||location.href).trim());
@digitarald
digitarald / manifest.webapp
Created September 17, 2012 21:27
Remix this App Manifest!
{
"name": "My App",
"description": "My elevator pitch goes here",
"launch_path": "/",
"icons": {
"128": "/img/icon-128.png"
},
"developer": {
"name": "Your Name or Organization",
"url": "http: //your-homepage-here.org"
@digitarald
digitarald / robot.js
Created December 3, 2012 23:16
Defendor 2.0 Beta
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var target = 0;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
diff --git a/cache-then-network/sw.js b/cache-then-network/sw.js
index 9449f5f..8170159 100644
--- a/cache-then-network/sw.js
+++ b/cache-then-network/sw.js
@@ -6,15 +6,12 @@ var cacheName = 'cache-then-network';
self.addEventListener('install', function(ev) {
console.log('SW install event');
- self.skipWaiting();
- ev.waitUntil(self.clients.claim());
This file has been truncated, but you can view the full file.
28014 http request GET https://registry.npmjs.org/semver
28015 verbose request uri https://registry.npmjs.org/hosted-git-info
28016 verbose request no auth needed
28017 info attempt registry request try #1 at 1:30:45 PM
28018 verbose request using bearer token for auth
28019 verbose etag "CTVPC6MTOOUB33OPF9OBO9WB7"
28020 http request GET https://registry.npmjs.org/hosted-git-info
28021 verbose request uri https://registry.npmjs.org/validate-npm-package-license
28022 verbose request no auth needed
28023 info attempt registry request try #1 at 1:30:45 PM
@digitarald
digitarald / MozActivity.js
Last active December 13, 2015 18:29
Image selection via Web Activity on Firefox OS
if ('MozActivity' in window) {
document.getElementById('my-file-input').addEventListener('click', function(evt) {
evt.preventDefault();
var picking = new MozActivity({
name: 'pick',
data: {
type: 'image/jpg'
}
@digitarald
digitarald / moz-runtime.js
Last active December 13, 2015 22:49
Open links in new window for apps
var selfReq = navigator.mozApps.getSelf();
isMozRuntime = false;
selfReq.onsuccess = function() {
isMozRuntime = selfReq.result;
if (isMozRuntime) {
// Responsive action to mozilla apps runtime (force links in new window
respondToMozRuntime();
}
};
function respondToMozRuntime() {
if ('MozActivity' in window) { // feature detection
// When getting elements, like document.getElementsByClassName('video-links')
// rather use event delegation, like
// `jQuery(document).on('click', 'video', fn)
document.getElementById('video-1').onclick = function(evt) {
evt.preventDefault(); // Prevent click behaviour
console.log("Launching Video!");
var activity = new MozActivity({
@digitarald
digitarald / index.js
Last active December 16, 2015 17:18
Push2B2G
/**
* Issue a register() call
* To register to listen for a notification, you simply call push.register
*/
var pushReq = navigator.push.register();
pushReq.onsuccess = function(e) {
alert('pushReq.onsuccess');
var endpoint = pushReq.result;
// Store it