Skip to content

Instantly share code, notes, and snippets.

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

Anderson Araujo AndersonFirmino

🐍
📜 🎼 🎮 🐧 🦆
View GitHub Profile
@AndersonFirmino
AndersonFirmino / Config Postgresql to Python
Created May 5, 2016 20:20 — forked from lym/gist:456ec863d3fc3c63cab4
psycopg: Error: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'
# Just install libpq-dev
$ sudo apt-get install libpq-dev
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@AndersonFirmino
AndersonFirmino / filedownloader.js
Created July 11, 2016 19:40 — forked from DavidMah/filedownloader.js
File Download requests using jquery/POST request with psuedo ajax
// Takes a URL, param name, and data string
// Sends to the server.. The server can respond with binary data to download
jQuery.download = function(url, key, data){
// Build a form
var form = $('<form></form>').attr('action', url).attr('method', 'post');
// Add the one key/value
form.append($("<input></input>").attr('type', 'hidden').attr('name', key).attr('value', data));
//send request
form.appendTo('body').submit().remove();
@AndersonFirmino
AndersonFirmino / snake.py
Created August 11, 2016 03:37 — forked from sanchitgangwar/snake.py
Snakes Game using Python
# SNAKES GAME
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
from random import randint
curses.initscr()
win = curses.newwin(20, 60, 0, 0)
@AndersonFirmino
AndersonFirmino / multit.py
Created August 18, 2016 03:42 — forked from d4rkcat/multit.py
multithread linux commands
#!/usr/bin/env python
# Multi-threading template
import argparse, subprocess, signal, Queue
from threading import Thread, Lock
from sys import stdout
from os import getpid, kill
class myThread (Thread):
def __init__(self, threadID, name, q):
@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 / 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 / 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 / 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 / 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.
"""