Skip to content

Instantly share code, notes, and snippets.

View AlexandreProenca's full-sized avatar
:octocat:
Focusing

Alexandre Proença AlexandreProenca

:octocat:
Focusing
View GitHub Profile
@AlexandreProenca
AlexandreProenca / view.py
Created August 23, 2015 15:16
Classe para teste de performance Django + DRF 3
# coding: utf-8
from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework.authentication import TokenAuthentication, SessionAuthentication
from rest_framework.permissions import AllowAny, IsAuthenticated
import models
from rest_framework.decorators import detail_route, list_route, api_view, authentication_classes
import serializers
from django.core.signals import request_finished, request_started
import time
@AlexandreProenca
AlexandreProenca / formater.py
Created August 23, 2015 15:20
Classe para formatar a saída dos resultados de performance do Django + DRF 3
# coding: utf-8
class Formater:
cor = {
'ROXO' : '\033[95m',
'AZUL' : '\033[94m',
'VERDE' : '\033[92m',
'AMARELO' : '\033[93m',
'VERMELHO' : '\033[91m',
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
with open(args.project_name + r'/settings.py', 'wt') as fout:
with open(resource_filename('robot_rest', 'settings.tpl'), 'rt') as fin:
for line in fin:
if '@projeto@' in line:
fout.write(line.replace('@projeto@', args.project_name))
elif '@HOST@' in line:
fout.write(line.replace('@HOST@', args.database_host))
elif '@USER@' in line:
fout.write(line.replace('@USER@', args.database_user))
elif '@PASSWORD@' in line:
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
import logging
import logging.handlers
my_logger = logging.getLogger('LoyfyLogger')
my_logger.setLevel(logging.CRITICAL)
from pymongo import MongoClient
client = MongoClient()
db = client.sbhistory
cursor = db.room.find()
for document in cursor:
document['payload']['details']['users_name'] = [{"username": i, "seen": None, "received": None} for i in document['payload']['details']['users_name']]
db.room2.insert(document)
@AlexandreProenca
AlexandreProenca / bottle-cors.py
Created June 30, 2016 17:27 — forked from richard-flosi/bottle-cors.py
Bottle with Cross-origin resource sharing (CORS)
"""
Example of setting up CORS with Bottle.py.
"""
from bottle import Bottle, request, response, run
app = Bottle()
@app.hook('after_request')
def enable_cors():
"""
@AlexandreProenca
AlexandreProenca / README.md
Created January 31, 2017 13:15 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

[].forEach.call($$("*"),function(a){
var color = (~~(Math.random()*(1<<24))).toString(16)
a.style.outline="1px solid #"+color;
var dom = document.createElement("div");
dom.setAttribute("style", "font-size: 10px; margin:5px; background: #"+color);
dom.innerText = a.localName;
a.appendChild(dom);
})

Checkout a new working branch

 git checkout -b <branchname>

Make Changes

 git add
 git commit -m "description of changes"

Sync with remote