This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default getUrl; | |
function getUrl(window) { | |
const topMostWindow = getTopMostIframeWithReferrer(window); | |
const { referrer } = topMostWindow.document; | |
if (!isInIframe(window)) return window.location.href; | |
// in Firefox it won't fill the referrer for friendly iframes | |
if (referrer === '' && isParentFrameFriendly(topMostWindow)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uniqid = require('uniqid'); | |
document.body.innerHTML = uniqid(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createFactory() { | |
var args = [].slice.call(arguments); | |
var createFunc = args.pop(); | |
return function() { | |
if (arguments.length > 0) { | |
return createFunc.apply(null, arguments); | |
} else { | |
return createFunc.apply(null, args); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hello world | |
var lodash = require('lodash'); | |
console.log(lodash); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Embed that snippet on your site to rick-roll every Android 2.3 user | |
// by opening a video in fullscreen without asking for user permission | |
var v = document.createElement('video'); | |
v.src = 'http://vid297.photobucket.com/albums/mm238/daystar170/RickRoll.mp4'; | |
v.load(); | |
document.body.appendChild(v); | |
setTimeout(function() { | |
// jumping to a certain position is also possible | |
// v.currentTime = 0; | |
v.play(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Using importScripts in a file which was imported via importScripts prevents loading following scripts.</title> | |
<script> | |
var worker = new Worker('worker_bug2.js'); | |
var callCount = 0; | |
worker.addEventListener('message', function() { | |
callCount++; | |
}, false); | |
setTimeout(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Loading an empty JS-file within worker#importScripts prevents loading following requests</title> | |
<script> | |
var worker = new Worker('worker_bug1.js'); | |
var callCount = 0; | |
worker.addEventListener('message', function() { | |
callCount++; | |
}, false); | |
setTimeout(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require([], function() { | |
describe('bar', function() { | |
// ... | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var b = new Blob(); | |
var u = window.URL.createObjectURL(b); | |
var w = new Worker(u); // throws Security Error in IE 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import os | |
from tastypie.fields import FileField | |
from django.core.files.uploadedfile import SimpleUploadedFile | |
class Base64FileField(FileField): | |
""" | |
A django-tastypie field for handling file-uploads through raw post data. | |
It uses base64 for en-/decoding the contents of the file. | |
Usage: |