Skip to content

Instantly share code, notes, and snippets.

View tonmcg's full-sized avatar

Tony McGovern tonmcg

View GitHub Profile
@d3noob
d3noob / .block
Last active April 8, 2024 12:19
Simple d3.js Graph
license: mit
// v2
/* UPDATE 13/02/2022
Added columns argument and made each optional
*/
// Returns an array of unique random numbers
RANDUNIQUE =
LAMBDA([rows],[columns],[min],[max],
@MarkTiedemann
MarkTiedemann / power-query-pagination.m
Last active March 5, 2024 23:43
Power Query Pagination Example
let
BaseUrl = "https://fake-odata-api.com/v1/Entities?",
Token = "F4K3-T0K3N-D0NT-U5E-L0L",
EntitiesPerPage = 1000,
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyweiss1982
andyweiss1982 / Dad Joke API Example.EXCEL.yaml
Created October 30, 2020 19:37
Very basic implementation of fetching data and putting into Excel
name: Dad Joke API Example
description: Very basic implementation of fetching data and putting into Excel
host: EXCEL
api_set: {}
script:
content: |
const button = document.querySelector("button");
button.addEventListener("click", run);
async function getRandomDadJoke(){
@CurtHagenlocher
CurtHagenlocher / Web.ContentsCustomRetry.m
Created April 30, 2015 13:08
Demonstrates the use of a custom retry duration with Web.Contents.
let
Value.WaitFor = (producer as function, interval as function, optional count as number) as any =>
let
list = List.Generate(
() => {0, null},
(state) => state{0} <> null and (count = null or state{0} < count),
(state) => if state{1} <> null
then {null, state{1}}
else {1 + state{0}, Function.InvokeAfter(() => producer(state{0}), interval(state{0}))},
(state) => state{1})
@CurtHagenlocher
CurtHagenlocher / multipart.m
Created July 20, 2015 20:18
Using multipart/form-data with Power Query. This assumes that any files being uploaded are textual; changing this to support arbitrary binary data is possible, but wasn't interesting to me.
let
Web.MultiPartPost = (url as text, parts as record) as binary =>
let
unique = Text.NewGuid(),
boundary = "--" & unique,
crlf = "#(cr)#(lf)",
item = (name, value) =>
let
filename = Value.Metadata(value)[name]?,
contentType = Value.Metadata(value)[type]?,
@mckneisler
mckneisler / QuickBooksOnline Code.txt
Last active March 19, 2021 15:58
QuickBooks Online API Example for VBA
Public Function quote(sString As String) As String
quote = Chr(34) + sString + Chr(34)
End Function
Public Function URLEncode(sString As String) As String
Dim iLen As Integer
iLen = Len(sString)
If iLen > 0 Then
ReDim sResult(iLen) As String
@oscarperpinan
oscarperpinan / code_without_ggplot2.R
Last active December 20, 2019 10:43
beautiful-thematic-maps: alternative code without using ggplot2
## https://timogrossenbacher.ch/2016/12/beautiful-thematic-maps-with-ggplot2-only/
library(raster)
library(sp)
library(rgdal)
library(viridisLite)
library(rasterVis)
## Read age data
data <- read.csv("input/avg_age_15.csv", stringsAsFactors = F)
## Read shapefile
@Aymkdn
Aymkdn / spservices-startworkflow.js
Created October 11, 2012 15:22
Start a workflow with Sharepoint (JavaScript)
/**
* Start a workflow
*
* @param {Object} params
* @param {String} params.listName The name of the list
* @param {Number} params.itemID The item ID
* @param {String} params.workflowName The name of the workflow
* @param {Array|Object} [params.parameters] An array of object with {Name:"Name of the parameter", Value:"Value of the parameter"}
* @param {Function} [params.after] Callback after the request is done
*/