Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / OCR Scan
Created February 22, 2010 21:42
#!/bin/sh
SOURCE=""
if [ $# -gt 1 ]
then
SOURCE="--source ADF -l 3"
outname=$2
pbreak=$1
@mhawksey
mhawksey / gist:1442370
Last active February 25, 2024 12:01
Google Apps Script to read JSON and write to sheet
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;
}
@alexfu
alexfu / FragmentObserver.java
Last active April 6, 2021 03:26
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.
public class FragmentObserver extends Observable {
@Override
public void notifyObservers() {
setChanged(); // Set the changed flag to true, otherwise observers won't be notified.
super.notifyObservers();
}
}
@mogsdad
mogsdad / Apps Script pdfToText utility.md
Last active July 17, 2023 01:32
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.

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 / ViewUtils.java
Last active September 26, 2015 13:53
View utility functions that I find myself using often.
/*
* 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
@alexfu
alexfu / CursorExtenstions.kt
Created June 30, 2015 11:56
Android database cursor extensions that simplify retrieval of typed values
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))
@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active March 21, 2024 00:43
Example on how to export a Google sheet to various formats, includes most PDF options
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