Skip to content

Instantly share code, notes, and snippets.

View gtalarico's full-sized avatar
♥️
Python, Javascript, and Go

Gui Talarico gtalarico

♥️
Python, Javascript, and Go
View GitHub Profile
@gtalarico
gtalarico / Dockerfile
Created October 21, 2020 17:22
Docker Jupyter for GIS
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 October 1, 2019 02:22
Reflect Proto Messages
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 September 10, 2019 19:34
Get Protobuf option value and others
"""
Proto
enum EntityType {
GEOMETRY = 0;
PHYSICAL = 1;
}
extend google.protobuf.MessageOptions {
EntityType entity_type = 100;
@gtalarico
gtalarico / netlify.toml
Created June 7, 2019 02:23
Netlify toml Config
# netlify.toml
[build]
functions = "build-lambda"
publish = "dist/"
command = "yarn build"
@gtalarico
gtalarico / vue.config.js
Last active June 7, 2019 02:31
Netlify Function Vue Config
// vue.config.js
module.exports = {
devServer: {
proxy: {
'^/.netlify': {
target: 'http://localhost:9000',
pathRewrite: { '^/.netlify/functions': '' }
}
}
}
@gtalarico
gtalarico / lambdaService.js
Created June 7, 2019 01:55
Netlify Lambda Service
// 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 June 7, 2019 01:49
Netlify Functions Build
{
"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 February 11, 2021 13:15
Airtable Netlify Lambda Function Setup
// 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 19:45
Assert Environment Variables are set
# 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 07:21
Django Database is Read
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"