Skip to content

Instantly share code, notes, and snippets.

View DKbyo's full-sized avatar

Danyel Cabello DKbyo

View GitHub Profile
@DKbyo
DKbyo / Dockerfile
Created March 7, 2024 03:17
AsyncIO + FastAPI + Uvicorn + Firestore Example
FROM python:3.9-alpine
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
WORKDIR /app
COPY main.py /app
CMD uvicorn --host 0.0.0.0 --port $PORT --workers $WORKERS main:app
@DKbyo
DKbyo / app.java
Last active May 18, 2022 19:27
google-java-sdk-retries
package com.example.app;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.compute.Compute;
import com.google.api.services.compute.model.Instance;
import com.google.api.services.compute.model.InstanceList;
@DKbyo
DKbyo / Dockerfile
Last active March 24, 2022 20:24
Thread Safe Sessions on SQLAlchemy on Cloud Run
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.10-slim
# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
@DKbyo
DKbyo / uuid_filename_filefield.py
Created September 6, 2021 15:13
Simple example of django filefield with auto generated uuid as file name and certain folder
from django.utils.deconstruct import deconstructible
@deconstructible
class upload_to(object):
def __init__(self, sub_path):
self.path = sub_path
def __call__(self, instance, filename):
ext = filename.split('.')[-1]
if instance.uuid is None:
@DKbyo
DKbyo / install_node-firestore-backup-restore.sh
Last active December 29, 2017 12:52
Install node-firestore-backup-restore from my fixed branch
git clone https://github.com/DKbyo/node-firestore-backup-restore.git
cd node-firestore-backup-restore
git checkout fix/install
npm install
npm pack
npm install -g firestore-backup-restore-1.1.0.tgz
@DKbyo
DKbyo / server.js
Created May 3, 2017 23:09
GoPro Hero 5 Node Server
var GoPro = require('goproh4');
var express = require('express');
var bodyParser = require('body-parser')
var WebSocket = require('ws');
var fs = require("fs");
var cam = new GoPro.Camera();
cam.mode(GoPro.Settings.Modes.Video, GoPro.Settings.Submodes.Video.Video)
.then(function(){
return cam.set(GoPro.Settings.VIDEO_RESOLUTION, GoPro.Settings.VideoResolution.R720S)})
.then(function(){
@DKbyo
DKbyo / US Zip Codes from 2013 Government Data
Created February 13, 2017 17:39 — forked from erichurst/US Zip Codes from 2013 Government Data
All US zip codes with their corresponding latitude and longitude coordinates. Comma delimited for your database goodness. Source: http://www.census.gov/geo/maps-data/data/gazetteer.html
This file has been truncated, but you can view the full file.
ZIP,LAT,LNG
00601,18.180555, -66.749961
00602,18.361945, -67.175597
00603,18.455183, -67.119887
00606,18.158345, -66.932911
00610,18.295366, -67.125135
00612,18.402253, -66.711397
00616,18.420412, -66.671979
00617,18.445147, -66.559696
00622,17.991245, -67.153993
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: '2.0'
info:
title: Cool Climate User API
description: API used by the Cool Climate Network in the Cool Climate Calculator
version: "1.0.0"
# the domain of the service
host: calculator.coolclimatenetwork.net
# array of all schemes that your API supports
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: '2.0'
info:
title: Cool Climate User API
description: API used by the Cool Climate Network in the Cool Climate Calculator
version: "1.0.0"
# the domain of the service
host: calculator.coolclimatenetwork.net
# array of all schemes that your API supports