Skip to content

Instantly share code, notes, and snippets.

View dallashuggins's full-sized avatar
🏠
Working from home

Dallas Huggins dallashuggins

🏠
Working from home
  • Nottingham, New Hampshire
View GitHub Profile
@dallashuggins
dallashuggins / compareVersions.js
Created July 6, 2019 03:36
Compare the versions of two software versions
const compareVersions = (firstVersion, secondVersion) => {
let done = false
try {
const firstVersionArray = firstVersion.split('.')
const secondVersionArray = secondVersion.split('.')
let i = 0
let length = firstVersionArray.length
do {
let first = parseFloat(firstVersionArray[i])
let second = parseFloat(secondVersionArray[i])
@dallashuggins
dallashuggins / parseParams.js
Created July 6, 2019 03:22
Example of a function that gets the current URL and parses the query parameters and stores in sessionStorage.
// Parse query params:
export default () => {
let finalParams
try {
const paramArray = window.location.search.replace('?', '').split('&')
const params = {}
paramArray.map((param, i) => {
if (param) {
const pair = param.split('=')
const key = pair[0]
@dallashuggins
dallashuggins / dynamicTable.js
Last active July 6, 2019 02:16
Dynamic Table for JS interview
function table ({ columns, items }) {
return (
<table>
<thead>
<tr>
{columns.map(col => (
<th>{col.key}</th>
))}
</tr>
</thead>
@dallashuggins
dallashuggins / asynchronousRecursive.js
Created July 5, 2019 03:50
Asynchronous recursive function that loops through all pages of results. There's a delay because of the large number of entities in the response, so you'll see my comment about what to add if you don't want to wait.
const axios = require('axios');
const util = require('util');
const getEntity = async (page) => {
try {
let options = {};
options.method = "GET";
options.url = 'https://pokeapi.co/api/v2/pokemon';
options.headers = {};
@dallashuggins
dallashuggins / pr_function
Created October 1, 2018 17:12
Recently built function to retrieve matches from Pocket Recruiter
const rp = require('request-promise');
const util = require('util');
const _ = require('underscore');
const Promise = require('bluebird');
var moment = require('moment');
const authenticate = async (credentials) => {
try {
let options = {};
options.method = "POST";
@dallashuggins
dallashuggins / issues
Created June 13, 2018 18:42
FOUND ISSUES: Schema (first try, no tail)
FOUND ISSUES [
{
"type": "missing_id_field",
"message": "schema type definitions must include a unique identifier field (fields.ID)",
"severity": "error",
"context": {
"dataType": "opportunitycompetitorscollection"
}
},
{
@dallashuggins
dallashuggins / getaddrinfo
Last active June 12, 2018 15:59
Bedrock Data Microsoft Dynamics ctscan errors: getaddrinfo
This file has been truncated, but you can view the full file.
> bedrockdata_fusion_microsoft_dynamics@1.0.0 start /Users/dally/Desktop/Left Hook/Bedrock/bedrock_fusion_microsoft_dynamics_2
> node start.js
Dynamics server listening on 56009
GET /v3/agents/microsoftdynamics42/auth?customer=000000000000000000000000
Final setting for handleAuth: { token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImlCakwxUmNxemhpeTRmcHhJeGRacW9oTTJZayIsImtpZCI6ImlCakwxUmNxemhpeTRmcHhJeGRacW9oTTJZayJ9.eyJhdWQiOiJodHRwczovL2JlZHJvY2tkYXRhLmNybS5keW5hbWljcy5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8yODIyNTYyNC03ODYwLTRmYzYtOWQ1ZS0zNmFlMjhlN2VjOTgvIiwiaWF0IjoxNTI4ODE4NjM5LCJuYmYiOjE1Mjg4MTg2MzksImV4cCI6MTUyODgyMjUzOSwiYWNyIjoiMSIsImFpbyI6IlkyZGdZUGdvSkZyaUZxUThMZlpwZm4vSWhZOUN2VGFSVndzbmJtVlFtYkh3UXZmcFI0b0EiLCJhbXIiOlsicHdkIl0sImFwcGlkIjoiNzI1ZTljZWYtNTlmZC00Y2Q5LThkMTMtZjM5Mzg0MzMwYjJiIiwiYXBwaWRhY3IiOiIxIiwiZV9leHAiOjI2MjgwMCwiZmFtaWx5X25hbWUiOiJNb3R0IiwiZ2l2ZW5fbmFtZSI6IkFkcmlhbiIsImlwYWRkciI6IjI0LjYxLjExMC45NiIsIm5hbWUiOiJBZHJpYW4gTW90dCIsIm9pZCI6ImU0M2UyMzg5LTA0ZTEtNGNhNC1hZWQ5L
@dallashuggins
dallashuggins / console log
Created June 11, 2018 17:23
Bedrock Data Microsoft Dynamics error: CAUGHT ERR { StatusCodeError: 422 - {"message":"Unexpected token u in JSON at position 0"}
Dallass-MacBook-Pro-8:ctscan dally$ ctscan test http://localhost:56009 microsoftdynamics34
body-parser deprecated undefined extended: provide extended option src/fake_hyper.js:13:30
Fake Hyper server listening on 4000
RUNNING TESTS http://localhost:56009 microsoftdynamics34
TESTING auth microsoftdynamics34 undefined
GET AGENT CALLED { agent: 'microsoftdynamics34' } { custId: '000000000000000000000000' }
GET LOCATOR CALLED { identity: '5b1e9eec7394fb1fb242a791' } { custId: '000000000000000000000000' }
QUERY IDENTITY LOCATOR { _id: 5b1e9eec7394fb1fb242a791 }
DECRYPT SECRETS CALLED { custId: '000000000000000000000000',
identityLocator: '{"_id":"5b1e9eec7394fb1fb242a791","resource":"5b1e9eec9d8cb16fd15832f8","createdAt":"2018-06-11T16:10:20.868Z","accessToken":"token"}' }
@dallashuggins
dallashuggins / Shopify-Bedrock API Call Limit script.js
Last active March 5, 2018 19:47
Shopify/Bedrock API Call Limit script - check for API limit in headers returned from response
var api_call_limit = response.headers['http_x_shopify_shop_api_call_limit'];
var current_limit = api_call_limit.split('/')[0];
console.log("Current API Call Limit", current_limit);
var future_limit = api_call_limit.split('/')[1];
console.log("Future API Call Limit", future_limit);
var results, items, cursor;
items = response.body.customers;
// when we reach the api limit, set timeout
if (future_limit > current_limit) {
console.log("No timeout needed");