Skip to content

Instantly share code, notes, and snippets.

Avatar

iury IuryAlves

View GitHub Profile
View app.py
# coding: utf-8
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route("/send", methods=["POST"])
def send():
return request.form["data"]
View variables.py
# raw types are immutable variables
x = 1
def change(x):
x = 2
change(x)
assert x == 1
# you can use the global statement, but it's not a good practice
View properties.py
class Water(object):
def __init__(self):
self._wet = False
@property
def wet(self):
return self._wet
@wet.setter
View game.py
WHITE = (255, 255, 255)
class Game(object):
SCREEN_SIZE = (800, 600)
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode(Game.SCREEN_SIZE)
self.screen.fill(WHITE)
View spy_example.js
describe("[bffdcas] EditarPerfilModel reset password ", function() {
var alertModel;
beforeEach(angular.mock.module('perfil_usuario'));
beforeEach(angular.mock.module('mockhttp'));
beforeEach(function (){
// mocka o alertModel
alertModel = {
View json.py
import json
# Apenas um exemplo de como fazemos
# jeito errado
with open('dados.json', 'w') as f:
f.write('{dados:' + json.dumps(['dados']) + '}')
# jeito certo
with open('dados.json', 'w') as f:
View home.html
{% extends '/gerenciar/base.html' %}
{% block js %}
<script type="text/javascript" src="/static/angular/js/angular.min.js"></script>
<script type="text/javascript" src="/static/jogos/jogo_form.js"></script>
<script type="text/javascript">
var jogoApp = angular.module('jogoApp', ['jogoModulo']).controller("JogoController", function($scope){
$scope.jogo={tit: 'Teste', map: 'Teste', qtd: '1', tmp: 'Sem limite', grp: 'Jogo Aberto'};
$scope.mostra=false;
$scope.formOnOff=function(){
View tests.py
# coding: utf-8
import unittest
from scheduling_algorithms import FCFS, SJF, SRTF, RoundRobin, FilaMultiNivelComFeedBack
from structures import Process, PCB
class ScheduleAlgorithm(unittest.TestCase):
def test_fcfs(self):
p1 = Process(PCB(24 ,0 ,1))
View scheduling_algorithms.py
# coding: utf-8
import os
import random
from structures import *
class SchedulingAlgorithm(object):
"""
Classe base para todos os algoritmos