Skip to content

Instantly share code, notes, and snippets.

View k-zehnder's full-sized avatar
😀

Kevin Zehnder k-zehnder

😀
View GitHub Profile
@kylehounslow
kylehounslow / client.py
Last active April 23, 2024 10:58
Send and receive images using Flask, Numpy and OpenCV
from __future__ import print_function
import requests
import json
import cv2
addr = 'http://localhost:5000'
test_url = addr + '/api/test'
# prepare headers for http request
content_type = 'image/jpeg'
@redlotus
redlotus / docstrings.py
Created October 2, 2017 04:34
Google Style Python Docstrings
# -*- coding: utf-8 -*-
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.
Example:
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including
@fomightez
fomightez / useful_pandas_snippets.py
Last active April 4, 2025 21:17 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
df['Column Name'].unique() # Note, `NaN` is included as a unique value. If you just want the number, use `nunique()` which stands
# for 'number of unique values'; By default, it excludes `NaN`. `.nunique(dropna=False)` will include `NaN` in the count of unique values.
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation.
df.height
df['height']
# are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html
# -or-
# http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/)
@bennadel
bennadel / .dockerignore-web
Last active March 23, 2024 16:24
From Noob To Docker On DigitalOcean With Nginx, Node.js, DataDog Logs, DogStatsD, And LetsEncrypt SSL Certificates
.*
Dockerfile
node_modules
@kmhoran
kmhoran / consumer.py
Last active January 18, 2022 20:27
Flask Consumer of Kafka Video Stream
import datetime
from flask import Flask, Response
from kafka import KafkaConsumer
# Fire up the Kafka Consumer
topic = "distributed-video1"
consumer = KafkaConsumer(
topic,
bootstrap_servers=['localhost:9092'])
@kmhoran
kmhoran / producer.py
Created March 21, 2018 19:09
Video Producer for Kafka Stream
import sys
import time
import cv2
from kafka import KafkaProducer
topic = "distributed-video1"
def publish_video(video_file):
"""
Publish given video file to a specified Kafka topic.
@valferon
valferon / postgres_manager.py
Created March 29, 2018 02:35
Python script to take care of postgres backup and restore of data
#!/usr/bin/python3
import argparse
import logging
import subprocess
import os
import tempfile
from tempfile import mkstemp
import configparser
import gzip
@aescarcha
aescarcha / nodeAsyncTest.js
Created September 25, 2018 07:03
Javascript async / await resolving promises at the same time test
// Simple gist to test parallel promise resolution when using async / await
function promiseWait(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(true);
}, time);
});
}
use rust_gpiozero::*;
use std::thread::sleep;
use std::time::Duration;
fn main() {
println!("Hello, world!");
let led = LED::new(18);
loop{
@sergiolucero
sergiolucero / graphqlapp.py
Created June 20, 2019 13:33
basic flask-graphql app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from flask_graphql import GraphQLView
#################################
app = Flask(__name__)
app.debug = True