Skip to content

Instantly share code, notes, and snippets.

@ronatgithub
ronatgithub / README.md
Created November 3, 2015 12:12 — forked from aronwoost/README.md
How to install node.js and CouchDB on a Google Compute Engine instance

#How to install node.js and CouchDB on a Google Compute Engine instance

Start and ssh into instance

Make sure you have a Google Compute engine account, have a project created and the gcutil command line tool installed.

Since want to ssh without the gcutil tool, you need to a your ssh key to the instance in addition to the already existing google_compute_engine key (used for gcutil).

@ronatgithub
ronatgithub / index.html
Last active August 29, 2015 14:26 — forked from nolanlawson/index.html
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 || '');
@ronatgithub
ronatgithub / index.html
Last active August 29, 2015 14:26 — forked from nolanlawson/index.html
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) {
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
@ronatgithub
ronatgithub / code
Last active July 6, 2017 20:30
HTML Form to send data to google spreadsheet using Google App Script
// the HTML code on your site:
<form id="form" method="get" action="https://script.google.com/macros/s/AKfycbxeKTVlTkqSGLIRphBrzACjuWlfmejbPIG7NqBxx-7Us7lnqLw/exec" accept-charset="UTF-8">
<input type="text" name="newletter_name" placeholder="Name">
<input type="text" name="newletter_email" placeholder="Email">
<input type="submit" value="Subscribe"/>
</form>
// and here the google apps script:
@ronatgithub
ronatgithub / gist:5a06f5dbfef4f05ef60e
Last active August 29, 2015 14:17
Google App Script - mail pdf from merged documents
// set time trigger to mergeGoogleDocs() function to run once a day at midnight
function mergeGoogleDocs() {
// set folder ID were we should look for files to merge
var folder = DriveApp.getFolderById('0BwqqMAWnXFBhMmJjM3FZakw2b1k');
var docIDs = [];
var files = folder.getFiles();
while (files.hasNext()){
file = files.next();
docIDs.push(file.getId());

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/

@ronatgithub
ronatgithub / code.js
Created March 13, 2015 01:42
Send Google Form by Email using Google Apps Script
/* Send Google Form by Email v2.1 */
/* For customization, contact the developer at amit@labnol.org */
/* Tutorial: http://www.labnol.org/?p=20884 */
function Initialize() {
var triggers = ScriptApp.getProjectTriggers();
@ronatgithub
ronatgithub / code.js
Created March 12, 2015 22:55
merge multiple documents and remove all extra line breaks using Google Apps Script
function mergeGoogleDocs() {
var folder = DriveApp.getFolderById('0BwqqMAWnXFBhMiJjM6FZakw9b1k'); // set folder ID were we should look for files to merge
var docIDs = [];
var files = folder.getFiles();
while (files.hasNext()){
file = files.next();
docIDs.push(file.getId());
}