Skip to content

Instantly share code, notes, and snippets.

View blacklight's full-sized avatar

Fabio Manganiello blacklight

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can't make this file beautiful and searchable because it's too large.
"COUNTRY","Country","INDICATOR","Indicator","SEX","Gender","EDUCATION_LEV","Education level","MOBILITY","Mobility status","EDUCATION_FIELD","Field","YEAR","Year","Value","Flag Codes","Flags"
"AUS","Australia","ENRL_SHARE_MOBILE-FIELDS","Share of mobile students by field","_T","Total","ISCED11_5","Short-cycle tertiary education","MOB","Mobile including homecoming nationals","_T","Total","9999","Latest available year",32.568,,
"AUS","Australia","ENRL_SHARE_MOBILE-FIELDS","Share of mobile students by field","_T","Total","ISCED11_6","Bachelor’s or equivalent level","MOB","Mobile including homecoming nationals","_T","Total","9999","Latest available year",17.26,,
"AUS","Australia","ENRL_SHARE_MOBILE-FIELDS","Share of mobile students by field","_T","Total","ISCED11_7","Master’s or equivalent level","MOB","Mobile including homecoming nationals","_T","Total","9999","Latest available year",56.32,,
"AUS","Australia","ENRL_SHARE_MOBILE-FIELDS","Share of mobile students by field","_T","Total","ISCED11_8","Doctoral or equ
@blacklight
blacklight / platypush_camera_start.py
Created October 30, 2020 23:07
Script that starts Pi Camera streaming on port 5001 when Platypush starts
from platypush.context import get_plugin
from platypush.event.hook import hook
from platypush.message.event.application import ApplicationStartedEvent
@hook(ApplicationStartedEvent)
def on_application_started(event, **_):
cam = get_plugin('camera.pi')
cam.start_streaming()
@blacklight
blacklight / platypush_babymonitor_script.py
Created October 30, 2020 22:28
Script illustrating two hooks that send a notification to the configured mobile devices when a baby cry start/stop event is detected
from platypush.context import get_plugin
from platypush.event.hook import hook
from platypush.message.event.custom import CustomEvent
@hook(CustomEvent, subtype='baby-cry', state='positive')
def on_baby_cry_start(event, **_):
pb = get_plugin('pushbullet')
pb.send_note(title='Baby cry status', body='The baby is crying!')
@blacklight
blacklight / micmon_detect.py
Last active October 30, 2020 21:36
This script shows how to use a previously trained micmon model to trigger Platypush events when a new sequence of positive/negative audio segments is detected
#!/usr/bin/python3
import argparse
import logging
import os
import sys
from platypush import RedisBus
from platypush.message.event.custom import CustomEvent
@blacklight
blacklight / micmon_predict_example.py
Created October 30, 2020 21:12
Use a previously trained Tensorflow micmon sound model to make predictions on sound segments from a microphone
import os
from micmon.audio import AudioDevice
from micmon.model import Model
model_dir = os.path.expanduser('~/models/sound-detect')
model = Model.load(model_dir)
audio_system = 'alsa' # Supported: alsa and pulse
audio_device = 'plughw:2,0' # Get list of recognized input devices with arecord -l
@blacklight
blacklight / micmon_train_example.py
Created October 30, 2020 21:07
Train a Tensorflow model for sound detection from a micmon dataset
import os
from tensorflow.keras import layers
from micmon.dataset import Dataset
from micmon.model import Model
# This is a directory that contains the saved .npz dataset files
datasets_dir = os.path.expanduser('~/datasets/sound-detect/data')
# This is the output directory where the model will be saved
@blacklight
blacklight / micmon_datagen_example.py
Created October 30, 2020 21:02
Generate a micmon spectrum dataset from a set of raw labelled audio files
import os
from micmon.audio import AudioDirectory, AudioPlayer, AudioFile
from micmon.dataset import DatasetWriter
basedir = os.path.expanduser('~/datasets/sound-detect')
audio_dir = os.path.join(basedir, 'audio')
datasets_dir = os.path.join(basedir, 'data')
cutoff_frequencies = [250, 2500]
// Platypush sample user script to simplify/distill the content of a web page
async (app, args) => {
const url = await app.getURL();
// Get and parse the page body through the Mercury API
const dom = await app.getDOM();
const html = dom.body.innerHTML;
const response = await app.mercury.parse(url, html);
// Define a new DOM that contains the simplified body as well as