Skip to content

Instantly share code, notes, and snippets.

View tomazursic's full-sized avatar

Tomaz Ursic tomazursic

View GitHub Profile
@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 / 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 / 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 / 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 / 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
@tomazursic
tomazursic / ubuntu-ppa.md
Last active June 30, 2017 21:45
Ubuntu ppa

Google Chrome

App Type: Internet Brows

Command:


    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
    sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
@tomazursic
tomazursic / commandline_gems.rst
Last active July 10, 2017 08:37
Commandline gems

CREATE DISK IMAGE USING DD AND PV

# bring img on sd card
sudo pv -tpreb name.img | sudo dd of=/dev/mmcblk0 bs=4M
# create image from sd card
sudo pv -tpreb /dev/mmcblk0 | sudo dd of=name.img bs=4M

Raspbeerry Pi USB gadget

  1. Fresh sd card with Raspbian

  2. Enable ssh

Add empty file "ssh" to /boot partition on SD card

Add to config.txt