Skip to content

Instantly share code, notes, and snippets.

@alexsavio
alexsavio / copy_subtitles_sync.py
Last active December 25, 2016 23:38
CLI command that reads the time data from one SRT file, the speech text from another, mixes them and saves the result into a new srt file.
#!/usr/bin/env python
import os
import os.path as path
import argparse
import logging
from chardet.universaldetector import UniversalDetector
from pysrt import SubRipFile, SubRipItem
logging.basicConfig(level=logging.INFO)
import colorsys
def hex_to_rgb(hex_str):
"""Returns a tuple representing the given hex string as RGB.
>>> hex_to_rgb('CC0000')
(204, 0, 0)
"""
if hex_str.startswith('#'):
hex_str = hex_str[1:]
@alexsavio
alexsavio / repo.py
Created June 25, 2014 14:19
GitHub to Gitlab repository version copier/control.
#content of the config file .python-gitlab.cfg:
#[global]
#default = local
#ssl_verify = true
#[local]
#url = http://***************
#private_token = **************
#### Start IPython, generate SHA1 password to use for IPython Notebook server
$ ipython
Python 2.7.5 |Anaconda 1.8.0 (x86_64)| (default, Oct 24 2013, 07:02:20)
Type "copyright", "credits" or "license" for more information.
IPython 1.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
@alexsavio
alexsavio / download-subs.py
Last active September 14, 2018 09:20
Python and Subliminal script to download subtitles automatically. (Just use: http://subliminal.readthedocs.org/en/latest/user/usage.html#cli)
#!/usr/bin/env python
#pip install subliminal babelfish
from __future__ import unicode_literals # for python 2 only
import os
import sys
import os.path as op
import logging as log
@alexsavio
alexsavio / pip-update
Last active August 29, 2015 13:56
Python script to use pip and upgrade all packages in the currently activated virtualenv.
#!/usr/bin/env python
import os
import sys
import subprocess
env_root = os.getenv('VIRTUAL_ENV')
if sys.platform == 'win32':
bin = 'Scripts'
@alexsavio
alexsavio / kickstart
Last active January 4, 2016 00:18 — forked from ludo/kickstart
install
# Ridiculous URL... I know...
url --url http://nl.archive.ubuntu.com/ubuntu/ubuntu/ubuntu/ubuntu/ubuntu/
text
lang en_US
langsupport en_US
keyboard es
#rootpw pa$$word # you should replace, and use --iscrypted
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 128m;
client_body_buffer_size 256k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@alexsavio
alexsavio / CURL_examples.ipynb
Last active December 31, 2015 05:59
IPython notebooks on how to use Virtualenv and Virtualenvwrapper
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.