Skip to content

Instantly share code, notes, and snippets.

View felipeblassioli's full-sized avatar
🏠
Working from home

Felipe Blassioli felipeblassioli

🏠
Working from home
  • Brazil, São Paulo
View GitHub Profile
@felipeblassioli
felipeblassioli / seletiva_vtx_sol
Created April 4, 2013 18:08
Soluções da prova de seleção da VTX
Bolei a prova para que fosse feita em média por bons candidatos nos seguintes tempos:
+-----------------------------------------------------------------+
| QUESTÕES | TEMPO (min) | TIPO |
+-----------------------------------------------------------------+
| 1,2 | 30 min | Lógica |
| 3,5 | 60 min | Programação |
| 4,6 | 30 min | Leitura e Simulação de código |
| 7 | ------ | Confiança nas respostas |
+-----------------------------------------------------------------+
O intuito era que as questões 1,2,6 fossem fáceis e fossem feitas rápido (nos primeiros 30-40min).
@felipeblassioli
felipeblassioli / flask_wtforms_custom_widget.py
Last active January 8, 2024 01:40
Creating custom wtforms.widgets in a Flask.app. Custom Form, Custom Field and Custom Widget.
from flask import Flask
from wtforms import Form, Field, TextField
from wtforms.widgets import TextInput, html_params
# http://wtforms.simplecodes.com/docs/0.6/widgets.html#custom-widgets
def render_ul_users(field, ul_class='awesome_class', **kwargs):
kwargs.setdefault('id', field.id)
if hasattr(field, 'users'):
html = [u'<ul %s>' % html_params(id=field.id, class_=ul_class)]
# A sure hope users is iterable:
from flask import Flask
from wtforms import Form, Field, TextField, FieldList, SelectField
from wtforms.widgets import TextInput, html_params, ListWidget
class H4ckedFieldList(FieldList):
widget = ListWidget(prefix_label=False)
class SomeRandomForm(Form):
name = TextField('Name')
{% macro form_field(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="control-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}" class="control-label">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}:
@felipeblassioli
felipeblassioli / gist:910d943f676c5a8be3f2
Created February 13, 2015 16:15
Solicitando receitas com p_ingredients = Tomato
POST http://rms-prep-sa.foodity.com/api/v2/recipes
Request BODY BEGIN
p_ingredients=tomato&fields=recipe_id%2Ctitle%2Cshort_title%2Cingredients%2Cmethods%2Cserves%2Ccook_time%2Cdifficulties%2Cassets&api_key=9HSRMDKDKXSSSLD4IOJJQHJMADRBWB&lang=en-GB&page_size=20
Request BODY END
Response:
{
"page_start": 0,
"data": [
{
@felipeblassioli
felipeblassioli / gist:0acad63409682aae98d9
Created February 13, 2015 16:16
Solicitando receitas com p_ingredients=Tomato,Onion
POST http://rms-prep-sa.foodity.com/api/v2/recipes
Request BODY BEGIN
p_ingredients=tomato%2Conion&fields=recipe_id%2Ctitle%2Cshort_title%2Cingredients%2Cmethods%2Cserves%2Ccook_time%2Cdifficulties%2Cassets&api_key=9HSRMDKDKXSSSLD4IOJJQHJMADRBWB&lang=en-GB&page_size=20
Request BODY END
Response:
{
"page_start": 0,
"data": [
{
@felipeblassioli
felipeblassioli / gist:d7abf0373859eb9895fd
Created February 13, 2015 16:39
Related_recipes funcionando
POST http://rms-prep-sa.foodity.com/api/v2/recipes
Request BODY BEGIN
p_ingredients=tomato&fields=recipe_id%2Ctitle%2Cshort_title%2Cingredients%2Cmethods%2Cserves%2Ccook_time%2Cdifficulties%2Cassets%2Crelated_recipes&api_key=9HSRMDKDKXSSSLD4IOJJQHJMADRBWB&lang=en-GB&page_size=20
Request BODY END
Response:
{
"page_start": 0,
"data": [
{
@felipeblassioli
felipeblassioli / show_features_keypoints.py
Last active December 19, 2016 05:05
OpenCV 2.4.10 - Show keypoints of all available feature detectors. Some filters applied: Grayscale, Thresholding and canny.
# -*- coding: utf-8 -*-
import cv2
import numpy as np
feature_detectors = [
"FAST",
"STAR",
"SIFT",
"SURF",
"ORB",
var usersStream = Bacon.interval(3000)
.filter(function(){ return this.state.mode === "users" }.bind(this))
.flatMapLatest(function(){
var store = this.state.selectedStore;
return Bacon.fromPromise( $.ajax({
type: 'GET',
url: '/users/',
data: {store_id: store.id}
}) );
}.bind(this))
@felipeblassioli
felipeblassioli / python_performance_loops_vs_itertools.py
Last active July 15, 2016 15:20
Python 2.7 itertools.product vs nested for loops vs nested for comprehension
import timeit
def test_performance(code, setup='pass', TIMES=10):
avg = lambda l: sum(l)/len(l)
result = timeit.Timer(code, setup).repeat(3,10)
print avg(result)
NESTED_FOR = """
for x in xrange(1000):
for y in xrange(1000):