Skip to content

Instantly share code, notes, and snippets.

@malefs
malefs / fastapi_websocket_redis_pubsub.py
Created March 29, 2023 15:53 — forked from timhughes/fastapi_websocket_redis_pubsub.py
FastAPI Websocket Bidirectional Redis PubSub
"""
Usage:
Make sure that redis is running on localhost (or adjust the url)
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html
pip install -u uvicorn
Install dependencies
@malefs
malefs / README.md
Created February 9, 2023 13:22 — forked from jasondavies/README.md
Zoom/Pan Map Example

Demonstrates using d3.behavior.zoom with a geographic projection. Based on an example by Iain Dillingham.

import pandas as pd
import numpy as np
def get_dataset(size):
# Create Fake Dataset
df = pd.DataFrame()
df['size'] = np.random.choice(['big','medium','small'], size)
df['age'] = np.random.randint(1, 50, size)
df['team'] = np.random.choice(['red','blue','yellow','green'], size)
df['win'] = np.random.choice(['yes','no'], size)
@malefs
malefs / forward.py
Created October 13, 2022 07:54 — forked from samim23/forward.py
# "Colorizing B/W Movies with Neural Nets",
# Network/Code Created by Ryan Dahl, hacked by samim.io to work with movies
# BACKGROUND: http://tinyclouds.org/colorize/
# DEMO: https://www.youtube.com/watch?v=_MJU8VK2PI4
# USAGE:
# 1. Download TensorFlow model from: http://tinyclouds.org/colorize/
# 2. Use FFMPEG or such to extract frames from video.
# 3. Make sure your images are 224x224 pixels dimension. You can use imagemagicks "mogrify", here some useful commands:
# mogrify -resize 224x224 *.jpg
# mogrify -gravity center -background black -extent 224x224 *.jpg
@malefs
malefs / Sparkasse2Homebank.md
Created July 20, 2022 08:08 — forked from daalja/Sparkasse2Homebank.md
Konvertiere Sparkassen Girokonto CSV-CAMT-Format und Kreditkarten CSV-Format in Homebank kompatibles Format

Info

Homebank (http://homebank.free.fr) versteht nur seine eigenen CSV-Dateien. Hier sind zwei Konverter für Sparkassenkonten:

  • Girokonto -> spk_csv-camt2homebank.py
  • Kreditkarte -> kreditkarte-homebank.py

Es werden die Dateien kreditkarte_import.csv bzw. girokonto_import.csv erstellt bzw. überschrieben.

@malefs
malefs / receiver.py
Created April 15, 2022 09:09 — forked from dariocazzani/receiver.py
Receive packets via UDP
'''
Simple udp socket server
'''
import socket
import sys
import pyaudio
import numpy as np
class Receiver(object):
@malefs
malefs / stream_mic.py
Created April 15, 2022 09:08 — forked from dariocazzani/stream_mic.py
Stream Microphone via UDP
'''
Simple udp socket server to stream audio from mic
'''
import pyaudio
import socket
import sys
class UDPstream(object):
def __init__(self, CLIENT_IP, PORT):
from sqlalchemy.ext.automap import automap_base
from sqlalchemy import create_engine, MetaData, Column, String, Integer
import pickle
from sqlalchemy.sql.schema import ForeignKey
# Create some tables in the database
engine = create_engine('sqlite://')
engine.execute('CREATE TABLE user (id INTEGER, name TEXT, favorite_color TEXT)')
engine.execute('CREATE TABLE profile (id INTEGER, userid INTEGER, summary TEXT)')
-- Description:
-- ------------
--
-- This is an example schema for storing collectd metrics in a TimescaleDB
-- dabase (see https://www.timescale.com/). It is based on the PostgreSQL
-- schema contributed by Sebastian Harl.
--
-- Prerequisities:
-- ---------------
--
@malefs
malefs / installopencv.sh
Created March 2, 2021 14:39 — forked from jwpleow/installopencvraspi.sh
install opencv
# remember to launch this with sudo so that sudo does not time out halfway
OPENCV_VERSION='4.5.1' # Version to be installed
#note this install script is without cuda
if [ `whoami` != 'root' ];
then
echo "This program needs to be run using 'sudo'"
exit
fi
sudo apt -y update