Skip to content

Instantly share code, notes, and snippets.

@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 / TKPhillips_huelights.py
Last active April 12, 2018 10:49
Phillips hue python Farbtemperatur ct steuern Tkinter
#!/usr/bin/python
from Tkinter import *
from phue import Bridge
'''
This example creates 3 sliders for the first 3 lights
and shows the name of the light under each slider.
There is also a checkbox to toggle the light.
https://github.com/studioimaginaire/phue/
'''
@malefs
malefs / mongodb_setupwin.bat
Last active April 11, 2018 15:40
setup mongodb windows service autorun
:: create mongodb.conf and Install mongodb as autorun Service with DB and log File in this Directory
::https://docs.mongodb.com/v2.4/reference/configuration-options/
@echo off
mkdir mongodb
set MONGOCONF=mongodb.cfg
echo logpath=%CD%\mongodb.log> %MONGOCONF%
echo logappend=true >> %MONGOCONF%
echo dbpath=%CD%\mongodb >> %MONGOCONF%
echo bind_ip = 127.0.0.1 >> %MONGOCONF%
echo port = 27017 >> %MONGOCONF%
#!/usr/bin/python
import os
import datetime
import ftplib
import traceback
import math
import random, string
import base64
import json
@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 / sip.conf
Last active October 26, 2017 12:27
CT special astersik türklingel sip
[general]
allowguest=no
port = 5060
bindaddr = 0.0.0.0
qualify = no
disable = all
allow = alaw
allow = ulaw
videosupport = no
dtmfmode = rfc2833
@malefs
malefs / sipklingel.py
Created October 26, 2017 12:26
Ct Special SIp Asterisk Klingel
import time
import shutil
import RPi.GPIO as gpio
import os
import sys
#Einstellungen
klingel_gpio = 4 #GPIO, der mit der Schaltung verbunden ist
callfilepfad = "/home/pi/klingel.call" #Dateipfad in dem das Script die .call-Datei ablegt
sipkanal = "624" #Name des SIP-Kanals (in eckigen Klammern in der SIP.conf)
@malefs
malefs / mp3pi.txt
Created October 26, 2017 12:22
mp3pi Ct Magazin
Weltempfänger
Raspi als Internet-Radio mit Touch-Bedienung
c't 6/17, S. 84
-----------------------------------------------------------
Für die meisten nachfolgenden Schritte sind Root-Rechte nötig:
sudo su -
Ausgabe auf Raspi-Touch-Display drehen:
echo "lcd_rotate=2" >> /boot/config.txt
Basis-Konfiguration von Raspbian:
raspi-config