Skip to content

Instantly share code, notes, and snippets.

View tomazursic's full-sized avatar

Tomaz Ursic tomazursic

View GitHub Profile
@tomazursic
tomazursic / install_rtl_433_macOSX.md
Last active October 11, 2020 14:37
rtl_433 macOSX

Install rtl_433 on macOSX Sierra 10.12.5

Install Xcode from AppStore

After installing Xcode you’ll want to open up a terminal and ensure you have accepted the developer license:

$ sudo xcodebuild -license

Install the Apple Command Line Tools

@tomazursic
tomazursic / logger.py
Last active June 3, 2022 01:32
Python boilerplate
"""
This helper provides logging setup.
The call `logger.info("hello")` prints log messages in this format:
Usage:
from logger import setup_logger
logger = setup_logger()
@tomazursic
tomazursic / InfluxDB_cheatsheet.md
Last active December 24, 2021 08:46
InfluxDB cheatsheet

InfluxDB Cheatsheet

Connect to InfluxDB using the commandline:

$ influx

Create a database foo:

CREATE DATABASE foo
@tomazursic
tomazursic / mailer.py
Last active June 30, 2017 21:39
Python - Mailer
#!/usr/bin/env python
# crontab -e
# @reboot python /home/pi/code/startup_mailer.py
import time
import subprocess
import smtplib
from email.mime.text import MIMEText
import datetime
@tomazursic
tomazursic / randomuser.py
Last active June 30, 2017 21:40
Random User
#!/usr/bin/env python
import json
import requests
url = 'https://randomuser.me/api/'
def main():
res = requests.get(url).json()
j = json.dumps(res, indent=2)
@tomazursic
tomazursic / pms.py
Created March 21, 2017 11:36
PMS5003 sensor
import serial
import datetime
from pymongo import MongoClient
port = serial.Serial('/dev/ttyAMA0', baudrate=9600, timeout=2.0)
client = MongoClient('172.31.150.230')
def read_pm_line(_port):
rv = b''
@tomazursic
tomazursic / iframe.js
Last active June 30, 2017 21:41
Create iframe
(function(){
document.body.innerHTML = '';
document.head.innerHTML = '';
var i = document.createElement('iframe');
i.id='theiframe';
i.style.width = '100%';
i.style.height='100%';
i.src = '?';
@tomazursic
tomazursic / alertexternal.js
Created March 10, 2017 12:04
Warning when opening external links
(function ($) {
var root = new RegExp(location.host);
$( 'a' ).each(function() {
if( location.hostname === this.hostname || !this.hostname.length ) {
$(this).addClass('local');
} else {
$(this).addClass('external');
}
@tomazursic
tomazursic / virtualbox_manage.md
Last active June 30, 2017 21:44
VirtualBox manage commands on MS

Clone fixed-size disc into dynamically allocated disc

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonemedium <disk-name>.vdi <new-disk-name>.vdi --variant Standard

Resize dynamically allocated disc. New size: 25GB:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd .vdi --resize 25000

@tomazursic
tomazursic / rsync-exclude.txt
Last active June 30, 2017 21:44
Exclude file for rsync
#rsync -aP --exclude-from=rsync-homedir-excludes.txt /home/$USER/ /media/$USER/linuxbackup/home/$USER/
#.android
#.AndroidStudioBeta
#.gradle
#.gvm
#.grails/
#.grails_history
#.kde/share/apps/nepomuk