Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: download.sh file ..."
exit 1
fi
for fn in "$@"
do
if [ -r "$fn" ] ; then
printf '\033]1337;File=name='`echo -n "$fn" | base64`";"
wc -c "$fn" | awk '{printf "size=%d",$1}'
var setupLTIScrollRequest = function() {
window.addEventListener('message', function(e) {
try {
var message = JSON.parse(e.data);
if (message.subject === 'lti.scrollTop') {
$('html,body').animate({
scrollTop: $('.tool_content_wrapper').offset().top + message.scrollTop
}, message.animate);
}
} catch(err) {
@zwily
zwily / useFirebaseUpdater.js
Created March 10, 2019 20:56
Firebase throttled updater hook
import { useState, useRef } from "react";
import { useDocument } from "react-firebase-hooks/firestore";
import throttle from "lodash/throttle";
// Hook that gives you an updater function that will do throttled
// updates to a firebase document, and provide back to you views of
// the updated data (before it has persisted).
//
// arguments: a Document ref, and time in ms to throttle
// returns an object with following fields:
@zwily
zwily / expo-firestore-persistence-hack.js
Last active October 24, 2024 05:29
A fragile weaving of various modules together to convince the Firestore web SDK to use persistence in an un-ejected Expo app.
/*
expo-firestore-persistence-hack
A fragile weaving of various modules together to convince the Firestore
web SDK to use persistence in an un-ejected Expo app.
To use, first:
```
$ expo install expo-sqlite