Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / flask-vs-django.sh
Last active March 13, 2016 20:15
flask versus Django request times (without tweaking)
#!/bin/bash
set -e
DIR=$(mktemp -d)
function setup_venv() {
cd $DIR
virtualenv env
. env/bin/activate
@fopina
fopina / emuparadise.py
Last active January 8, 2022 17:30
Scraper script for emuparadise.me
#!/usr/bin/env python
"""
Scraper script for emuparadise.me
Usage
=====
```
fopina$ ./emuparadise.py -h
usage: emuparadise.py [-h] [--download] [--search] [--system SYSTEM] [--list]
@fopina
fopina / qpushme.py
Created December 18, 2015 15:07
Python function to push messages using https://qpush.me
import urllib2
import urllib
def qpushit(name, code, message):
data = urllib.urlencode({
'name': name,
'code': code,
'sig': '',
'cache': False,
@fopina
fopina / peewee_pgsql_test.py
Created August 7, 2015 10:32
get_or_create() versus try: .create() in peewee+pgsql
#!/usr/bin/env python
"""
Sometimes we need to use a model in peewee that we want to get from DB or create if it doesn't exist.
We have get_or_create and create_or_get for that.
But what if it don't really want the instance of the model? We simply want to create it (for logging purposes maybe)?
Is there a faster method than these two, assuming we will be inserting a lot of duplicate records?
I usually simply do:
try:
Model.create(...)
@fopina
fopina / dbtest.py
Created July 23, 2015 17:00
sqlite3 vs unqlite
#!/usr/bin/env python
'''
pip install pysqlite
pip install unqlite
'''
import sqlite3
from unqlite import UnQLite
import timeit
@fopina
fopina / bulk_trakt.py
Created June 23, 2015 16:35
Trakt.tv Bulk AddToHistory
from urllib2 import Request, urlopen
import json
import sys
URL = 'https://api-v2launch.trakt.tv'
# create your own app
API_KEY = ''
SECRET = ''
PIN_URL = 'https://trakt.tv/pin/????'