Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / index.html
Created May 20, 2015 00:49
PouchDB putAttachment
<html>
<body>
<h1>Look in the console</h1>
<script src="//cdn.jsdelivr.net/pouchdb/3/pouchdb.min.js"></script>
<script>
var db = new PouchDB('mydb');
var myBase64String = btoa('foobar');
db.putAttachment('mydoc', 'myattachment.png', myBase64String, 'image/png').then(function () {
return db.get('mydoc', {attachments: true});
}).then(function (doc) {
@erickoledadevrel
erickoledadevrel / Code.js
Last active February 20, 2020 13:32
Remove multiple line breaks in a Googe Document using Apps Script
function removeMultipleLineBreaks(element) {
if (!element) {
element = DocumentApp.getActiveDocument().getBody();
}
var parent = element.getParent();
// Remove empty paragraphs
if (element.getType() == DocumentApp.ElementType.PARAGRAPH
&& element.asParagraph().getText().replace(/\s/g, '') == '') {
if (!(parent.getType() == DocumentApp.ElementType.BODY_SECTION
&& parent.getChildIndex(element) == parent.getNumChildren() - 1)) {
@nolanlawson
nolanlawson / index.html
Last active March 13, 2017 18:44
Demonstrate attachments in PouchDB
<html>
<body>
<pre id="display"></pre>
<script src="//cdn.jsdelivr.net/pouchdb/3.1/pouchdb.js"></script>
<script>
(function () {
'use strict';
var display = document.getElementById('display');
display.innerHTML = (display.innerHTML || '');
@Daniel15
Daniel15 / 1_README.md
Last active September 8, 2025 07:24
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

@jasonclark
jasonclark / booklist.js
Last active May 4, 2020 00:11
booklist javascript (jQuery) - calling google spreadsheet api, parsing response
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
//source Google Sheets file is https://docs.google.com/spreadsheets/d/1rX4_fInsYS7vOGpnXm1UklZgvU27FXl3UYu9lx9RHHU/
$(function listBooks() {
$.getJSON( "https://spreadsheets.google.com/feeds/list/1rX4_fInsYS7vOGpnXm1UklZgvU27FXl3UYu9lx9RHHU/1/public/full?alt=json",
function (data) {
$('div#book-list').append('<ul class="items"></ul>');
$.each(data.feed.entry, function(i,entry) {
var item = '<span style="display:none">' + entry.id.$t + '</span>';