Skip to content

Instantly share code, notes, and snippets.

@davidwhitney
davidwhitney / CouchDb quickstart example
Created March 14, 2011 22:53
CouchDb quickstart example
using System;
using System.Web.Mvc;
using Divan;
using Newtonsoft.Json;
namespace CouchTest.Controllers
{
[HandleError]
public class HomeController : Controller
{
@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;
}
@bgrins
bgrins / gist:1789787
Created February 10, 2012 13:58
C# Multipart File Upload
// Implements multipart/form-data POST in C# http://www.ietf.org/rfc/rfc2388.txt
// http://www.briangrinstead.com/blog/multipart-form-post-in-c
public static class FormUpload
{
private static readonly Encoding encoding = Encoding.UTF8;
public static HttpWebResponse MultipartFormDataPost(string postUrl, string userAgent, Dictionary<string, object> postParameters)
{
string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid());
string contentType = "multipart/form-data; boundary=" + formDataBoundary;
@devfred
devfred / RequesQ.js
Last active March 7, 2016 23:18
javascript: Xhr with queue example
/* Queue to use in conjuction with xhr functionality */
var requestQ = (function() {
var numRequestToComplete, requestsCompleted, callBacks, singleCallBack;
return function(options) {
if (!options) options = {};
numRequestToComplete = options.numRequest || 0;
requestsCompleted = options.requestsCompleted || 0;
callBacks = [];
var fireCallbacks = function() {
/* alert("we're all complete"); */
@nicerobot
nicerobot / README.md
Created December 2, 2012 19:18
Create Google Drive webViewLink folders via JavaScript.

Create Google Drive webViewLink folders via JavaScript (You must change CLIENT_ID before this will work.)

These folders are suitable for publishing websites. Once the folder is created, simply upload index.html and other resources to the folder.

@entaq
entaq / Google_OAuth2.js
Created December 20, 2012 21:43
Simple Google+ OAuth 2.0 calls in Apps Script
/**
reference -
https://developers.google.com/accounts/docs/OAuth2WebServer
https://code.google.com/apis/console/
https://developers.google.com/+/api/latest/
**/
////handle all requests here
function doGet(e) {
@dhlavaty
dhlavaty / RestApi.cs
Created January 2, 2013 09:54
Simplest method to do a REST API calls in c# with basic .NET classes (no external library needed). I use it when communicationg with Recurly.com REST services.
/*
Simplest method to do a REST API calls in c# with basic .NET classes.
I use it when communicationg with Recurly.com REST services.
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
@peter
peter / rack-rest-api-example.rb
Created January 31, 2013 19:06
An example of how to write a simple JSON REST API with a simplistic router directly on top of Rack (i.e. without the use of a framework like Sinatra).
#################################################################
#
# File: lib/api.rb
#
#################################################################
require 'user' # ActiveRecord model
# Connect to the db
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
@andsens
andsens / sign_s3.gs
Last active August 9, 2016 18:21
Google spreadsheet function for signing S3 URLs (very handy for CSV cost allocation reports when combined with the ImportData() function)
function sign_s3(access_key, private_key, bucket, object_name, validity, base_url) {
if(!base_url) {
base_url = "http://s3.amazonaws.com";
}
if(!validity) {
validity = 60;
}
expires = Math.floor((new Date()).getTime() / 1000) + validity;
object_name = encodeURIComponent(object_name);
stringToSign = "GET\n\n\n"+expires+"\n/"+bucket+"/"+object_name;
@mogsdad
mogsdad / GCalUtils.md
Last active May 10, 2021 17:39
Collection of Google Calendar related utility functions for Google Apps Script.

Google Calendar Utilities

getEventsWithGuest

Gets all events that occur within a given time range, and that include the specified guest email in the guest list.

###Parameters:###