Skip to content

Instantly share code, notes, and snippets.

View igr-santos's full-sized avatar

Igor dos Santos igr-santos

  • Belo Horizonte - MG
View GitHub Profile
@igr-santos
igr-santos / virtualenvwrapper.md
Last active August 29, 2015 13:58
Organizing the development environment with Virtualenvwrapper
  1. Com o pip instalado, digite o seguinte comando no terminal:

pip install virtualenvwrapper

  1. Agora é necessário uma pasta onde ficaram armazenados seus ambientes e os seus projetos:

mkdir ~/.Envs [Criando uma pasta oculta Envs na pasta pessoal do usuário]

mkdir ~/Projects [Criando uma pasta comum Projects na pasta pessoal do usuário]

@igr-santos
igr-santos / Preferences.sublime-settings
Created June 10, 2014 20:47
Configuration SublimeText 3 (Perv Orange)
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/Perv Orange Moonlight (SL).tmTheme",
"draw_minimap_border": true,
"enable_telemetry": false,
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
function ReportChart(url) {
this.url = url;
}
ReportChart.prototype.getChart = function() {
$.get(
this.url,
function(result) {
chart = result['chart'];
data = result['data'];
@igr-santos
igr-santos / example_pymongo.py
Created June 26, 2014 18:56
Sample handling MongoDB with Python
from pymongo import MongoClient
# Connect client MongoDB and database
client = MongoClient()
database = client['database_name']
# or
database = MongoClient().database_name
@igr-santos
igr-santos / mongo_manager.py
Last active August 29, 2015 14:03
Object used to support the construction and manipulation of a MongoDB aggregation
#!/usr/bin/env python
from pymongo import MongoClient
from datetime import datetime
class Cache(object):
def __init__(self, cached):
self.date = datetime.today()
self.cached = cached
@igr-santos
igr-santos / mongo_manager_example.py
Created July 3, 2014 19:46
Example execute MongoManager
if __name__ == '__main__':
from mongo_queryset import MongoManager, InQuery, DateQuery
manager = MongoManager('cybergia', 'reportlab_userdocument')
date_gt = datetime(2014, 01, 01)
date_lte = datetime.today()
manager.project(
user_pk=1, predicates__predicate=1, predicates__obj=1,
predicates__date=1
).unwind(
@igr-santos
igr-santos / console.py
Created July 7, 2014 17:06
Comportamento interessante de se observar
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
... x = 9
... def __init__(self, x):
... self.x = x
... def bar(self, y):
... return self.x + y
...
@igr-santos
igr-santos / configurando-servidor-gunicorn.md
Last active August 29, 2015 14:04
configurando servidor com Django + Gunicorn

Title: Configurando um servidor de produção para aplicações Python Slug: configurando-um-servidor-de-producao-para-aplicacoes-python Date: 2014-07-24 14:42 Tags: django,web,tutorial,wsgi,gunicorn,nginx,supervisor,servidor,producao Author: Igor Santos Email: [email protected] Github: igr-santos Bitbucket: igrsantos Site: http://pythonclub.com.br Gittip: igr-santos

@igr-santos
igr-santos / teste.py
Created August 22, 2014 16:55
example use Django Rest Framework
# serializers.py
class ObjectiveSerializer(serializers.ModelSerializer):
class Meta:
model = Objective
fields = (
'name', 'short_description', 'points_awarded',
'number_of_steps', 'energy_cost'
)
@igr-santos
igr-santos / Preferences.sublime-settings
Last active August 29, 2015 14:13
Configure Sublime Text 3
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/SublimeLinter/Perv Orange Moonlight (SL).tmTheme",
"draw_minimap_border": true,
"enable_telemetry": false,
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",