Skip to content

Instantly share code, notes, and snippets.

@timhall
timhall / gist:3494261
Created August 28, 2012 02:03
Javascript inheritance (slight additions to backbone's implementation)
// Subclass given parent class and extend with prototype and static properties
// (inherits helper from Backbone.js)
var inherits = function (parent, protoProps, staticProps) {
var child;
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function () { parent.apply(this, arguments); };
}
@timhall
timhall / gist:3494452
Created August 28, 2012 02:44
Example implementation of inheritance implementation
var Parent = function (name) {
var _parent = this;
_parent.name = name;
}
Parent.prototype.sayHi = function () {
return 'Hi ' + this.name + '!';
}
Parent.sayHowdy = function () { return 'Howdy!' }
extendable(Parent);
@timhall
timhall / rAF-polyfill-performance.js
Created November 15, 2012 13:17
Updated requestAnimationFrame polyfill that uses new high-resolution timestamp
// Updated requestAnimationFrame polyfill that uses new high-resolution timestamp
//
// References:
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// https://gist.github.com/1579671
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
//
// Note: this is my initial stab at it, *requires additional testing*
(function () {
@timhall
timhall / gist:c88e52a71acc45243bbb
Last active October 23, 2017 22:14
Excel-REST - Smartsheet API: Update
' curl https://api.smartsheet.com/1.1/row/{rowId}/cells \
Dim Request As New RestRequest
Request.Resource = "row/{rowId}/cells"
Request.AddUrlSegment "rowId", "RowId..."
' -H "Authorization: Bearer ACCESS_TOKEN" \
Request.AddHeader "Authorization", "Bearer ACCESS_TOKEN is set in authenticator"
' -H "Content-Type: application/json" \
Request.RequestFormat = json
@timhall
timhall / gist:bab59824216aefb5f61b
Created November 9, 2014 02:03
Excel-REST Basic Authentication
' Create Client
Dim Client As New RestClient
Client.BaseUrl = "https://..."
' Create HttpBasicAuthenticator
' https://github.com/timhall/Excel-REST/tree/master/authenticators
Dim Auth As New HttpBasicAuthenticator
Auth.Setup "Username", "Password"
' Add Authenticator to Client
@timhall
timhall / gist:2734e7d858a7d8c54360
Last active March 8, 2024 20:19
VBA-Web - Google Calendar API
' (Based of Analytics example)
' In Client setup, set BaseUrl and Scope for Calendar
Client.BaseUrl = "https://www.googleapis.com/calendar/v3/"
Auth.AddScope "calendar"
Public Type CalendarEvent
Summary As String
Location As String
Attendees As Collection
StartTime As Date
@timhall
timhall / Crunchbase.bas
Created February 13, 2015 01:12
Crunchbase VBA-Web Example
Private Const UserKey As String = "YOUR-USER-KEY"
Private pClient As WebClient
Public Property Get Client() As WebClient
If pClient Is Nothing Then
Set pClient = New WebClient
pClient.BaseUrl = "https://api.crunchbase.com/v/2/"
End If
Set Client = pClient
''
' Xing Authenticator
'' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
Implements IWebAuthenticator
Option Explicit
' --------------------------------------------- '
' Constants and Private Variables
' --------------------------------------------- '
''
' Todoist Authenticator
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
'
' Custom IWebAuthenticator for TODOist API
' https://developer.todoist.com/#oauth
' ```
'
' @class TodoistAuthenticator
' @implements IWebAuthenticator v4.*
@timhall
timhall / d3.compose functional.md
Last active November 18, 2015 15:23
d3.compose functional

Goals

Apply functional techniques to make d3.compose easier to reason about, more testable, and better match d3's standard approach

Implementation

Use a "smart"/"dumb" components approach (reference) with "smart" component handling logic, state, and context and "dumb" component handling rendering.

  • The "dumb" component is stateless and is a simple, idempotent function that takes in a d3.selection and properties and renders the chart.
  • The "smart" component provides the API for interacting with Compose, prepares properties for the "dumb" component, and handles any logic/state