Skip to content

Instantly share code, notes, and snippets.

View turicas's full-sized avatar

Álvaro Justen turicas

View GitHub Profile
@turicas
turicas / youtube-download-merge.sh
Created August 8, 2011 03:51
Download a lot of videos from YouTube and merge it - example: talk by @viniciusteles about software problems (7 videos) at AgileBrazil2011
#!/bin/bash
###############################################################################
# This script downloads a lot of videos from YouTube and merge them into a #
# single .FLV file using mencoder. #
# #
# Requires Python, wget|curl and mencoder #
# Python and wget actually are installed on many GNU/Linux distributions and #
# Mac OS (sorry, Windows' users) #
# To install mencoder in Ubuntu/Debian, just execute as root: #
# aptitude install mencoder #
@turicas
turicas / virtualenv_with_sudo-iu
Created November 5, 2011 00:23
Error in pip installation
root@debian-32:~# sudo -iu git virtualenv /opt/gitosis/test
New python executable in /opt/gitosis/test/bin/python
Installing setuptools.............done.
Installing pip...............done.
root@debian-32:~# sudo -iu git pwd
/opt/gitosis
@turicas
turicas / nonblocking.py
Created November 7, 2011 08:06
Non-blocking file-like class for read() (Python)
import threading
class NonBlocking(threading.Thread):
def __init__(self, fp):
threading.Thread.__init__(self)
self.fp = fp
self.read_buffer = []
self.running = True
self.start()
@turicas
turicas / add-to-fabric-operations.py
Created November 7, 2011 17:42
Example of a possible implementation of pipe() for fabric: "a remote (SSH) Popen". It is just a proof-of-concept! (shame)
import socket
import types
def new_readline(self, n=-1):
buf = []
bytes_read = True
while bytes_read:
try:
bytes_read = self._old_read(1)
buf.append(bytes_read)
@turicas
turicas / example_usage.txt
Created November 18, 2011 20:16
Get the number of followers and following on Twitter
alvaro@ideas:~$ ipython --no-banner -i followers_following.py
In [1]: number_of_following('turicas')
Out[1]: 627
In [2]: number_of_followers('turicas')
Out[2]: 1253
@turicas
turicas / Makefile
Created December 3, 2011 23:22
Create slugs and abbreviate names using Python
test:
clear
nosetests --with-coverage --cover-package name_utils test_name_utils.py
clean:
find -regex '.*\.pyc' -exec rm {} \;
find -regex '.*~' -exec rm {} \;
.PHONY: test clean
@turicas
turicas / email_utils.py
Last active April 9, 2024 19:56
Send emails easily in Python (with attachments and multipart)
#!/usr/bin/env python
# coding: utf-8
# This little project is hosted at: <https://gist.github.com/1455741>
# Copyright 2011-2020 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
import os
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@turicas
turicas / example_image_utils.py
Created December 10, 2011 19:04
Layer on top of Python Imaging Library (PIL) to write text in images easily
#!/usr/bin/env python
# coding: utf-8
# You need PIL <http://www.pythonware.com/products/pil/> to run this script
# Download unifont.ttf from <http://unifoundry.com/unifont.html> (or use
# any TTF you have)
# Copyright 2011 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
from image_utils import ImageText
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the