Skip to content

Instantly share code, notes, and snippets.

View brittanydionigi's full-sized avatar

Brittany Dionigi brittanydionigi

View GitHub Profile

"if" means inverse frequency and the unit here is minute
e.g. "if < 20" means the user has exhibited that behavior (on average) more than once per 20 minutes
so when "if < 5", then "frequency > 1/5"
so it would be higher than once per 5 minutes!

and "c" means the number of times the behavior has been exhibited so far (since the installation of the addon)
so -c > 10 -if < 20 means the user has done something at least 10 times with a frequency of higher than once per 20 minutes

16:52 "if" means
16:52 inverse frequency
16:52 and the unit here is minute
16:53 e.g. if <20 means the user has exhibited that behavior (on average) more than once per 20 minutes
16:53 got it
16:54 and "c" means the number of times the behavior has been exhibited so far (since the installation of the addon)
16:54 so -c >10 -if <20 means the user has done something at least 10 times with a frequency of higher than once per 20 minutes
16:56 ok cool, so let me see if I’m getting this right
16:56 using """+"" button used at least 50 times and if <5 tabs newtab-button -c >50 -if <5” as an example...
16:57 + button used at least 50 times AND with a frequency higher than 5 times per minute

var Offliner = importScripts('dist/offliner.min.js');
// import here the plug-ins for offliner
var offlinerInstance = new Offliner({
workerUrl: "/path/to/worker-file.js"
});
offlinerInstance.prefetch
.use(/* ... */) // you will find fetchers in the off.fetchers collection
.resources([/* ... */]);
importScripts('dist/offliner.min.js');
// import here the plug-ins for offliner
var offliner = new off.Offliner({
workerUrl: '/path/to/worker-file.js'
}
@brittanydionigi
brittanydionigi / events.html
Created August 28, 2015 19:23
events practice
<!doctype html>
<html>
<head>
<style type="text/css">
div { margin: 15px; padding: 50px; border: 1px solid #ccc; background-color: rgba(255, 192, 203, 0.24); }
</style>
</head>
<body>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> -->
<script type="text/javascript">
// Check for Service Workers and register service worker script
function registerServiceWorker(workerFile) {
console.log("Checking for service workers...");
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(workerFile, {
scope: './'
}).then(function(reg) {
console.log("Service Worker Successfully Registered");
enableSubmitButton();
});
@brittanydionigi
brittanydionigi / sw-messaging.js
Created March 16, 2015 19:41
messaging in service workers
// index.html -- Sending message TO service worker, FROM page:
navigator.serviceWorker.controller.postMessage(message);
// service-worker.js -- Handling message event in service worker by posting a message back to the page:
self.addEventListener('message', function(event) {
self.clients.matchAll().then(function(client) {
client[0].postMessage({
command: 'logMessage',
error: null,
message: 'hi there message here!!'
@brittanydionigi
brittanydionigi / headers.js
Created February 25, 2015 15:39
Headers when POSTing to /api/v2/apps/app for FF Marketplace (dev)
{ authorization: 'OAuth oauth_consumer_key="foo",oauth_nonce="yuWMpO90nLNV4UOFQbSJoIEwpKZX5Laj",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1424878605",oauth_version="1.0",oauth_signature="7HPYLjVksQ8uxVeDkgn55MWXOJI%3D"',
host: 'marketplace-dev.allizom.org',
accept: '*/*',
connection: 'close',
'user-agent': 'Node authentication',
'content-length': 41,
'content-type': 'application/json' }
@brittanydionigi
brittanydionigi / oauth.js
Last active August 29, 2015 14:16
oauth
var oauth = new OAuth.OAuth(
'https://marketplace-dev.allizom.org/oauth/token', // request token URL
'https://marketplace-dev.allizom.org/oauth/authorize', // access token URL?
consumerKey, // user generated key from developers/api
consumerSecret, // user generated secret from developers/api
'1.0a', // oauth version
null, // callback
'HMAC-SHA1' // signature method
);