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
| function _geraAlias($palavra){ | |
| //Transforma uma palavra em uma alias, usada em URL's amigáveis | |
| $palavra = strtolower($palavra); | |
| #Removendo os caracters especiais | |
| $palavra = str_replace(".", "", $palavra); | |
| $palavra = str_replace("/", "", $palavra); | |
| $palavra = str_replace("\\", "", $palavra); | |
| $palavra = str_replace(":", "", $palavra); | |
| $palavra = str_replace("(", "", $palavra); | |
| $palavra = str_replace(")", "", $palavra); |
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
| # Need a way to kill the addictiveness of the 2048 game? Paste this into yo' console. | |
| # http://gabrielecirulli.github.io/2048/ | |
| var t;(t=new GameManager(4,KeyboardInputManager,HTMLActuator,LocalStorageManager));t.startTiles=0;t.setup();while(t.grid.cellsAvailable()){t.grid.insertTile(new Tile(t.grid.randomAvailableCell(), 1024));};t.actuate(); |
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
| ;;; 2048.el --- play 2048 in Emacs (updated graphical version) | |
| ;; A mild extension for graphical improvements on the 2048-game.el | |
| ;; by Liam O'Connor to the game 2048 implemented in emacs by | |
| ;; Zachary Kafner | |
| ;; Copyright 2014 Zachary Kanfer | |
| ;; Author: Zachary Kanfer <zkanfer@gmail.com> | |
| ;; Version: 2014.03.27 |
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
| arq = open('alice.txt') | |
| texto = arq.read() | |
| texto = texto.lower() | |
| import string | |
| for c in string.punctuation: | |
| texto = texto.replace(c, ' ') | |
| texto = texto.split() | |
| dic = {} | |
| for p in texto: |
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 heapq import heappush, heappop | |
| def heapsort(v): | |
| h = [] | |
| for x in v: | |
| heappush(h, x) | |
| return [heappop(h) for i in range(len(h))] | |
| from random import shuffle | |
| v = list(range(8)) | |
| shuffle(v) |
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
| def merge(p, q, r, v): | |
| w = [] | |
| i, j = p, q | |
| while i < q and j < r: | |
| if v[i] <= v[j]: | |
| w.append(v[i]) | |
| i += 1 | |
| else: | |
| w.append(v[j]) | |
| j += 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
| def merge(e, d): | |
| r = [] | |
| i, j = 0, 0 | |
| while i < len(e) and j < len(d): | |
| if e[i] <= d[j]: | |
| r.append(e[i]) | |
| i += 1 | |
| else: | |
| r.append(d[j]) | |
| j += 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
| def dec2bin(n): | |
| b = '' | |
| while n != 0: | |
| b = b + str(n % 2) | |
| n = int(n / 2) | |
| return b[::-1] | |
| def d2b(n): | |
| if n == 0: | |
| return '' |
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
| #@gwidion code | |
| print"".join(u"\x1b[%dm%c%s"%((42+y%2^y>>3&1),((1,3,2,-1,0,2,3,1)+(4,)*8+32*(-9781,)+8*(10,)+(7,9,8,5,6,8,9,7))[y]+9813,(y+1)%8and" "or" \x1b[48m\n")for y in range(64)) |
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
| import urllib.request | |
| import json | |
| resp = urllib.request.urlopen('http://worldcup.sfg.io/matches').read() | |
| for jogo in json.loads(resp.decode('utf-8')): | |
| if jogo['status'] == 'completed': | |
| print (jogo['home_team']['country'], jogo['home_team']['goals'], 'x', jogo['away_team']['country'], jogo['away_team']['goals']) |
OlderNewer