Skip to content

Instantly share code, notes, and snippets.

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)
@raikel
raikel / ubuntu-server-setup.md
Last active October 11, 2024 21:46
Ubuntu server setup

Avoid ssh lost connection due to innactivity

On the server, edit the file /etc/ssh/sshd_config:

ClientAliveInterval 30
ClientAliveCountMax 10
@timhughes
timhughes / fastapi_websocket_redis_pubsub.py
Last active February 21, 2025 08:41
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
@dmontagu
dmontagu / app.py
Created February 18, 2020 00:28
FastAPI + dash
# Based on the example from https://www.activestate.com/blog/dash-vs-bokeh/
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as obj
import uvicorn as uvicorn
from dash.dependencies import Input, Output
from fastapi import FastAPI
from starlette.middleware.wsgi import WSGIMiddleware
@kriegsman
kriegsman / Pacifica.ino
Last active January 8, 2025 18:23
Pacifica: gentle, blue-green ocean waves. For Dan.
//
// "Pacifica"
// Gentle, blue-green ocean waves.
// December 2019, Mark Kriegsman and Mary Corey March.
// For Dan.
//
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>
FASTLED_USING_NAMESPACE

Basic Methods

Prefix Method
imp→ import moduleName from 'module'
imn→ import 'module'
imd→ import { destructuredModule } from 'module'
ime→ import * as alias from 'module'
ima→ import { originalName as aliasName} from 'module'
exp→ export default moduleName
#Script to install Opencv 3.4.4 with optmizations for raspberry pi that can increase performance up to 50%!
#install pre-requisites
sudo apt-get install build-essential checkinstall cmake pkg-config yasm git gfortran libjpeg-dev libjasper-dev libpng-dev libtiff5-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libv4l-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgtk2.0-dev libtbb-dev qt5-default libatlas-base-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libopencore-amrnb-dev libopencore-amrwb-dev libavresample-dev x264 v4l-utils libprotobuf-dev protobuf-compiler libgoogle-glog-dev libgflags-dev libgphoto2-dev libeigen3-dev libhdf5-dev doxygen
#add symlink for libv4l
sudo ln -s -f /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h
#download and install Intel TBB precompiled for raspberry pi 2/3 b
git clone https://github.com/abhiTronix/TBB_Raspberry_pi.git
cd TBB_Raspberry_pi/
@malefs
malefs / message.hpp
Created April 18, 2019 10:26 — forked from mashiro/message.hpp
zeromq + msgpack
#include <string>
#include <ctime>
#include <msgpack.hpp>
struct message
{
std::string tag;
std::time_t time;
std::string text;
MSGPACK_DEFINE(tag, time, text);
@wyan
wyan / dspHostDrum8.ino
Created March 5, 2019 07:00 — forked from anonymous/dspHostDrum8.ino
Drum8 code for the dsp-Host module
// Copyright 2016 DSP Synthesizers Sweden.
//
// Author: Jan Ostman
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@audionerd
audionerd / supersaw-shooter.scd
Last active May 5, 2025 17:33
SuperSaw (Roland JP-8000 and JP-8080) in SuperCollider
// via https://web.archive.org/web/20191104212834/https://www.nada.kth.se/utbildning/grukth/exjobb/rapportlistor/2010/rapporter10/szabo_adam_10131.pdf
(
{ | freq = 523.3572, mix=0.75, detune = 0.75 |
var detuneCurve = { |x|
(10028.7312891634*x.pow(11)) -
(50818.8652045924*x.pow(10)) +
(111363.4808729368*x.pow(9)) -
(138150.6761080548*x.pow(8)) +
(106649.6679158292*x.pow(7)) -