Skip to content

Instantly share code, notes, and snippets.

View scottjason's full-sized avatar

Scott Jason scottjason

  • San Francisco, CA
View GitHub Profile
@scottjason
scottjason / pipe.js
Last active October 6, 2020 20:45
function composition with pipe
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
const users = [
{ name: "Jeff", age: 34 },
{ name: "Jack", age: 28 },
{ name: "Milady", age: 29 },
];
export const extractFirstName = cb => arr => arr.map(cb);
export const transformNames = cb => arr => arr.map(cb);
@scottjason
scottjason / atrium.js
Created January 30, 2019 02:52
atrium-challenge
/*
Your previous Markdown content is preserved below:
## Instructions
Welcome to Atrium's technical code challenge!
CoderPad will allow you to write and run code in the language of your choice. Switch the language in the upper right corner of the window.
Please complete the code challenge in no more than one hour from your scheduled time. Only code completed within one hour and developed within coderpad will be reviewed.
@scottjason
scottjason / atrium.js
Created January 30, 2019 02:52
atrium-challenge
/*
Your previous Markdown content is preserved below:
## Instructions
Welcome to Atrium's technical code challenge!
CoderPad will allow you to write and run code in the language of your choice. Switch the language in the upper right corner of the window.
Please complete the code challenge in no more than one hour from your scheduled time. Only code completed within one hour and developed within coderpad will be reviewed.
@scottjason
scottjason / aspire-request.js
Last active January 7, 2019 01:18
aspire-request
const https = require('https')
const request = require('request');
const port = 3000;
const url = 'https://api.appspot.com/api/instagram/account/1';
function makeRequest() {
request.get(url, function(error, response, body) {
console.log('response', response.statusCode) // 404
-- NAME: % FRS with Requests By Month 08089
-- DISPLAY: Percent FRS with Requests By Month
-- ID 35146
WITH
help_requested_sessions AS (SELECT DISTINCT session_id FROM is_oaklabs.production_mirror_events
WHERE event='help.requested' AND oakos_location LIKE '%08089%'),
help_requested_session_inits AS (SELECT DISTINCT h.session_id, e.event, e.event_timestamp, DATE_TRUNC('month', e.event_timestamp) FROM help_requested_sessions h
LEFT JOIN is_oaklabs.production_mirror_events e
ON h.session_id = e.session_id
// [Log] Response From API Call Two On 'item.change' Event
var response = {};
response.data = {
"product": {
"_id": "5620b8a8398a4b537d0df56d",
"id": 71048306,
"storeCode": "POLO",
"gc": 4259989,
var results = [];
var app = {
initialize: function() {
var arr = [
this.generateMediaObj('imgs/avengers.jpg', "Avengers", "2012"),
this.generateMediaObj('imgs/blade_runner.jpg', "Blade Runner", "1982")
];
/* eachLimit(arr, limit, iterator, callback) */
async.eachLimit(arr, 1, this.makeRequest, this.onComplete);
function Media(boxCover, searchName, year) {
this.boxCover = boxCover;
this.searchName = searchName;
this.year = year;
this.genre = "";
this.imdbRating = "";
module.apiCall(this, module.init);
}
var module = {
@scottjason
scottjason / async-break-waterfall.js
Last active August 29, 2015 14:24
async-break-waterfall
/*
A user makes a request via his parking meter app on his iPhone.
The request is received by the actual parking meter and it now has the user obj.
The parking meter finds the user by id.
It checks the status, and if its expired it returns a response saying its expired.
-- Waterfall BreakPoint --
And if not, then by default the req body will have a minsToAdd prop (thats how they built it lol)
@scottjason
scottjason / gist:ac3aeba584bccf6ea0c5
Last active August 29, 2015 14:14
iswear response timing
function(host, guest, session, callback){
sessionFindOne({sessionId: session.sessionId}).then(function(promisedSession) {
/*
This assert test checks that the original session's _id is the same as the session _id in the one that gets pulled down.
This test wil throw an error.
When you log the result instead of running an assert test the strings are identical but ...
console.log("identical looking session id used to find session" === "identical looking promised session id") ...