This file contains hidden or 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 python | |
| import unittest | |
| from union_find import UnionFind | |
| class TestUnionFind(unittest.TestCase): | |
| def test_init(self): | |
| u = UnionFind(5) | |
| self.assertEquals([0, 1, 2, 3, 4], u.id) |
This file contains hidden or 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
| from fabric.api import task, local, sudo, run, prefix, env, cd | |
| from fabric.contrib.files import exists, first | |
| from contextlib import contextmanager, nested | |
| def once(s): | |
| """Command_prefixes is a list of prefixes""" | |
| if s not in env.command_prefixes: | |
| return s | |
| return 'true' |
This file contains hidden or 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 python | |
| import httplib | |
| import StringIO | |
| import hashlib | |
| import uuid | |
| import random | |
| import string | |
| import sys | |
| import os | |
| import subprocess |
This file contains hidden or 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 -*- | |
| GRID = { | |
| 1: 1, | |
| 2: 2, | |
| 3: 3, | |
| 4: 4, | |
| 5: 5, | |
| 6: 6, | |
| 7: 7, |
This file contains hidden or 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
| $ cat ~/path/to/.git/hooks/post-checkout | |
| #!/bin/bash | |
| echo "Cleaning pyc" | |
| find . -iname '*.pyc' -delete |
This file contains hidden or 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
| -- repeat | |
| rep :: Int -> x -> [x] | |
| rep 0 x = [] | |
| rep n x = [x] ++ rep (n-1) x | |
| -- get value at | |
| at :: [x] -> Int -> x | |
| at (x:xs) 0 = x | |
| at (x:xs) n = at (xs) (n-1) |
This file contains hidden or 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
| class SomeClass: | |
| def some_method(self): | |
| some_function() | |
| def some_function(): | |
| pass |
This file contains hidden or 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
| # play <some song name> | |
| function play { | |
| youtube-dl --default-search=ytsearch: \ | |
| --youtube-skip-dash-manifest \ | |
| --output="${TMPDIR:-/tmp/}%(title)-s%(id)s.%(ext)s" \ | |
| --restrict-filenames \ | |
| --format="bestaudio[ext!=webm]" \ | |
| --exec=mplayer -vvv "$*" | |
| } |
This file contains hidden or 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
| # Example of how to query elasticsearch with httpie | |
| echo '{"query": {"match": {"name": "beer"}}}' | http POST :9200/my_index/my_doctype/_search/ |
This file contains hidden or 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
| from collections import deque | |
| def sol(inp): | |
| strd = sorted(inp) | |
| enum = enumerate(strd) | |
| for idx, item in enum: | |
| # ASEGURARSE QUE ESTO SEA UN TRIO SIEMPRE | |
| next_3 = idx + 3 |
OlderNewer