Skip to content

Instantly share code, notes, and snippets.

@wtip
wtip / testa.html
Last active December 29, 2015 20:59
PeerJS Data connections test - for some reason this is not working for me.
<!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
]}});
@wtip
wtip / file_sd_config.yml.j2
Created December 15, 2016 16:19
Ansible template that uses ansible inventory data to generate file based service discovery for prometheus to scrape
---
# 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 / ansible_task.yml
Created May 18, 2020 20:23
Ansible task to change the reserved filesystem blocks
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 / picam_stream.py
Last active August 16, 2021 16:32
picamera, gstreamer and rtsp-simple-server scripts and config
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