This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int equi ( int[] arr ) { | |
long left = 0; | |
long right = 0; | |
/* sumamos todos a la izquierda */ | |
for(int i : arr) { | |
left += i; | |
} | |
/* vamos comprobando y restando a la izquierda y sumando a la dcha */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/vundle | |
call vundle#rc() | |
Bundle 'gmarik/vundle' | |
Bundle 'tpope/vim-fugitive' | |
Bundle 'kevinw/pyflakes' | |
Bundle 'kevinw/pyflakes-vim' | |
Bundle 'nvie/vim-flake8' | |
Bundle 'kien/ctrlp.vim' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(', ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
import gc | |
def iterjam(): | |
import functools as ft | |
def iterjam2(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer