Skip to content

Instantly share code, notes, and snippets.

@malefs
malefs / MC Cheat Sheet
Created April 26, 2018 14:00 — forked from samiraguiar/MC Cheat Sheet
Midnight Commander Cheat Sheet
Shortcut Description
---------------------------------------------------------------
C-o Drop to the console
Insert Select/deselect file
* Invert selection on files
+ Specify file selection options (including custom pattern)
- The same as above, but for deselecting
F5/F6 Copy/move selected files
@malefs
malefs / multithreaded_image_scrapper.py
Created April 25, 2018 14:20 — forked from DollarAkshay/multithreaded_image_scrapper.py
Multithreaded Image Scraper in Python (Insanely fast on Ryzen 7)
import cv2
import numpy as np
import urllib.request
import time
import threading
import math
def getPokemon(start, end):
print("Started worker for range :", start, "to", end)
import cv2
import time
import glob
import multiprocessing.pool as mp
def process_img(image_file):
if '_canny.jpg' not in image_file:
print 'processing', image_file
img = cv2.imread(image_file)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
@malefs
malefs / rest-server.py
Created April 24, 2018 15:05 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@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
@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 / 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 / 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 / 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: