Skip to content

Instantly share code, notes, and snippets.

View AndersonFirmino's full-sized avatar
🐍
📜 🎼 🎮 🐧 🦆

Anderson Araujo AndersonFirmino

🐍
📜 🎼 🎮 🐧 🦆
View GitHub Profile
@AndersonFirmino
AndersonFirmino / howto-manually-add-trust-cert-to-rubygems.md
Created November 14, 2016 18:21
Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller)

SSL upgrades on rubygems.org and RubyInstaller versions

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


Hello,

If you reached this page, means you've hit this SSL error when trying to

#!/usr/bin/python
import sys #for cmd line argv
#take command line args as the input string
input_string = sys.argv
#remove the program name from the argv list
input_string.pop(0)
#convert to google friendly url (with + replacing spaces)
@AndersonFirmino
AndersonFirmino / threading_example.py
Created November 4, 2016 18:42 — forked from sebdah/threading_example.py
Running a background thread in Python
import threading
import time
class ThreadingExample(object):
""" Threading example class
The run() method will be started and it will run in the background
until the application exits.
"""
@AndersonFirmino
AndersonFirmino / linebreak.py
Created November 3, 2016 00:16 — forked from cemk/linebreak.py
Creating linebreaks and paragraphs in Jinja2/Flask à la Django Style
import re
from jinja2 import evalcontextfilter, Markup, escape
@app.template_filter()
@evalcontextfilter
def linebreaks(eval_ctx, value):
"""Converts newlines into <p> and <br />s."""
value = re.sub(r'\r\n|\r|\n', '\n', value) # normalize newlines
paras = re.split('\n{2,}', value)
@AndersonFirmino
AndersonFirmino / email_example.py
Created November 1, 2016 14:58
Exemplo de envio de email com conteudo html usando python
#!/usr/bin/env python3
# retirado da pagina https://docs.python.org/3/library/email-examples.html#email-examples
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# me == my email address
# you == recipient's email address
me = "[email protected]"
@AndersonFirmino
AndersonFirmino / ui.datepicker-pt-BR.js
Created October 30, 2016 23:09 — forked from Senhordim/ui.datepicker-pt-BR.js
Tradução datepicker pt-BR
/* Brazilian initialisation for the jQuery UI date picker plugin. */
/* Written by Leonildo Costa Silva ([email protected]). */
jQuery(function($){
$.datepicker.regional['pt-BR'] = {
closeText: 'Fechar',
prevText: '&#x3c;Anterior',
nextText: 'Pr&oacute;ximo&#x3e;',
currentText: 'Hoje',
monthNames: ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
@AndersonFirmino
AndersonFirmino / database_merge.py
Created October 25, 2016 13:56
Script para merge de files sql
# coding=utf-8
#########################################################
# Script para pegar varios arquivos sql em um diretorio
# e mesclar todos em um unico arquivo.
# by: Anderson Firmino (coderpy) <[email protected]>
# by: Gustavo Rodrigo (hpix) <[email protected]>
#########################################################
import os
@AndersonFirmino
AndersonFirmino / flask_gridfs_server.py
Created October 13, 2016 18:07
A simple GridFS server built with Flask
from flask import Flask, request, redirect, url_for, make_response, abort
from werkzeug import secure_filename
from pymongo import MongoClient
from bson.objectid import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
@AndersonFirmino
AndersonFirmino / MongoEngineGridFS Server
Created October 13, 2016 17:58 — forked from kimenye/MongoEngineGridFS Server
Serve GridFs files from mongo engine with flask
from flask import Flask, request, redirect, url_for, make_response, abort
from mongoengine.fields import get_db
from bson import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
from <your_app> import app
@app.route('/files/<oid>')
def serve_gridfs_file(oid):
try:
@AndersonFirmino
AndersonFirmino / python-logo-ascii.txt
Last active December 16, 2016 18:54
python logo ascii art
..:77I777777777777777777777I. .
..?77777777777777777777777777777$+..
. ~7777777I7777777777777777777777777$~..
.7I7777...7777777777777777777777777$7+.
.?7777.. ..77777777777777777777777$$7.
.77777 777777777777777777777$$$$$I
.77777.. ...7777777777777777777$$$$$$$$
.7777777 .77$777777777777777777$$$$$$$$
.77777777777777777777777777777$$$$$$$$$$
.77777777777777777777777777$$$$$$$$$$$$$