Skip to content

Instantly share code, notes, and snippets.

Peter W techieshark

View GitHub Profile
View __mocks__stripe.ts
// __mocks__/stripe.ts: Jest Mock for Stripe class
* Fake a response from stripe.customers.list().
* @example
* mockStripeCustomerList(1) === { data: ['fake customer'], object: 'list', … }
* @param count number of fake customers to return
export const mockStripeCustomerList = (count: number) => ({
data: (new Array(count)).fill('fake customer'),
View send204.ts
import { NO_CONTENT } from 'http-status-codes';
const send204 = (req: Request, res: Response, next: NextFunction) => {
techieshark / setAllowHeader.ts
Created Aug 29, 2019
node: setAllowHeader()
View setAllowHeader.ts
import { NextFunction, Request, Response } from 'express';
* Sets Allow header.
* "The Allow header lists the set of methods support by a resource.
* This header must be sent if the server responds with a 405 Method Not Allowed
* status code to indicate which request methods can be used."
techieshark / index.js
Created Feb 22, 2019
View index.js
* Returns whether the current browser supports
* the `locales` argument of Number.prototype.toLocaleString().
* IE < 11 does not.
* Copied from
* @return {boolean} true if browser supports it, otherwise false.
* @see
function toLocaleStringSupportsLocales() {
const number = 0;
techieshark / objectValues.js
Created Feb 22, 2019
Flow-typed version of Object.values()
View objectValues.js
// @flow
// Flow-typed version of Object.values()
// @see: problem -
// @see: this solution -
export default function objectValues<A, B>(obj: {[key: A]: B}): Array<B> {
return ((Object.values(obj): any): Array<B>);
techieshark / pick.js
Created Feb 22, 2019
simple pick.js implementation
View pick.js
// @flow
* Returns new object made of the picked paths.
* Native implementation of lodash `pick`.
* Shaves 1-2kb off download size:
* @see
* @see
* @return {Object}
techieshark / australian-postcodes.sql
Created Jun 1, 2018 — forked from randomecho/australian-postcodes.sql
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
View australian-postcodes.sql
Taken and cribbed from
May contain errors where latitude and longitude are off. Use at own non-validated risk.
DROP TABLE IF EXISTS postcodes_geo;
techieshark / add_remove_class.js
Created May 24, 2018
add/remove class without jQuery (just Vanilla JS)
View add_remove_class.js
* Remove a CSS class from an HTML element.
* @param {HTMLElement} el The HTML element to modify.
* @param {string} className The class to remove.
* @returns null
* @see
function removeClass(el, className) {
if (el.classList)

Keybase proof

I hereby claim:

  • I am techieshark on github.
  • I am techieshark ( on keybase.
  • I have a public key ASAGfHHdWMNLxRSipw5fj5uzzNELExUqoXtBuY0RPYw41go

To claim this, I am signing this object:

View CLA-school-finder
# Contributor License Agreement
The following terms are used throughout this agreement:
* You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.
* Project - School Finder project located at
* Contribution - any type of work that is submitted to a Project, including any modifications or additions to existing work.
* Submitted - conveyed to a Project via a pull request, commit, issue, or any form of electronic, written, or verbal communication with GitHub, Code for Australia, Peter W, contributors or maintainers.
1. Grant of Copyright License.
You can’t perform that action at this time.