Skip to content

Instantly share code, notes, and snippets.

View acwoss's full-sized avatar
🐍

Anderson Carlos Woss acwoss

🐍
View GitHub Profile
@acwoss
acwoss / main.php
Created January 14, 2019 10:48
ZanyRoastedAdmins created by acwoss - https://repl.it/@acwoss/ZanyRoastedAdmins
// https://pt.stackoverflow.com/q/355941/5878
$gabarito = '1;1;A|2;1;B|3;1;C|4;1;A|5;1;A|6;2;D|7;2;C|8;2;B|9;2;A|10;2;A';
$materias = [];
foreach (explode('|', $gabarito) as $resposta) {
list($pergunta, $materia, $alternativa) = str_getcsv($resposta, ';');
if ( ! array_key_exists($materia, $materias)) {
<?php
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Response\HtmlResponse;
use Woss\Pipeline;
require "../vendor/autoload.php";
$pipeline = new Pipeline([
function ($request, $next) {
if (!isset($request->getAttribute('user'))) {
return new Response(401, 'Sai daqui demônio!');
}
return $next->handle($request);
},
function ($request, $next) {
class Pipeline implements RequestHandlerInterface
{
public function __constuct($handlers)
{
$this->handlers = $handlers;
}
public function handle(Request $request): Response
{
$handler = current($this->handlers);
@acwoss
acwoss / main.py
Created September 26, 2018 18:04
QuickDarkbluePublishers created by acwoss - https://repl.it/@acwoss/QuickDarkbluePublishers
import time
def is_prime(number):
i = 3
while i**2 <= number:
if number % i == 0:
return False
i += 2
return True
@acwoss
acwoss / main.py
Created September 26, 2018 13:19
GlumStunningRouter created by acwoss - https://repl.it/@acwoss/GlumStunningRouter
import math, time
def sieve_of_eratosthene(N):
# Cria-se uma lista referente a todos os inteiros entre 0 e N:
A = [True] * (N+1)
# Define os números 0 e 1 como não primos:
A[0] = A[1] = False
@acwoss
acwoss / main.py
Created September 24, 2018 18:48
FearlessMagnificentCharactercode created by acwoss - https://repl.it/@acwoss/FearlessMagnificentCharactercode
code = '''
def perfect_numbers(N):
def sieve_of_eratosthene(N):
A = [True] * (N+1)
A[0] = A[1] = False
for value, prime in enumerate(A):
if prime:
yield value
@acwoss
acwoss / main.py
Created September 24, 2018 18:36
UnsungQueasyMap created by acwoss - https://repl.it/@acwoss/UnsungQueasyMap
def perfect_numbers(N):
def sieve_of_eratosthene(N):
A = [True] * (N+1)
A[0] = A[1] = False
for value, prime in enumerate(A):
if prime:
yield value
for i in range(value**2, N+1, value):
A[i] = False
@acwoss
acwoss / main.py
Created September 24, 2018 16:36
HatefulRundownPaint created by acwoss - https://repl.it/@acwoss/HatefulRundownPaint
from math import factorial, radians, isclose, sin
def seno(x, n=7):
x = radians(x)
def termo_geral(x, i):
return ((-1)**i / factorial(2*i+1)) * (x**(2*i+1))
def termos(x, n):
for i in range(n):
@acwoss
acwoss / main.py
Created September 24, 2018 16:29
HatefulRundownPaint created by acwoss - https://repl.it/@acwoss/HatefulRundownPaint
from math import factorial, radians, isclose, sin
def seno(x, n=7):
# Se o ângulo for em graus, converte para radianos
if x > 1:
x = radians(x)
def termo_geral(x, i):
return ((-1)**i / factorial(2*i+1)) * (x**(2*i+1))