Skip to content

Instantly share code, notes, and snippets.

@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active Oct 16, 2021
Example on how to export a Google sheet to various formats, includes most PDF options
View exportSpreadsheet.gs
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@alexfu
alexfu / CursorExtenstions.kt
Created Jun 30, 2015
Android database cursor extensions that simplify retrieval of typed values
View CursorExtenstions.kt
import android.database.Cursor
/**
* CursorExtentions
*
* Android database cursor extensions that simplify retrieval of typed values
* @author alexfu
*/
fun Cursor.getInt(colName: String): Int {
return this.getInt(this.getColumnIndex(colName))
@alexfu
alexfu / ViewUtils.java
Last active Sep 26, 2015
View utility functions that I find myself using often.
View ViewUtils.java
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 Alex Fu
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@mogsdad
mogsdad / Apps Script pdfToText utility.md
Last active Aug 24, 2021
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.
View Apps Script pdfToText utility.md

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);
    
@alexfu
alexfu / FragmentObserver.java
Last active Apr 6, 2021
Observer pattern for notifying Fragments of a ViewPager to update their views. This will update the current Fragment, as well as the off screen Fragments that are retained.
View FragmentObserver.java
public class FragmentObserver extends Observable {
@Override
public void notifyObservers() {
setChanged(); // Set the changed flag to true, otherwise observers won't be notified.
super.notifyObservers();
}
}
@mhawksey
mhawksey / gist:1442370
Last active Sep 22, 2021
Google Apps Script to read JSON and write to sheet
View gist:1442370
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;
}
View OCR Scan
#!/bin/sh
SOURCE=""
if [ $# -gt 1 ]
then
SOURCE="--source ADF -l 3"
outname=$2
pbreak=$1