Skip to content

Instantly share code, notes, and snippets.

@adamgreg
adamgreg / show_in_native_window.py
Created November 18, 2021 12:29
Presents a Dash app as a native application, like an Electron app. Pops up a minimal window locally and shuts down the server when that window is closed.
from dash import Dash, html
def show_in_native_window(app: Dash) -> None:
"""
Modify the application to launch a minimal browser window, and shut down when this window is closed,
to give the look & feel of a native application.
"""
from threading import Timer
@mementum
mementum / vanktharp-coinflip.py
Created August 26, 2019 21:34
Beating The Random Entry
#!/usr/bin/env python
# -*- coding: utf-8; py-indent-offset:4 -*-
###############################################################################
# Copyright (C) 2019 Daniel Rodriguez - MIT License
# - https://opensource.org/licenses/MIT
# - https://en.wikipedia.org/wiki/MIT_License
###############################################################################
import argparse
import random
@jdthorpe
jdthorpe / MongoEngin with Pandas DataFrames.md
Last active November 9, 2020 05:05
MongoEngin with Pandas DataFrames

MongoEngine Documents with Pandas

This example is meant to demonstrate the separation of concerns between Data Modeling (i.e. storing things) and business logic (i.e. doing things) by creating a Python Package called InventoryDB which implements data models and can be imported into a script that implements some business logic (i.e. actual work!).

DATA MODELING

To minimize the amount of effort involved in storing a pandas DataFrame in a MongoDB Document

# -*- coding: utf-8 -*-
from airflow.operators.http_operator import SimpleHttpOperator
from airflow.operators.postgres_operator import PostgresOperator
from airflow.operators.dummy_operator import DummyOperator
from airflow.hooks.postgres_hook import PostgresHook
from airflow.models import Variable, DAG
from datetime import date, datetime, timedelta
@MicTech
MicTech / avroToCsv.pig
Last active February 11, 2016 08:13
Avro to Csv in Pig
#Based on Petr's code - https://github.com/PetrVales
#You need PiggyBank library
#info: https://cwiki.apache.org/confluence/display/PIG/PiggyBank
#jar: http://search.maven.org/#search%7Cga%7C1%7Cpiggybank
#start pig in local mode
pig -x local
#register PiggyBank library