Skip to content

Instantly share code, notes, and snippets.

View thor27's full-sized avatar

Thomaz de Oliveira dos Reis thor27

View GitHub Profile
from time import sleep
import sys
start = 0
left = 1
right = 2
up = 3
down = 4
def print_screen(matrix, time=0.3, last_frame=False):
@thor27
thor27 / elefante.py
Last active February 20, 2017 13:18 — forked from fchevitarese/elefante.py
Canta a musiquinha do elefante que incomoda muita gente.
"""Música do elefante.
Digite a quantidade de vezes que vai contar, preferencialmente um número par.
"""
elefantes = int(input('Digite quantos elefantes quer contar: '))
ini = "{numero} {plural} muita gente!\n{numero2} elefantes {incomodam} muito mais.\n"
for elefante in range(1, elefantes):
print(ini.format(
numero=elefante,
@thor27
thor27 / raise_windows.py
Last active November 11, 2016 16:46
Raise all windows of the active one. Bind this to a shortcut (such as SUPER + UP) and when you press all windows of this app goes foreground. With a special hack for CSSH. Taken from here with updates: http://askubuntu.com/questions/446521/how-to-show-all-windows-of-an-application/
#!/usr/bin/env python3
import subprocess
import getpass
import time
def get(command):
return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8")
def execute(command):
subprocess.Popen(["/bin/bash", "-c", command])
# -*- encoding: utf-8 -*-
#!/usr/bin/python
import httplib, urllib, json, sys
from pprint import pprint
from datetime import datetime
import optparse
#URI = 'localhost:5008/static/feed.html'
URI = 'g1.globo.com/bemestar/no-ar/index.html'
@thor27
thor27 / hanoi.py
Last active August 29, 2015 13:56
Hanoi Tower
import os
class Game(dict):
def __init__(self, number_of_piecies, frontend=lambda x:None, start_column=0b001, end_column=0b100):
super(Game, self).__init__()
for column in [0b001, 0b010, 0b100]:
self[column] = Column(self)
self.frontend = frontend(self)
for num in range(number_of_piecies,0,-1):
Piece(num,self,0b001)
curl -XPOST "http://localhost:9200/example/" -d '
{
"settings":{
"index":{
"analysis":{
"analyzer":{
"my_analyzer":{
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "my_metaphone"]