Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt
import time
import json
import base64
def on_connect(client, userdata, flags, rc):
print("Connected with result code " + str(rc))
dev_eui = 'ZZZZZ'
@malefs
malefs / gist:a37cc9744ddd97305f3cd2579c25aa10
Created October 4, 2018 05:52 — forked from ealogar/gist:6698348
tutorial of pymongo: - Recommendations of use - Examples - Useful readings
#-*- coding: utf-8 -*-
u"""
MOD: pymongo
"""
import pymongo
#===============================================================================
@malefs
malefs / mongo_test_restaurants.py
Created October 4, 2018 05:54 — forked from vinovator/mongo_test_restaurants.py
Script to interact with MongoDB using pymongo driver
# mongo_test_restaurants.py
# Python 2.7.6
"""
Test script to connect to MongoDB collections using pymongo library
Connects to an already imported connection named "restaurants"
source - https://docs.mongodb.org/getting-started/python/
"""
from pymongo import MongoClient, ASCENDING, DESCENDING
@malefs
malefs / Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Created October 15, 2018 15:31 — forked from IamAdiSri/Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Setting up and using Python3, Pip3, Virtualenv (for Python3) and Virtualenvwrapper (for Python3)
First install pip for Python2. Download the get-pip.py file from https://bootstrap.pypa.io/get-pip.py
$ cd <download location>
$ sudo -H python ./get-pip.py
Installing pip also installs Python3
To run Python3
$ python3
Install pip3 by just executing the same file as in the step above, but this time using Python3
$ sudo -H python3 ./get-pip.py
@malefs
malefs / ffmpeg-mjpeg.sh
Last active March 28, 2019 07:59 — forked from indiejoseph/ffmpeg-mjpeg.sh
ffmpeg record mjpg-streamer
# capture mjpegstream -r Framerate
ffmpeg -f mjpeg -r 2 -i "http://127.0.0.1/rpicam/cam_pic_new.php?" -r 2 ./video.avi
@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);
@malefs
malefs / obdii_info.sh
Created June 4, 2019 13:28 — forked from BretStateham/obdii_info.sh
Dump OBDII Info via cansend and candump
# --------- SCRIPT BEGIN ----------
# By Bret Stateham
# This script assumes
# - You are running on a linux machine
# - You have the can-utils installed and working. See:
# - https://github.com/linux-can/can-utils
# - https://www.kernel.org/doc/Documentation/networking/can.txt
# - You have a can device attached and configured as can0 (you can change the targetbus variable to match if otherwise)
# - The can device is attached to your running target vehicle
@malefs
malefs / Pacifica.ino
Created January 18, 2020 18:09 — forked from kriegsman/Pacifica.ino
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
@malefs
malefs / pyenv-cheat-sheet.md
Created April 14, 2020 13:36
pyenv cheat sheet

Python environment cheatsheet

Tool for creating isolated Python environments

The common use-cases:

  • Handling different versions of same libraries per each service
  • Same plus no access to site-packages