I hereby claim:
- I am diezguerra on github.
- I am saul (https://keybase.io/saul) on keybase.
- I have a public key whose fingerprint is 41CC 20BC 641C 0215 84F8 5736 2F7D 9259 08E9 7490
To claim this, I am signing this object:
# Snippet setting git branch and git dirty helper | |
# Commit at the end kept from original snippet, I added the rev-parse stuff and the proper redirection. | |
set fish_git_dirty_color red | |
set fish_git_clean_color brown | |
function parse_git_dirty | |
if test (git status 2> /dev/null ^&1 | tail -n1) != "nothing to commit (working directory clean)" | |
echo (set_color $fish_git_dirty_color) | |
else |
I hereby claim:
To claim this, I am signing this object:
In = lambda: map(int, raw_input().split()) | |
integer_no, unique_no = In() | |
a = In() | |
uniques = [In().pop() for _ in range(unique_no)] | |
aux = [0] * integer_no | |
seen = set() | |
for idx in xrange(integer_no - 1, -1, -1): |
import dateutil.parser | |
import pytz | |
date_string = '2013-10-14T12:47:12.776270' | |
date_object = pytz.timezone('America/Los_Angeles').localize(dateutil.parser.parse(date_string)) | |
print date_object.isoformat() |
import requests | |
import json | |
r = requests.get('https://graph.facebook.com/search?q=&type=adcountry&limit=500') | |
countries = {country['name']: country['country_code'] for country in r.json()['data']} | |
assert countries['Spain'] == 'ES' | |
assert len(countries) == 216 |
#!/usr/bin/env python2.7 | |
import gc | |
def iterjam(): | |
import functools as ft | |
def iterjam2(): |
""" | |
Result: | |
Using original function 1000 loops, best of 3: 200 us per loop | |
Using itertools.chain 10000 loops, best of 3: 130 us per loop | |
Using joined sets 10000 loops, best of 3: 142 us per loop | |
Using double the tags and modulo 1000 loops, best of 3: 184 us per loop | |
""" |
a_range = range(12) | |
a_range[-2:] = range(10,20) | |
assert a_range == range(20) | |
a_range[10:11] = range(10)[::-1] | |
a_range[20:] = [] | |
assert a_range == range(10) + range(10)[::-1] | |
keywords = "apple, pear, banana, lemon and orange" | |
keywords = keywords.split(', ') |
# -*- coding: utf-8 -*- | |
# <nbformat>3.0</nbformat> | |
# <rawcell> | |
# How to filter Python dictionaries, the right way. | |
# | |
# Expected output: | |
# Original list lookup => 100 loops, best of 3: 9.82 ms per loop | |
# Dict trick lookup => 1000 loops, best of 3: 315 us per loop |