Skip to content

Instantly share code, notes, and snippets.

@fopina
fopina / mopidy-yt-search.py
Last active April 4, 2016 14:40
simplified script to compare pafy searches (in mopidy-youtube) across systems
"""
Deps:
- pip install requests pafy youtube-dl
"""
import pafy
import requests
import string
import unicodedata
import re
from multiprocessing.pool import ThreadPool
@fopina
fopina / watchlog.sh
Last active January 8, 2022 17:30
Bash script to tail a log file and push new lines to your phone
#!/bin/bash
#
# Watch log
#
# Script that will "tail -f" a log file and push the new lines to your phone
# using a Telegram bot (@PushItBot - https://fopina.github.io/tgbot-pushitbot/)
function pushit() {
# this function receives the first parameter passed to the script
# plus the latest line of the log file
@fopina
fopina / mic_client.py
Created July 28, 2016 12:24
microphone streaming with pyAudio
#!/usr/bin/env python
import pyaudio
import socket
import sys
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
CHUNK = 4096
@fopina
fopina / meo-ipv6-off-playbook.yml
Created May 16, 2018 13:44
Disable IPv6 in MEO Router ansible
# requires ansible 2.4
# usage:
# ansible-playbook playbook.yml -i 192.168.1.254,
- hosts: all
gather_facts: false
tasks:
# ansible 2.4 telnet plugin does not add \r
# and the router requires it so...
- name: disable ipv6 in meo router
package main
import (
"os"
"fmt"
"math/rand"
"github.com/veandco/go-sdl2/sdl"
)
const (
@fopina
fopina / lenticular.py
Last active January 8, 2022 17:30
Poor Man's Lenticular
#!/usr/bin/env python
# https://www.youtube.com/watch?v=mmGB9ADKr5Y
import argparse
from PIL import Image
DEFAULT_STRIPS = 8
@fopina
fopina / portquiz.py
Last active January 8, 2022 17:30
portquiz.net quick tester
# directly from
# https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor-example
import concurrent.futures
import urllib.request
def check_port(port):
print('testing %d \r' % port, end='')
# smaller response text!
r = urllib.request.Request('http://portquiz.net:%d' % port, headers={'User-Agent': 'curl'})
@fopina
fopina / handlers_main.yml
Created July 9, 2019 23:18
fluentbit ansible role
---
- name: Restart Fluentbit
service:
name: td-agent-bit
enabled: true
state: restarted
- hosts: all
gather_facts: True
become: True
roles:
- role: fluentbit
fluentbit_inputs:
- systemd:
- Tag: docker
- Systemd_Filter: _SYSTEMD_UNIT=docker.service
- cpu:
@fopina
fopina / conftest.py
Created May 28, 2020 10:01
pytest-django --debug-sql
__force_django_debug = False
def pytest_runtest_setup():
if __force_django_debug:
# required for logging SQL as pytest always sets DEBUG to False (why?)
# https://github.com/pytest-dev/pytest-django/blob/master/pytest_django/plugin.py#L473
from django.conf import settings
settings.DEBUG = True