Skip to content

Instantly share code, notes, and snippets.

@wernight
wernight / podcast.py
Last active August 29, 2015 14:16
Download and upload to Google Music Regionaljournal Zuerich Schaffhausen podcasts.
#!/usr/bin/env python
'''
Setup:
$ pip install gmusicapi==4.0.0 requests==2.5.1
$ mkdir podcasts
$ python podcast.py
'''
import requests
import bs4
@wernight
wernight / flash-debug.sh
Last active August 29, 2015 14:05
Find and install the latest Flash plugin debug for Ubuntu
#!/bin/sh -e
# Find the latest Flash plugin debug for Linux and install it removing the standard plugin first.
#
# Usage: curl https://gist.githubusercontent.com/wernight/a3c1e30a3c64e350197f/raw/8c49f7c521a9ccb215edcdf9696642f37edbbb08/flash-debug.sh | sh
echo "Finding latest version from http://www.adobe.com/support/flashplayer/downloads.html"
flash_download=$(curl --silent http://www.adobe.com/support/flashplayer/downloads.html | grep -Po '(?<=")http[^"]*flashplayer_\d+_plugin_debug[^"]*\.tar\.gz(?=")' | head -n 1)
echo "Found and extracting $flash_download"
tmp_dir=/tmp/flashplayer_plugin_debug
"""
Requires gmusicapi from http://unofficial-google-music-api.readthedocs.org/en/latest/usage.html
"""
import os
from gmusicapi import Musicmanager
# From https://support.google.com/googleplay/answer/1100462
AUDIO_FILE_EXTENSIONS = ('.mp3', '.m4a', '.wma', '.flac', '.ogg', '.m4a')
def upload_recursive(basedir):
@wernight
wernight / inotifyexec.py
Last active June 27, 2023 22:47
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.
@wernight
wernight / git-submit
Last active December 19, 2015 07:09
Gerrit `git submit` helper. Does a `git push HEAD:origin/refs/for/$current_branch_name` and supports drafts. Works in msysgit and in most Linux/Mac.
#!/bin/bash -e
#
# Gerrit `git submit` helper. Does a `git push HEAD:origin/refs/for/$current_branch_name` and supports drafts.
#
# Get latest version from https://gist.github.com/wernight/5916904
#
# Install:
# 1. Save this script under one of you path (e.g., ~/bin/ or /usr/local/bin)
# 2. Make it executable (e.g., chmod +x ~/bin/git-submit)
#
@wernight
wernight / gist:4978408
Created February 18, 2013 16:00
Custom NAnt task to execute multiple <exec> tasks in parallel and wait until they all completed.
using System;
using System.Threading.Tasks;
using NAnt.Core;
using NAnt.Core.Attributes;
using NAnt.Core.Tasks;
namespace MyTasks
{
[TaskName("parallelexec")]
public class ParallelExecTask : TaskContainer
@wernight
wernight / git-submite
Created October 18, 2012 22:24
'git submit' which pushes to Gerrit matching branch
#!/bin/sh -e
#
# Save this file as ~/bin/git-submit
#
# Usage: git submit [--draft] [remote]
# Example:
# 'git submit' executed on a Git branch tracking origin/master will push to refs/for/master.
#
REMOTE=origin