Skip to content

Instantly share code, notes, and snippets.

View fmasanori's full-sized avatar

Fernando Masanori fmasanori

View GitHub Profile
@fmasanori
fmasanori / sound_panel.py
Created November 28, 2013 21:18
sound_panel class for DJ Mix
from tkinter import *
import pygame.mixer
class SoundPanel(Frame):
def track_toggle(self):
if self.track_playing.get() == 1:
self.track.play(loops = -1)
else:
self.track.stop()
def change_volume(self, v):
@fmasanori
fmasanori / hfmix.pyw
Created November 28, 2013 21:27
Head First DJ Mix
from tkinter import *
from sound_panel import *
import pygame.mixer
import os
app=Tk()
app.title('Head First Mix')
mixer = pygame.mixer
mixer.pre_init(buffer = 300)
mixer.init()
@fmasanori
fmasanori / Thanking_fb.py
Created January 29, 2014 20:49
Thanking my 500+ friends who wished me on my birthday on Facebook, by by Akshit Khurana
import requests
import json
AFTER = 1353233754
TOKEN = ' <insert token here> '
#by Akshit Khurana
def get_posts():
"""Returns dictionary of id, first names of people who posted on my wall
between start and end time"""
query = ("SELECT post_id, actor_id, message FROM stream WHERE "
g = {}
g[1] = [2, 3, 5]
g[2] = [1, 6, 4]
g[3] = [1, 4, 7]
g[4] = [2, 3, 8]
g[5] = [1, 6, 7]
g[6] = [2, 5, 8]
g[7] = [3, 5, 8]
g[8] = [4, 6, 7]
removidos = [True] + 8 * [False]
@fmasanori
fmasanori / guess_names.py
Created April 8, 2014 21:54
Guess girl names
import random
girls = '''Júlia Sophia Isabella Manuela Giovanna Alice Laura
Luiza Beatriz Mariana Yasmin Gabriela Rafaela Isabelle Lara
Letícia Valentina Nicole Sarah Vitória Isadora Lívia Helena
Lorena Clara Larissa Emanuelly Heloisa Marina Melissa Gabrielly
Eduarda Rebeca Amanda Alícia Bianca Lavínia Fernanda Ester
Carolina Emily Cecília Pietra Milena Marcela Laís Natália
Maria Bruna Camila Luana Catarina Olivia Agatha Mirella
Sophie Stella Stefany Isabel Kamilly Elisa Luna Eloá Joana
Mariane Bárbara Juliana Rayssa Alana Caroline Brenda Evelyn
class int42(int):
def __init__(self, n):
int.__init__(n)
def __add__(a, b):
return 42
def __str__(n):
return '42'
@fmasanori
fmasanori / jogos.py
Last active October 30, 2022 00:00
World Cup in six lines of Python 3. Jogos da Copa do Mundo em cinco linhas de Python 3.
import requests
jogos = requests.get('http://worldcup.sfg.io/matches').json()
for jogo in jogos:
if jogo['status'] in ('completed', 'in progress'):
print (jogo['home_team']['country'], jogo['home_team']['goals'], 'x',
jogo['away_team']['country'], jogo['away_team']['goals'])
@fmasanori
fmasanori / JS Chess
Last active August 29, 2015 14:04
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))
@fmasanori
fmasanori / dec2bin.py
Created August 4, 2014 14:19
Decimal para binário em Python 3
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 ''
@fmasanori
fmasanori / mergesort.py
Last active August 29, 2015 14:05
mergesort
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