Skip to content

Instantly share code, notes, and snippets.

Avatar
♥️
Python, Javascript, and Go

Gui Talarico gtalarico

♥️
Python, Javascript, and Go
View GitHub Profile
@gtalarico
gtalarico / Dockerfile
Created Oct 21, 2020
Docker Jupyter for GIS
View Dockerfile
FROM osgeo/gdal
ENV PORT=8888
RUN apt-get update
RUN apt-get install -y \
python3-pip
RUN python -m pip install \
gdal \
@gtalarico
gtalarico / reflect_proto.py
Created Oct 1, 2019
Reflect Proto Messages
View reflect_proto.py
from pprint import pprint
from google.protobuf.pyext.cpp_message import GeneratedProtocolMessageType
from google.protobuf.descriptor import FieldDescriptor
from myproto import schema_pb2
pb_types = {
FieldDescriptor.TYPE_BOOL: bool,
FieldDescriptor.TYPE_BYTES: bytes,
@gtalarico
gtalarico / proto_entity.py
Last active Sep 10, 2019
Get Protobuf option value and others
View proto_entity.py
"""
Proto
enum EntityType {
GEOMETRY = 0;
PHYSICAL = 1;
}
extend google.protobuf.MessageOptions {
EntityType entity_type = 100;
@gtalarico
gtalarico / netlify.toml
Created Jun 7, 2019
Netlify toml Config
View netlify.toml
# netlify.toml
[build]
functions = "build-lambda"
publish = "dist/"
command = "yarn build"
@gtalarico
gtalarico / vue.config.js
Last active Jun 7, 2019
Netlify Function Vue Config
View vue.config.js
// vue.config.js
module.exports = {
devServer: {
proxy: {
'^/.netlify': {
target: 'http://localhost:9000',
pathRewrite: { '^/.netlify/functions': '' }
}
}
}
@gtalarico
gtalarico / lambdaService.js
Created Jun 7, 2019
Netlify Lambda Service
View lambdaService.js
// lambdaService.js
import axios from 'axios'
const $axios = axios.create({
baseURL: '/.netlify/functions',
timeout: 10000 // 10 seconds
})
// Response Interceptor to handle and log errors
$axios.interceptors.response.use(
@gtalarico
gtalarico / packages.json
Last active Jun 7, 2019
Netlify Functions Build
View packages.json
{
"scripts": {
"serve": "vue-cli-service serve",
"serve:lambda": "netlify-lambda serve lambda",
"build": "run-p build:**",
"build:app": "vue-cli-service build",
"build:lambda": "netlify-lambda build lambda",
"...": "..."
},
@gtalarico
gtalarico / airtable.js
Last active Feb 11, 2021
Airtable Netlify Lambda Function Setup
View airtable.js
// lambda/airtable.js
const Airtable = require('airtable')
Airtable.configure({
endpointUrl: 'https://api.airtable.com',
apiKey: process.env.AIRTABLE_KEY
})
const base = Airtable.base('appNtnZ99fkL1cByn')
exports.handler = function(event, context, callback) {
@gtalarico
gtalarico / assert_envs.sh
Created May 23, 2019
Assert Environment Variables are set
View assert_envs.sh
# Asserts given env vars are set
# Usage: assert_envs { args }
# eg. DBHOST DBPORT DBNAME DBUSER
assert_envs() {
for var in "$@"; do
if [ -z "${!var}" ]; then
error "$var environment is required and is not set"
exit 1
fi
done
@gtalarico
gtalarico / serve.sh
Created May 12, 2019
Django Database is Read
View serve.sh
info " Checking DB Connection"
while ! python3 manage.py inspectdb >/dev/null 2>&1; do
warn " DB is not ready"
sleep 5
done
info " DB is ready"