Skip to content

Instantly share code, notes, and snippets.

View ryanpadilha's full-sized avatar
:octocat:

Ryan Padilha ryanpadilha

:octocat:
View GitHub Profile
@lucasdavila
lucasdavila / conf_pg_bouncer_ubuntu.txt
Created August 11, 2011 01:51
PostgreSQL connection pooling com pgbouncer
Um método para otimizar as conexões com o banco de dados é estabelecer um pool de conexão, caso sua aplicação
não faça isto nativamente você pode usar alguma ferramenta como o pgbouncer [1].
O principal motivo para manter um pool de conexões ativas com o banco de dados, é que o processo
de criar uma conexão com o banco de dados e posteriormente elimina-la gasta recursos e leva algum tempo,
o que pode ser pouco para uma conexão, mas para apps onde a conexão / desconexão ocorre com muita
frequência (como em aplicações web) manter um pool de conexões ativas, pode economizar algum tempo
entre cada solicitação.
Um pool de conexões trabalha de maneira muito simples, após a aplicação criar e usar a conexão com o
@jelies
jelies / AutowiringSpringBeanJobFactory.java
Last active June 14, 2024 06:00
Quartz (2.1.6) java config with spring (3.2.1). Using a SpringBeanJobFactory to automatically autowire quartz classes.
package com.jelies.spring3tomcat7.config.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
/**
* This JobFactory autowires automatically the created quartz bean with spring @Autowired dependencies.
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, french_stem;
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english );
ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, english_stem;
CREATE TEXT SEARCH CONFIGURATION de ( COPY = german );
ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING
@shreyansb
shreyansb / flask_profiler.py
Last active January 11, 2024 12:08
A profiler for Flask apps
"""
This module provides a simple WSGI profiler middleware for finding
bottlenecks in web application. It uses the profile or cProfile
module to do the profiling and writes the stats to the stream provided
To use, run `flask_profiler.py` instead of `app.py`
see: http://werkzeug.pocoo.org/docs/0.9/contrib/profiler/
and: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling
"""
@victor-rds
victor-rds / brdocs.cpfcnpjValidator.js
Last active March 6, 2024 21:31
Extensão para JQuery Validation Plugin (jqueryvalidation.org) que valida o número de CPF ou CNPJ (inclusive os dois ao mesmo tempo num único campo), usa "namespace" brdocs para evitar conflitos, a função calculaDigito() pode ser usada sozinha caso você deseje mudar a lógica do validador ou criar seu método de validação em outro framework ou plugin.
brdocs = {
/**
* Enum com opções do validador
* @readonly
* @enum {number}
*/
cpfcnpj: { "CPF": 1, "CNPJ": 2, "AMBOS": 3 },
/**
* Função que valida CPF e CNPJ de uma só vez.
@bluekvirus
bluekvirus / flask-uWSGI-nginx.md
Last active July 19, 2022 20:26
How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04+

How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04

@credit Yan Zhu (https://github.com/nina-zhu)

Introduction

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions, it can help you get your Python application or website off the ground. Flask includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server is required.

In this guide, we will demonstrate how to install and configure some components on Ubuntu 14.04 to support and serve Flask applications. We will configure the uWSGI application container server to interface with our applications. We will then set up Nginx to reverse proxy to uWSGI, giving us access to its security and performance features to serve our apps.

Prerequisites and Goals

@sameerkumar18
sameerkumar18 / example_flask_googlecaptcha.py
Created May 20, 2017 07:04
A Simple Python Flask Example for Google Recaptcha (implemented on http://ipusearch.herokuapp.com)
RECAPTCHA_PUBLIC_KEY = '<public key>'
RECAPTCHA_PRIVATE_KEY = '<private key>'
def checkRecaptcha(response, secretkey):
url = 'https://www.google.com/recaptcha/api/siteverify?'
url = url + 'secret=' + str(secretkey)
url = url + '&response=' +str(response)
@thomasdarimont
thomasdarimont / app.py
Last active July 2, 2024 20:19
Simple python example using flask, flask_oidc and keycloak
import json
import logging
from flask import Flask, g
from flask_oidc import OpenIDConnect
import requests
logging.basicConfig(level=logging.DEBUG)
app = Flask(__name__)