Skip to content

Instantly share code, notes, and snippets.

View jpulec's full-sized avatar

James Pulec jpulec

View GitHub Profile
//## Moment.JS Holiday Plugin
//
//Usage:
// Call .holiday() from any moment object. If date is a US Federal Holiday, name of the holiday will be returned.
// Otherwise, return nothing.
//
// Example:
// `moment('12/25/2013').holiday()` will return "Christmas Day"
//
//Holidays:
@jpulec
jpulec / myrequest.js
Last active July 21, 2020 06:30
Request Wrapper
import request from 'request';
const myRequests = {
get: (...args) => request.get(...args),
post: (...args) => request.post(...args),
patch: (...args) => request.patch(...args),
delete: (...args) => request.delete(...args),
put: (...args) => request.put(...args),
};
@jpulec
jpulec / myrequest.js
Last active July 22, 2020 07:38
Request Replaced
import fetch from 'cross-fetch';
import _ from 'lodash';
const myRequests = {
get: (...args) => {
const urlOrOptions = args[0];
const cb = args[1];
let url;
let options;
@jpulec
jpulec / domystuff.js
Created July 3, 2020 01:52
MockRequest
import request from "request";
const myCoolFunction = (search, cb) => {
console.log(`Preparing to search for ${search}`);
request(`https://google.com/search/q=${search}`, cb);
}
@jpulec
jpulec / domystuff.js
Created July 3, 2020 01:54
Mock Wrapper
import wrapper from "./wrappers/request.js";
const myCoolFunction = (search, cb) => {
console.log(`Preparing to search for ${search}`);
wrapper(`https://google.com/search/q=${search}`, cb);
}