Introduction to AMQP

November 26, 2014 Leave a comment

AMQP is the Advanced Message Queuing Protocol, an open standard protocol for message orientation, queuing, routing, reliability and security, for which the RabbitMQ messaging server is the most popular implementation.

More:
http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/
http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol

Source:

https://kombu.readthedocs.org/en/latest/introduction.html

Learning Python

November 20, 2014 Leave a comment

Found some pretty interesting sites for learning python.

I normally get really bored doing exercises in books. So working with games and/or tasks is much more involving and interesting to me.

Checkio
Program Arcade Games

Small issue with Program Arcade Games site. Registration is pretty simple, just type in your email address and a password. Use numbers and text. Changing your password was not working when I tried.

Categories: Interesting, python

Distutils

November 20, 2014 Leave a comment

Very helpful distutils tutorial
https://wiki.python.org/moin/Distutils/Tutorial

Categories: Interesting, python Tags: ,

Downloading youtube videos with youtube-dl

October 4, 2014 Leave a comment

Problem:
I wanted to download lots of youtube videos, but I did not want to do so by my usual watch and download method.

Solution:
youtube-dl is a small command-line program to download videos from YouTube.com and a few more sites.

A short feature list of things you can do.

1. You can download entire playlists.

user@computer:~/lectures/discrete_maths$ youtube-dl --rate-limit 4M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx
 PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx: Downloading webpage
[download] Downloading playlist: Discrete Mathematics
 playlist Discrete Mathematics: Collected 19 video ids (downloading 19 of them)
[download] Downloading video #1 of 19
 Setting language
 Confirming age
 h_9WjWENWV8: Downloading webpage
 h_9WjWENWV8: Downloading video info webpage
 h_9WjWENWV8: Extracting video information
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 1_20-h_9WjWENWV8.mp4
[download]  42.6% of 184.48MiB at 525.55KiB/s ETA 03:26

2. You can interupt and continue from where you stopped.

user@computer:~/lectures/discrete_maths$ youtube-dl --rate-limit 1M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx
 PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx: Downloading webpage
[download] Downloading playlist: Discrete Mathematics
 playlist Discrete Mathematics: Collected 19 video ids (downloading 19 of them)
[download] Downloading video #1 of 19
 Setting language
 Confirming age
 h_9WjWENWV8: Downloading webpage
 h_9WjWENWV8: Downloading video info webpage
 h_9WjWENWV8: Extracting video information
[download] Resuming download at byte 82488037
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 1_20-h_9WjWENWV8.mp4
[download] 100% of 184.48MiB in 03:22
[download] Downloading video #2 of 19
 BrDto0heyaQ: Downloading webpage
 BrDto0heyaQ: Downloading video info webpage
 BrDto0heyaQ: Extracting video information
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 2_20-BrDto0heyaQ.mp4
[download]  20.7% of 221.93MiB at 529.26KiB/s ETA 05:40^C
ERROR: Interrupted by user

user@computer:~/lectures/discrete_maths$ youtube-dl --rate-limit 1M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx
 PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx: Downloading webpage
[download] Downloading playlist: Discrete Mathematics
 playlist Discrete Mathematics: Collected 19 video ids (downloading 19 of them)
[download] Downloading video #1 of 19
 Setting language
 Confirming age
 h_9WjWENWV8: Downloading webpage
 h_9WjWENWV8: Downloading video info webpage
 h_9WjWENWV8: Extracting video information
[download] Arsdigita 02 (Discrete Mathematics) Lecture 1_20-h_9WjWENWV8.mp4 has already been downloaded
[download] Downloading video #2 of 19
 BrDto0heyaQ: Downloading webpage
 BrDto0heyaQ: Downloading video info webpage
 BrDto0heyaQ: Extracting video information
[download] Resuming download at byte 48193596
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 2_20-BrDto0heyaQ.mp4
[download]  48.0% of 221.93MiB at 533.93KiB/s ETA 03:41^C
ERROR: Interrupted by user

It tracks where you reached in the play list and when you restart is skips through videos that have been downloaded and proceeds from there.

3. You can limit the amount of bandwidth that is used.

