Skip to content

Instantly share code, notes, and snippets.

View nguyenhieuec's full-sized avatar

m_fx nguyenhieuec

  • Viet Nam
View GitHub Profile
@cmungall
cmungall / make_gdrive_index.py
Created June 12, 2019 01:46
Generate HTML index of a synced google drive folder. For me this is faster to search and navigate than the clunky slow google web interface. Pretty hacky code but it works for me
#!/usr/bin/env python3
import os
import re
import logging
import click
# don't index these
excludes = {
'single_files',
'Icon',
import cv2, queue, threading, time
class VideoCapture:
def __init__(self, name):
self.cap = cv2.VideoCapture(name)
self.q = queue.Queue()
t = threading.Thread(target=self._reader)
t.daemon = True
t.start()
@gecko655
gecko655 / airflow_monitoring.py
Last active June 21, 2021 06:45
The file added by cloud composer when creating the environment
"""A liveness prober dag for monitoring composer.googleapis.com/environment/healthy."""
import airflow
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import timedelta
default_args = {
'start_date': airflow.utils.dates.days_ago(0),
'retries': 1,
'retry_delay': timedelta(minutes=5)
@richiefrost
richiefrost / query_builder.py
Last active June 21, 2022 13:13
Simple use of the builder pattern to create a SQL query generator
class QueryBuilder:
def __init__(self):
self.select_value = ''
self.from_table_name = ''
self.where_value = ''
self.groupby_value = ''
def select(self, select_arg):
self.select_value = select_arg
return self
@betterdatascience
betterdatascience / app.py
Created October 5, 2020 18:44
Python Database Driven REST API
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False