Skip to content

Instantly share code, notes, and snippets.

"""
gausskernel.py
Vasco Flores
unidim:
0.00081721 0.02804124 0.23392411 0.47442500 0.23392411 0.02804124 0.00081721
sum:
0.9999901346984609
bidim:
@vxf
vxf / db.sql
Created December 9, 2017 19:14
-- phpMyAdmin SQL Dump
-- version 4.4.10
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 09, 2017 at 08:14 PM
-- Server version: 10.0.30-MariaDB-0+deb8u2
-- PHP Version: 5.6.30-0+deb8u1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SELECT Aluno.numero, Aluno.nome, Classificacao.nota FROM Aluno
JOIN Classificacao ON Classificacao.id_aluno=Aluno.id
JOIN UC ON UC.id=Classificacao.id_uc and UC.id_area=1
SELECT Aluno.numero, Aluno.nome, SUM(Classificacao.nota >= 10.0) FROM Aluno
JOIN Classificacao ON Classificacao.id_aluno=Aluno.id
JOIN UC ON UC.id=Classificacao.id_uc and UC.id_area=1
GROUP BY Aluno.id
@vxf
vxf / metro.py
Last active September 27, 2019 01:25
Client code for https://www.metrolisboa.pt/ web api
import requests
import re
import json
import logging
BEARER_RX = re.compile(r"Bearer \w{8}\-\w{4}\-\w{4}\-\w{4}\-\w{12}")
STATIONS_RX = re.compile(
r"{ id: \"(\w\w)\", nome: \"([^\"]*)\", coord: \"(-?\d*\.\d*),(-?\d*\.\d*)\" }")
DESTINATIONS_RX = re.compile(
r"case \"(\d*)\":.*\n.*return \[\"([^\"]*)\",\s*\"([^\"]*)\",\s*\"(\w\w)\"\];")
@vxf
vxf / covid19.py
Last active March 28, 2020 17:43
#!/usr/bin/env python3
import requests
import argparse
import pickle
import os
url = 'https://services.arcgis.com/CCZiGSEQbAxxFVh3/arcgis/rest/services/COVID19Portugal_view/FeatureServer/0/query'
import os, time, stat
"""
Requires xlsxwriter and pillow
"""
import sys
from PIL import Image, ImageOps
import xlsxwriter
from itertools import product
HEIGHT = 100
"""
Requires
pillow
numpy
"""
from PIL import Image
from itertools import product
from math import sin, cos, sqrt, inf
from numpy import dot, subtract, multiply, add
// raytracer for shadertoy https://www.shadertoy.com/view/wtsBz7
// reference:
// https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection
#define MOVING
const float MAXFLOAT = 3.402823e+38;
const float EPSILON = 0.001;
const int MAX_BOUNCE = 4;