Skip to content

Instantly share code, notes, and snippets.

@wtip
wtip / picam_stream.py
Last active Aug 16, 2021
picamera, gstreamer and rtsp-simple-server scripts and config
View picam_stream.py
from picamera import PiCamera
import shlex, subprocess, os
camera = PiCamera()
# max resolution is (3280, 2464) for full FoV at 15FPS
camera.resolution = (1640, 1232)
# zoom (x, y, w, h) proportion of the image to include in the output
# use the following to crop 4:3 full FoV res when using 16:9 resize res to achieve full width sensor FoV
#camera.zoom = (0.0, 0.1, 1.0, 0.75)
camera.framerate = 30
@wtip
wtip / ansible_task.yml
Created May 18, 2020
Ansible task to change the reserved filesystem blocks
View ansible_task.yml
tasks:
- name: Change reserved blocks to 1 percent on ext4 filesystems that are not / mounted
shell: tune2fs -l {{ item.device }} | egrep "Reserved block count|Block count" | paste -sd\ | awk '{print ($7 / $3 * 100)}' | grep -q 1 || tune2fs -m1 {{ item.device }}
with_items:
- "{{ ansible_mounts }}"
when: item.fstype == 'ext4' and item.mount != '/'
register: tune2fs
changed_when: tune2fs.stdout != ""
@wtip
wtip / file_sd_config.yml.j2
Created Dec 15, 2016
Ansible template that uses ansible inventory data to generate file based service discovery for prometheus to scrape
View file_sd_config.yml.j2
---
# Uses ansible inventory to generate file based service discovery for prometheus to scrap
{# Loop over all groups except some #}
{% for group in groups if not group in ['all', 'ungrouped', prometheus_node_exporter_group] %}
{# Loop through hosts in group, if host is part of the prom-exports group, print hostname and port #}
- targets: [{% for host in groups[group] %}{% if prometheus_node_exporter_group in hostvars[host].group_names %}'{{ host }}:{{ prometheus_node_exporter_port }}', {% endif %}{% endfor %}]
labels:
job: '{{ group }}'
{% endfor %}
@wtip
wtip / testa.html
Last active Dec 29, 2015
PeerJS Data connections test - for some reason this is not working for me.
View testa.html
<!DOCTYPE html>
<html>
<head>
<title>test A - sender</title>
<script type="text/javascript" src="http://cdn.peerjs.com/0.3/peer.js"></script>
<script>
// PeerJS object
var peer = new Peer({ key: 'lwjd5qra8257b9', debug: 3, config: {'iceServers': [
{ url: 'stun:stun.l.google.com:19302' } // Pass in optional STUN and TURN server for maximum network compatibility
]}});