- JSON is faster for small size data
- map (key size < 50 and Unmarshalling intensive workload)
- single struct
- gob is faster for big size data
- map (key size > 50 or Marshalling intensive workload)
- slice
/* | |
Author: https://github.com/gorhill | |
Source: https://gist.github.com/gorhill/5285193 | |
A Go function to render a number to a string based on | |
the following user-specified criteria: | |
* thousands separator | |
* decimal separator |
Using MongoDB in golang with mgo |
/** Returns a PDF object based on the contents of the 'invoicing' sheet */ | |
function invoiceToPDF(invDetails) | |
{ | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
ssID = spreadsheet.getId(); | |
var sheet = spreadsheet.getSheetByName(INVOICES_SHEETNAME); | |
var gid = sheet.getSheetId(); | |
// &gid=x at the end of above url if you only want a particular sheet | |
var url2 = "http://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=" + ssID + |
package main | |
import ( | |
"flag" | |
"io" | |
"log" | |
"net" | |
"net/http" | |
"strings" | |
) |
function doGet(request) { | |
if (request.parameters.url != undefined && request.parameters.url != "") { | |
var imageBlob = UrlFetchApp.fetch(request.parameters.url).getBlob(); | |
var resource = { | |
title: imageBlob.getName(), | |
mimeType: imageBlob.getContentType() | |
}; | |
var options = { | |
ocr: true | |
}; |
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
To send a request via the sandbox, you can use pm.sendRequest.
pm.test("Status code is 200", function () {
pm.sendRequest('https://postman-echo.com/get', function (err, res) {
pm.expect(err).to.not.be.ok;
pm.expect(res).to.have.property('code', 200);
pm.expect(res).to.have.property('status', 'OK');
});
});
package main | |
import ( | |
"log" | |
"net/rpc" | |
) | |
type ToDo struct { | |
Title, Status string | |
} |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
type Person struct { | |
Name string | |
Age int |