Skip to content

Instantly share code, notes, and snippets.

View luizamboni's full-sized avatar
💭
I may be slow to respond.

Luiz Zamboni luizamboni

💭
I may be slow to respond.
View GitHub Profile
@luizamboni
luizamboni / page-content.js
Last active May 9, 2020 20:53
pageContent service for strapi tutorial
'use strict';
const modelName = 'page-content'
module.exports = {
_validate(data) {
if (!(data.startAt < data.endAt)){
throw new Error("startAt should be less than endAt date")
}
@luizamboni
luizamboni / explode-attributes.py
Last active September 3, 2021 20:09
glue PySpark
# Json Data
# {
# "id": String
# "products_count": Number
# "products: [
# { "id": Number , "t": String , "cpc": Number }
# ]
# }
import sys
@luizamboni
luizamboni / glue-dev-endpoint.sh
Created July 27, 2018 21:05
a bash to create and connect to AWS Glue Dev Endpoint
#!/bin/bash
# create a dev-endpoint in aws glue
openssl rsa -in ~/.ssh/id_rsa -outform pem > ~/.ssh/id_rsa.pem
chmod 700 id_rsa.pem
aws glue create-dev-endpoint --endpoint-name dev-test3 --role-arn "${ARN}" --public-key "$(cat ~/.ssh/id_rsa.pub)" --number-of-node 2
watch aws glue get-dev-endpoints
@luizamboni
luizamboni / agg.py
Last active July 27, 2018 21:56
glue snippets
import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
# aditional imports
from pyspark.sql.functions import sum
from awsglue.dynamicframe import DynamicFrame
@luizamboni
luizamboni / redux.js
Created May 17, 2018 22:00
redux to consume 3rd level maturity
const { createStore, applyMiddleware, combineReducers } = require('redux');
const thunk = require('redux-thunk').default;
const Axios = require("axios");
const ROOT = ""
// users edition of users
const usersReducer = (state = { list: []} , action) => {
const { payload, type } = action
@luizamboni
luizamboni / lucenize.js
Last active September 9, 2017 04:21
transform phrase in lucene query with postuguese semantics
const dictionary = {
substantives: [
"berço",
"notebook",
"smartphone",
"tela"
],
@luizamboni
luizamboni / mysql5.6.sh
Last active September 3, 2017 19:36
instal mysql 5.6
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe'
sudo apt-get update
sudo apt install mysql-server-5.6 -y
sudo apt install mysql-client-5.6 -y
@luizamboni
luizamboni / nodejs-tcp-example.js
Created August 22, 2017 23:53 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@luizamboni
luizamboni / days-range-generator.js
Last active August 22, 2017 17:37
generator to create range of days
const moment = require("moment")
const rangeGenerator = function*(startDate, endDate) {
const start = moment(startDate)
const end = moment(endDate)
while (start.format("YYYY-MM-DD") <= end.format("YYYY-MM-DD")) {
yield start.format("YYYY-MM-DD")
start.add(1, "day")
}