Skip to content

Instantly share code, notes, and snippets.

View brittanydionigi's full-sized avatar

Brittany Dionigi brittanydionigi

View GitHub Profile
@brittanydionigi
brittanydionigi / what-on-earth.js
Last active January 4, 2016 20:50
nothing's right I'm torn I'm all out of faith this is how I feel I'm cold and I am shamed
points_to_award: function(questionPosition, inputVal, correctVal) {
var points_earned, plus_seven, plus_three, plus_one;
switch (questionPosition) {
case 2:
plus_one = (inputVal >= (correctVal - 5) && inputVal <= (correctVal + 5)) ? 1 : 0
plus_three = (inputVal >= (correctVal - 3) && inputVal <= (correctVal + 3)) ? 3 : plus_one;
break;
case 10:
plus_one = (inputVal >= (correctVal - 3) && inputVal <= (correctVal + 3)) ? 1 : 0
@brittanydionigi
brittanydionigi / update.html
Created February 10, 2014 23:24
lazy-load images for Smith
<img
data-original="//cdn.shopify.com/s/files/1/0202/8216/products/SWORDSSMITH-KILLER-quillearring500x750_large.jpg?v=1379114870"
class="lazy"
style="display: inline;">
<script type="text/javascript">
(function() {
$('img.lazy').lazyload({
@brittanydionigi
brittanydionigi / shifts.js
Created March 27, 2014 21:12
making people do my work for me
/* Some boys are playing a hockey game and they each play a certain number of shifts. */
/* For simplicity, we'll say there are 15 different shifts in a game. */
[
{
"player": "Joe",
"shifts": [
{ "shift_start": 3, "shift_end": 5 }, // Joe started playing at shift #3, and stopped after shift #5
{ "shift_start": 7, "shift_end": 11 }
]
@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
);
@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 / 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!!'
// 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 / 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">
importScripts('dist/offliner.min.js');
// import here the plug-ins for offliner
var offliner = new off.Offliner({
workerUrl: '/path/to/worker-file.js'
}