Skip to content

Instantly share code, notes, and snippets.

View dionimf's full-sized avatar

Dioni dionimf

View GitHub Profile
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);
@dionimf
dionimf / 2048.js
Created June 26, 2014 01:17 — forked from bih/2048.js
# 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();
@dionimf
dionimf / 2048.el
Created June 26, 2014 01:17 — forked from liamoc/2048.el
;;; 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
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:
@dionimf
dionimf / heapsort.py
Last active September 14, 2015 10:30 — forked from fmasanori/heapsort.py
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)
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
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
@dionimf
dionimf / dec2bin.py
Last active August 29, 2015 14:06 — forked from fmasanori/dec2bin.py
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 ''
@dionimf
dionimf / JS Chess
Last active August 29, 2015 14:06 — forked from fmasanori/JS Chess
#@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))
@dionimf
dionimf / jogos.py
Last active August 29, 2015 14:06 — forked from fmasanori/jogos.py
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'])