Skip to content

Instantly share code, notes, and snippets.

View dimitrisdovinos's full-sized avatar

Dimitris dimitrisdovinos

View GitHub Profile
@dimitrisdovinos
dimitrisdovinos / awsCallTokenEndpoint.js
Last active January 18, 2019 14:02
Javascript for getting the authorization code from Cognito
const axios = require('axios');
const debug = require('debug')('auth');
const config = require('../../config');
const qs = require('qs');
async function awsCallTokenEndpoint(grantType, accessToken) {
const data = {
grant_type: grantType,
client_id: config.cognito.clientId,
code: accessToken,
const jwt = require('jsonwebtoken');
function generateAuthToken(user) {
const token = jwt.sign(
{
id: user.id,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
const path = require('path');
const dotEnvPath = path.resolve('./.env');
const dotenv = require('dotenv').config({ path: dotEnvPath });
const config = {};
config.secret = process.env.SECRET;
config.port = process.env.PORT || 3001;
config.cognito = {};
Customer item Price items
Elton John pasta 2.5 2
Jimmy Page soup 1.99 1
Billy Joel beer 3.5 6
create table sales (
id integer,
first_name varchar,
last_name varchar,
item_name varchar,
item_qty integer,
total_spent decimal
);
aact_ali01 geo EU28
aact_ali01 geo EU27
aact_ali01 geo EU25
aact_ali01 geo EU15
aact_ali01 geo EA19
aact_ali01 geo EA16
aact_ali01 geo EA12
aact_ali01 geo EA11
aact_ali01 geo BE
aact_ali01 geo BG
{"Item":
{"category":
{ "geo":["EU28","EU27","EU15","EA11","EL","SI","SK","ES","FI","SE","BE","FR","UK","IS","HR","NO","CH","EA19","BG","IT","MK","TR","CY","CZ","LV","LT","EU25","EA16","DK","LU","HU","DE","MT","NL","EA12","EE","AT","PL","IE","PT","RO"],
"itm_newa":["40000","41000","42000"],
"time":["1999","1998","1997","1996","1995","1994","1993","1992","1991","1990","1989","1988","1987","1986","1985","1984","1983","1982","1981","1980","1979","1978","1977","1976","1975","1974","2018","1973","2017","2016","2015","2014","2013","2012","2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000"]
},
"dataset":"aact_ali01"
}
}
@dimitrisdovinos
dimitrisdovinos / create temp table.sql
Last active April 1, 2019 13:19
create temporary table
create temp table t_data
(
customer varchar,
customer_first_name varchar,
customer_last_name varchar,
item_name varchar,
total_spent decimal,
item_qty integer
);
copy t_data(customer, item_name, total_spent, item_qty )from stdin DELIMITER ',';
Elton John, pasta, 2.5, 2
Jimmy Page, soup, 1.99, 1
Billy Joel, beer, 3.5, 6
\.
update t_data set customer_first_name = split_part(customer,' ',1) ;