Skip to content

Instantly share code, notes, and snippets.

@malefs
malefs / mjpeg_udp.py
Created June 2, 2017 13:55 — forked from mic159/mjpeg_udp.py
Raspberry Pi MJPEG stream over UDP
from picamera import PiCamera
from io import BytesIO
import socket
import time
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
with PiCamera(resolution='VGA', framerate=5) as camera:
time.sleep(2)
@malefs
malefs / Flask-raspberryPi-GPIO-camera-model.py
Created June 2, 2017 14:00 — forked from benyaminsalimi/Flask-raspberryPi-GPIO-camera-model.py
simple RestApi for RaspberryPi RPIO & camera model with flask
# BPi restFull-api by @BenyaminSalimi
# you can see log of this program in "BPi.log"
from flask import Flask,jsonify,send_file
import picamera
import time
import RPi.GPIO as GPIO
app = Flask(__name__)
@malefs
malefs / rpi-led-notes.md
Created June 10, 2017 00:37 — forked from taktran/rpi-led-notes.md
Controlling Raspberry Pi 2 LEDs

Commands for controlling the Raspberry Pi 2 LEDs.

See rpi-leds for a node module that does this.

Power (PWR) LED

  • OK (ACT) LED = led0
  • Power (PWR) LED = led1

Allow access

@malefs
malefs / tmux.conf
Created June 10, 2017 01:00 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@malefs
malefs / gist:0e4465a5dea9ea14cda7f0bfed275bd6
Created October 24, 2017 11:55 — forked from oysteinjakobsen/gist:44a2c87bb552871bec71
How install Docker on Raspberry Pi 2

Would you love to get Docker up and running on you Raspberry Pi 2? Fortunately someone already did most of the leg work for you, as you will see from the article "Kick-Ass Raspberry Pi 2 having a forbidden love affair with Docker 1.4.1".

Check the official article "Installing Operating System Images" for more information on how to install this Debian Wheezy OS.

After you have downloaded and installed the image referenced in the article you're ready to do some adjustments to improve security.

Create a user

Log in as root to create a personal user and give it a password:

@malefs
malefs / gist:765a953652c2fcb78f2202c549c569af
Created October 24, 2017 11:55 — forked from oysteinjakobsen/gist:e59cdd38a688ee8a418a
How to get docker-compose (fig) up and running on Raspberry Pi 2

Background

I assume you already have Docker up and running on your Raspberry Pi 2. If not, see this article.

The next natural step is to install Docker Compose (formerly Fig), but there's no ARM support out of the box. This recipe will help you install Docker Compose on your Raspberry Pi 2!

The following six steps will do the trick:

  1. Get the docker-compose source code from git
@malefs
malefs / pi_mount_usb.md
Created January 8, 2018 11:04 — forked from etes/pi_mount_usb.md
How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

Follow the simple steps in the order mentioned below to have your USB drive mounted on your Raspberry Pi every time you boot it.

These steps are required especially if your are setting up a Samba share, or a 24x7 torrent downloader, or alike where your Raspberry Pi must have your external storage already mounted and ready for access by the services / daemons.

Step 0. Plug in your USB HDD / Drive to Raspberry Pi If you are using a NTFS formatted drive, install the following

@malefs
malefs / mpl_zmq_animate.py
Created February 1, 2018 06:57 — forked from lebedov/mpl_zmq_animate.py
Plot data received over a ZeroMQ port in real time using matplotlib.
#!/usr/bin/env python
"""
Plot data received over a ZeroMQ port in real time using matplotlib.
Notes
-----
This appears to segfault when run using the WxAgg backend.
"""
@malefs
malefs / mostPostedTracks.js
Created April 18, 2018 08:23 — forked from adrienjoly/mostPostedTracks.js
mongodb "group by" query using aggregation for counting documents per category, on a objectid-timestamp-based subset
db = db.getSiblingDB("whyd_music") // explicitely select collection
var jan2014 = ObjectId("52c35a800000000000000000"); // created using http://steveridout.github.io/mongo-object-time/
db.post.aggregate([
{"$sort": {"_id": -1}}, // order: antichronological
{"$match": {"_id": {"$gt": jan2014}}}, // only documents that were created after the 1syt january 2014
{"$group": {"_id": "$eId", // group by value of the eId attribute -> _id attribute in the resulting output collection
"name": {"$first": "$name"}, // -> include the name of each grouped category
"count": {"$sum": 1}}}, // -> count attribute will contain the number of documents for each value of _eid
{"$match": {"count": {"$gt": 50}}}, // limit output to results with count > 50
{"$sort": {"count": -1}} // output order: highest count first