Skip to content

Instantly share code, notes, and snippets.

I would like to sort the following JSON string:

'{"france":{"bordeaux":{"st emmilion":["gran crue"]},"burgundy":{"cote de nuits":{"chambolle musigny":["le musigny"]}}}}'

Into this output

region_one = [['France', 'france']] region_two = [['Bordeaux', 'bordeaux', class: 'france'], ['Burgundy', 'burgundy', class: 'france']] region_three = [['St Emmilion', 'st emmilion', class: 'bordeaux'], ['Cote De Nuits', 'cote de nuits', class: 'burgundy']] region_four = [['Gran Crue', 'gran crue', class: 'st emmilion'], ['Chambolle Musigny', 'chambolle musigny', class: 'cote de nuits']]

@lukebyrne
lukebyrne / question.md
Last active August 31, 2015 04:55
Reverse recursion

How would I go about searching this hash of hashes for a wine growing region for the final branch of the tree for the key of Vista Flores.

{
    "Argentina": {
        "Catamarca": [],
        "Cuyo": [],
        "Fiambala": [],
        "Jujuy": [],
        "La Rioja": {
require 'yaml'
require 'pp'
require 'json'
json = '{"australia":["some", "wines"]}'
regions = JSON.parse(json)
results = {}
@lukebyrne
lukebyrne / gist:8794e13c8a60467fd3bcab7f77748d9f
Last active March 12, 2020 02:49
Australian State Boundaries for Postgis geometry(MultiPolygon,4326 )
===============
South Australia
===============
0106000020E6100000020000000103000000010000001D000000CE0702B31633614083BD132C8ADE41C07E88A0CCBF3A61400B75E2F888E141C0305BF404B93D61407E8CB69CEDDC41C082A571197D416140FA76A4EEABE041C0AC2E9C75F343614006825A361DED41C02056531421426140EB2B7DBB46F341C00EFA473D61406140D84D40B12BF441C09C71F204BC3A6140A814145512EF41C0884622B8783561404ECA202CEEF241C030B75EC2E83361401E73B3EE15F841C028240C0AE332614073212155760342C024C2F4DB592E6140C45BDD73910942C0941F12E13B2C6140BAB6CE9CAF0242C054DDEF5BB42661406DB8272CC2FD41C0D2B87347BB24614007ABE44AFD0442C074397147D420614034505E5F0F0342C02A6D5A19351D6140587441DAF70542C09EC1190F291861402C8C730D3D0442C0DECC5399DA126140B0D9232CB6F741C07A0B5D704C116140FC00C49CF3F141C01050729E8712614064AC4C5F7FE741C00C41922370146140A2B09917D6DF41C00E937247F0226140CA8A5FE4FAD441C01875C97FB12A61401461A1C5D9CB41C03C651FB8F83061401A92FE5476CD41C052C12A8FB8326140ECEC844064CF41C04AE8B07A553461403DF9358807D441C07424B07A23336140DB27085570DC41C0CE0702B31633614083BD132C8ADE

Problem

We have an issue with the querying of our API, specifically the count of stores that get returned for a query, lat/lng versus a product_id, lat/lng.

First API Call

One the first API call (use postman, curl or a plain browser to view results)

https://app.frootbat.com/api/v4/products_group_by_sizes?lat=36.778261&lng=-119.4179324&page=1&query=Suntory%20Hibiki%20Limited%2017%20Year%20Old%20Blended%20Whisky%20750

We are quering for Suntory Hibiki Limited 17 Year Old Blended Whisky 750 at a lat/lng of 37.8857582/-122.1180201.

@lukebyrne
lukebyrne / problem.md
Last active July 21, 2017 06:44
Need to aggregate by currency

Requirements

We are updating our API to return currency conversions for all prices and currencies that we have. You can see that here, in the amount_by_currency

So in the API call for products_group_by_sizes we are returning lowPrice, avgPrice and highPrice, we would also like to return an amount_by _currency field here that will have the lowPrice, avgPrice and highPrice for each store amount_by_currency that is in the index production_compare-product_searches_group_by_sizes.

Here is the link to Kibana, I will send the password via Skype, the username is elastic

Below is the current query we are using.

[
{
"id": 522,
"currency_symbol": "$",
"currency_code": "USD",
"amount": 11.99,
"amount_by_currency": [
{
"symbol": "$",
"code": "AUD",
@lukebyrne
lukebyrne / house-prices-random-forrest.ipynb
Created September 6, 2018 07:25
A Jupyter notebook running though the Fast AI Random Forrest Machine Learning tutorials to apply to https://www.kaggle.com/c/house-prices-advanced-regression-techniques
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require('dotenv').config()
const cors = require('cors')
const bodyParser = require('body-parser')
const express = require('express')
const expressJwt = require('express-jwt')
const cookieSession = require('cookie-session')
const jwt = require('jsonwebtoken')
const passport = require('passport')
const GoogleStrategy = require('passport-google-oauth20').Strategy
const jwtSecret = Buffer.from('Zn8Q5tyZ/G1MHltc4F/gTkVJMlrbKiZt', 'base64')
import decode from 'jwt-decode';
import axios from 'axios';
import auth0 from 'auth0-js';
import Router from 'vue-router';
import Auth0Lock from 'auth0-lock';
const ID_TOKEN_KEY = 'id_token';
const ACCESS_TOKEN_KEY = 'access_token';
const CLIENT_ID = '{AUTH0_CLIENT_ID}';
const CLIENT_DOMAIN = '{AUTH0_DOMAIN}';