Skip to content

Instantly share code, notes, and snippets.

View peterbsmyth's full-sized avatar

Peter B Smith peterbsmyth

View GitHub Profile
fetch("https://fcctop100.herokuapp.com/api/fccusers/top/recent")
.then(response => {
return response.json().then(json => ({ json, response }))
}).then(({ json, response }) => {
if (!response.ok) {
return Promise.reject(json);
}
// Do Stuff with JSON HERE
// for example...
function takesACallBack(something, callback) {
callback(something);
}
function logger(argument) {
console.log(argument);
@peterbsmyth
peterbsmyth / api.cycle.md
Last active September 24, 2016 03:28
Brainstorming API Dev Process

API Cycle Time

Brainstorming by Peter B Smith

  • Develop a test suite of ~100 routes to build out
    • Query by:
      1. Date
      2. API Key
  • Sever from scratch
    • 1,000 requests per second test suite
  • 10 - 100 routes and Queries
---
# roles/auto-scaling/tasks/main.yml
- name: Retrieve current Auto Scaling Group properties
command: "aws --region {{ region }} autoscaling describe-auto-scaling-groups --auto-scaling-group-names webapp"
register: asg_properties_result
- name: Set asg_properties variable from JSON output if the Auto Scaling Group already exists
set_fact:
asg_properties: "{{ (asg_properties_result.stdout | from_json).AutoScalingGroups[0] }}"
@peterbsmyth
peterbsmyth / helpers.lua
Created March 5, 2017 17:14
sample helpers file
local crud = require "kong.api.crud_helpers"
local helpers = require "kong.plugins.YOUR-PLUGIN.helpers"
return {
["/fantastics/"] = {
POST = function(self, dao_factory)
crud.post(self.params, dao_factory.voices)
end,
<!-- Drip -->
<script type="text/javascript">
var _dcq = _dcq || [];
var _dcs = _dcs || {};
_dcs.account = '<YOUR_ACCOUNT_ID>';
(function() {
var dc = document.createElement('script');
dc.type = 'text/javascript'; dc.async = true;
dc.src = '//tag.getdrip.com/<YOUR_ACCOUNT_ID>.js';
declare const _dcq: any;
declare const _dcq: any;
import { Injectable } from '@angular/core';
@Injectable()
export class DripService {
submitSubscriber() {
return new Promise((resolve, reject) => {
_dcq.push(["identify", {
email: "test@mailinator.com",
import { Component } from '@angular/core';
import { DripService } from './drip.service';
@Component({
selector: 'app-root',
template: `
<h1>
{{ (response | async)?.email }}
</h1>
`
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
@Injectable()
export class UserService {
private usersUrl = 'https://jsonplaceholder.typicode.com/users';