Skip to content

Instantly share code, notes, and snippets.

View dmpop's full-sized avatar
🇺🇦

Dmitri Popov dmpop

🇺🇦
View GitHub Profile
@dmpop
dmpop / raspberrypi.sh
Last active June 10, 2016 12:25
Raspberry Pi installation script
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "Run this script as sudo"
exit 1
fi
apt update
apt -y install apache2 php5 php5-gd php5-sqlite git-core fossil screen imagemagick python-pip rsync jq
pip install bottle
@dmpop
dmpop / timplapse.py
Created July 31, 2015 12:12
SL4A-based Python script for timelapse photography
import android, time, os
droid = android.Android()
counter = 1
title = "Number of Photos"
droid.dialogCreateAlert(title)
photoCount = int(droid.dialogGetInput("Specify number of photos to take:").result)
title = "Time interval"
@dmpop
dmpop / pi_camera_bottle.py
Created September 13, 2015 16:38
Simple Python Bottle-based app to control Raspberry Pi camera module
#!/usr/bin/python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@dmpop
dmpop / weather_report
Created December 22, 2015 09:27
Weather Report flow for Node-RED
[{"id":"5b09f655.d78988","type":"openweathermap","z":"8312dc32.974a3","name":"","lon":"","lat":"","city":"Aarhus","country":"Denmark","x":363,"y":168,"wires":[["ffe6ef68.f37e"]]},{"id":"9f9af6b7.3f75e","type":"inject","z":"8312dc32.974a3","name":"Weather Today","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"00 10 * * *","once":false,"x":147,"y":118,"wires":[["5b09f655.d78988"]]},{"id":"71938e7e.a647a","type":"e-mail","z":"8312dc32.974a3","server":"smtp.foobar.com","port":"465","name":"foo@bar.com","dname":"","x":778,"y":294,"wires":[]},{"id":"ffe6ef68.f37e","type":"function","z":"8312dc32.974a3","name":"Process Weather Data","func":"msg.payload = \"Weather: \" + msg.payload.detail + \", Temperature: \" + msg.payload.tempc + \"°C\" + \" Wind Speed: \" + msg.payload.windspeed + \"m/s\"\nreturn msg;","outputs":1,"noerr":0,"x":562,"y":226,"wires":[["71938e7e.a647a"]]}]
@dmpop
dmpop / weather-blinkstick
Last active January 25, 2016 10:56
BlinkStick flow for Node-RED
[{"id":"72aafd2f.608874","type":"exec","z":"c44f31ab.9139e8","command":"blinkstick","addpay":true,"append":"","useSpawn":"","name":"BlinkStick","x":831,"y":170,"wires":[[],[],[]]},{"id":"ba40088d.d286e8","type":"openweathermap","z":"c44f31ab.9139e8","name":"","lon":"","lat":"","city":"Aarhus","country":"Denmark","x":338,"y":173,"wires":[["a36fdbc6.490e48"]]},{"id":"95a6d5c0.afcbd","type":"inject","z":"c44f31ab.9139e8","name":"Weather Today","topic":"","payload":"","payloadType":"none","repeat":"600","crontab":"","once":true,"x":112,"y":81,"wires":[["ba40088d.d286e8"]]},{"id":"a36fdbc6.490e48","type":"function","z":"c44f31ab.9139e8","name":"Process Weather Data","func":"if (msg.payload.weather === \"Clear\") {\n msg.payload = \"--repeats 51 --pulse green\"\n return msg;\n}\n\nelse if (msg.payload.weather === \"Broken clouds\") {\n msg.payload = \"--repeats 51 --pulse yellow\"\n return msg;\n}\nelse if (msg.payload.weather === \"Rain\") {\n msg.payload = \"--repeats 51 --pulse red\"\n return msg;\n}\n
@dmpop
dmpop / node-red-twitter
Last active March 31, 2016 08:40
Twitter mentions Node-RED flow
[{"id":"19cbb03a.2ecd3","type":"twitter in","z":"4c5513ea.a4813c","twitter":"","tags":"","user":"false","name":"Mentions","topic":"tweets","x":177.16668701171875,"y":251.16665649414062,"wires":[["4bdfd1e1.404698"]]},{"id":"640bfbf0.4399d4","type":"e-mail","z":"4c5513ea.a4813c","server":"","port":"465","name":"Email","dname":"","x":756.1666870117188,"y":295.1666564941406,"wires":[]},{"id":"4bdfd1e1.404698","type":"function","z":"4c5513ea.a4813c","name":"Modify message","func":"msg.topic = msg.topic.replace(\"tweets/\", \"Twitter mention by \");\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":201,"wires":[["640bfbf0.4399d4"]]}]
@dmpop
dmpop / unsplash-random.sh
Last active September 18, 2017 21:31
Use random photos from Unsplash as a desktop background on Ubuntu
#!/bin/bash
uuser="unsplash_user_name"
path="path/to/dir"
size=$(xdpyinfo | grep dimensions | awk '{print $2}')
curl "https://source.unsplash.com/user/$uuser/$size" --location --output $path/unsplash-random.jpeg
gsettings set org.gnome.desktop.background picture-uri file://$path/unsplash-random.jpeg
@dmpop
dmpop / dweet-ip.sh
Created May 31, 2016 09:02
Send the current local IP address to dweet.io
#!/bin/bash
ping -c1 google.com &>/dev/null
if [ $? -eq 0 ]; then
IP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
curl "https://dweet.io/dweet/for/$THING?IP=$IP"
fi
@dmpop
dmpop / latlon.sh
Last active July 4, 2016 19:52
Convert latitude and longitude values to digiKam-compatible format
#!/bin/bash
latlon="geo:"$(xclip -o | tr -d ' ')
notify-send $latlon -i info
echo $latlon | xclip -selection c
@dmpop
dmpop / exiftool-helper.sh
Created July 11, 2016 07:45
Helper script for using ExifTool
#!/bin/bash
#OPTIND=1
while getopts "h?sdyar" opt; do
case $opt in
s) exiftool -directory=%e .
;;
d) exiftool -d %Y%m%d-%H%M%S.%%e '-FileName<DateTimeOriginal' -r .
;;
y) exiftool '-Directory<CreateDate' -d %Y-%m-%d -r .
;;