Download Options:
-r, –rate-limit LIMIT maximum download rate in bytes per second
(e.g. 50K or 4.2M)

youtube-dl --rate-limit 1M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx

Subtitle Options:
–write-sub write subtitle file
–write-auto-sub write automatic subtitle file (youtube
only)
–all-subs downloads all the available subtitles of
the video
–list-subs lists all available subtitles for the video
–sub-format FORMAT subtitle format (default=srt) ([sbv/vtt]
youtube only)
–sub-lang LANGS languages of the subtitles to download
(optional) separated by commas, use IETF
language tags like ‘en,pt’

4. You can check for available subtitles.

user@computer:~/Movies$ youtube-dl --list-subs http://www.youtube.com/watch?v=9RPWATPdImw
 Setting language
 Confirming age
 9RPWATPdImw: Downloading webpage
 9RPWATPdImw: Downloading video info webpage
 9RPWATPdImw: Extracting video information
 9RPWATPdImw: Looking for automatic captions
 9RPWATPdImw: Downloading XML
WARNING: Video doesn't have automatic captions
 9RPWATPdImw: Available subtitles for video: en
 9RPWATPdImw: Available automatic captions for video:

5. You can download movie with available subtitles.

user@computer:~/Movies$ youtube-dl --all-subs http://www.youtube.com/watch?v=9RPWATPdImw
 Setting language
 Confirming age
 9RPWATPdImw: Downloading webpage
 9RPWATPdImw: Downloading video info webpage
 9RPWATPdImw: Extracting video information
[info] Writing video subtitles to: [English Sub] Jet Li 2011 Flying.Swords.Of.Dragon.Gate [turn on caption for sub]-9RPWATPdImw.en.srt
[download] Destination: [English Sub] Jet Li 2011 Flying.Swords.Of.Dragon.Gate [turn on caption for sub]-9RPWATPdImw.mp4
[download] 100% of 431.77MiB in 12:32

Source:
http://rg3.github.io/youtube-dl/index.html

E: Internal Error, No file name for gdb:amd64

October 2, 2014 Leave a comment

Problem:

I was trying to install FLTK on 64bit debian and was installing one of the prerequisites gdb when I got the following error

E: Internal Error, No file name for gdb:amd64

Solution:
My friend google had this as a solution that worked for me. (Although it would be nice if I knew what it means.)

dpkg -i /var/cache/apt/archives/*.deb
dpkg --configure -a 

Source:
http://askubuntu.com/questions/266450/how-to-fix-e-internal-error-no-file-name-for-libc6
http://ubuntuforums.org/showthread.php?t=2185185

Categories: debian Tags: ,

From List Comprehensions to Generator Expressions

September 28, 2014 Leave a comment

From List Comprehensions to Generator Expressions
List comprehensions were added in Python 2.0. This feature originated as a set of patches by Greg Ewing with contributions by Skip Montanaro and Thomas Wouters. (IIRC Tim Peters also strongly endorsed the idea.) Essentially, they are a Pythonic interpretation of a well-known notation for sets used by mathematicians. For example, it is commonly understood that this:

{x | x > 10}

refers to the set of all x such that x > 10. In math, this form implies a universal set that is understood by the reader (for example, the set of all reals, or the set of all integers, depending on the context). In Python, there is no concept of a universal set, and in Python 2.0, there were no sets. (Sets are an interesting story, of which more in a future blog post.)

This and other considerations led to the following notation in Python:

[f(x) for x in S if P(x)]

This produces a list containing the values of the sequence S selected by the predicate P and mapped by the function f. The if-clause is optional, and multiple for-clauses may be present, each with their own optional if-clause, to represent nested loops (the latter feature is rarely used though, since it typically maps a multi-dimensional entity to a one-dimensional list).

more…

Source:
The history of python

Virtualenv

September 27, 2014 Leave a comment

Problem:

I had to work with different versions of django and having system wide installs would not work. I needed a clear demarcation between all versions.

Solution:
virtualenv is a tool to create isolated Python environments.

Source:

http://virtualenv.readthedocs.org/en/latest/virtualenv.html

Follow

Get every new post delivered to your Inbox.

Join 39 other followers