Skip to content

Instantly share code, notes, and snippets.

@marsam
marsam / unicode_csv.py
Created July 20, 2013 03:20
python unicode csv reader
# -*- coding: utf-8 -*-
#
# http://stackoverflow.com/a/904085
import csv
def UnicodeDictReader(utf8_data, **kwargs):
csv_reader = csv.DictReader(utf8_data, **kwargs)
for row in csv_reader:
@marsam
marsam / urllib3_transport.py
Created July 16, 2013 23:34
suds urllib3 transport
# -*- coding: utf-8 -*-
from urllib3 import connection_from_url
from urllib3.util import make_headers
from urllib3.exceptions import HTTPError
from suds.transport import Transport, TransportError, Reply
class Urllib3Transport(Transport):
"""
@marsam
marsam / instrucciones.rst
Created July 14, 2013 18:34
Instrucciones para escribir un texto

Instrucciones para escribir un texto

"El más rápido de los hombres, Aquiles, no podrá alcanzar nunca al más lento de los animales, la tortuga, si se da a ésta una ventaja inicial en una carrera."

Zenón de Elea

@marsam
marsam / fabfile.py
Created July 13, 2013 01:51
fabric vagrant integration
# -*- coding: utf-8 -*-
from fabric.api import env
from fabric.decorators import task
from fabric.operations import run, local
env.timeout = 120
# env.hosts = ['motoko', 'batou', 'tachikoma']
env.forward_agent = True
env.use_ssh_config = True
@marsam
marsam / onpe.py
Last active December 19, 2015 17:09
A simple onpe scraper
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
from urllib import urlencode
from urlparse import urlparse, urljoin, parse_qsl
except ImportError:
from urllib.parse import urlparse, urljoin, urlencode, parse_qsl
from lxml.html import parse
@marsam
marsam / euler.el.md
Last active December 18, 2015 23:48
project euler solutions in elisp

Euler solutions in elisp

Just for fun

  • Problem 1
  • Problem 2
  • Problem 3
  • Problem 4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Zipf's song
===========
Your slightly pointy-bearded boss has assigned you to write software to find
the best songs from different music albums. And the software should be finished
in an hour. But don’t panic, you don’t have to solve the problem of writing an
@marsam
marsam / .travis.yml
Created June 23, 2013 18:47
example python .travis.yml
# Tips:
# * [ci skip] in commits messages
# * https://secure.travis-ci.org/:username/:project.png
# * Use travislint
language: python
python:
- '2.6'
- '2.7'
@marsam
marsam / toallemployees.md
Created June 23, 2013 18:42
TO ALL EMPLOYEES

TO ALL EMPLOYEES

It has been brought to the management’s attention that some individuals have been using foul language in the course of normal conversation between employees. Due to complaints from some of the easily offended workers, this conduct will no longer be tolerated.

The management does, however, realize the importance of each person being able to properly express their feelings when communicating with their fellow employees. Therefore, the management has compiled the following code phrases so that the proper exchange of ideas and information can continue.

OLD PHRASE                                               NEW PHRASE

No fucking way ......................................... I’m not certain that’s feasible.

You’ve got to be shitting me ........................... Really.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Reversed Binary Numbers
~~~~~~~~~~~~~~~~~~~~~~~
Yi has moved to Sweden and now goes to school here. The first years of
schooling she got in China, and the curricula do not match completely in the
two countries. Yi likes mathematics, but now... The teacher explains the
algorithm for subtraction on the board, and Yi is bored. Maybe it is possible