Skip to content

Instantly share code, notes, and snippets.

View herberthamaral's full-sized avatar

Herberth Amaral herberthamaral

View GitHub Profile
set expandtab
set autoindent
syntax enable
set shiftwidth=4
set tabstop=4
set softtabstop=4
filetype plugin indent on
set hlsearch
set incsearch
@herberthamaral
herberthamaral / tests.py
Created November 13, 2011 23:54
Exemplo de uso de decorators na vida real utilizando views no django
import fudge
from django.test import TestCase
from django.contrib.auth.models import User
from django.http import Http404
import views
def stub(name = 'stub'):
return fudge.Fake(name).is_a_stub()
class AuthTest(TestCase):
from django.http import HttpResponse
from models import Post
def posts(request):
posts = Post.objects.all()
texto = "<h1>Lista de posts:</h1>"
texto += "<ul>"
for post in posts:
item = "<li><a href='/blog/post/"+str(post.id)+"'>"+post.title+"</a></li>"
texto += item
@herberthamaral
herberthamaral / gist:1607387
Created January 13, 2012 16:37
storage_flood
// função pra floodar o localStorage, com o intuito de saber se o browser simplesmesnte lança uma
// exception quando o storage está cheio ou se o browser pergunta se o user deseja expandir o
// espaço disponível para o localStorage
function flood(){
for(i=0;i<5*1024*1024;i++) {
window.localStorage.setItem(Math.random().toString(), Math.random().toString())
}
}
@herberthamaral
herberthamaral / wtf.js
Created February 24, 2012 13:04
wtf.js
console.log(999999999999999)
//999999999999999
console.log(9999999999999999)
//10000000000000000 ==> WTF??
console.log(9999999999999999+1)
//10000000000000000
console.log(9999999999999999+2)
@herberthamaral
herberthamaral / manage.py
Created January 14, 2014 15:20
Add --settings option to manage.py
#excerpt from manage.py
settings_arg = [arg for arg in sys.argv if arg.startswith('--settings=')]
if settings_arg:
settings = __import__(settings_arg[0].split('=')[1])
else:
import settings
@herberthamaral
herberthamaral / id_rsa.pub
Created May 26, 2016 10:51
ssh public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpbrzA0XGgUmtTTAmEXxMjAj7B+lkW4e2KkPGcmP2u4bYehH/1axdTaAf6HYKcMDv65aJIN8Qz/zp0b6zNb5mwptPNa3f9LrEZ2zT0agPZCgRX71AUunp9WhNazz48uPyWCYRw9BIQzNHyJFMIlnjwCwpwZu/qBMZWHu9EBQ3UOHqfdUzf2mw0/8UASFnGduLGbY7kSDMxX3NBDN6zLsYBKBVJyz+bszdWi3QXLNcDLVqqh0sOi16FTHZJzsjFnf+K6JNRQGeMMsisyZX1E2TSFBm+slJYzW2zdqGuOjnDsGQyZ9Uv+m0oJ+t29cMiTwOKcURI64U3LSSTm0oCLHaj
@herberthamaral
herberthamaral / class-tests.js
Created April 24, 2012 21:09
Simple, but effective JavaScript class system
describe("class system", function(){
it("should be possible to create classes", function(){
Class({name:'MyClass'});
expect(window.MyClass === undefined).toBeFalsy();
});
it("should be possible to create properties within classes", function(){
Class({
name:'MyClass',
attrs:{
@herberthamaral
herberthamaral / apresentacao-org-mode-e-gtd.org
Created February 23, 2018 16:49
Prosa sobre org-mode e GTD

Revisão do GTD

Processo para organização pessoal

É basicamente um gerenciamento de listas que você confia

Listas “padrão”: Inbox, Próximas ações, Projetos, Talvez um dia, Delegado

Você pode ter mais de um inbox (caderno, keep, etc)

Você pode ter mais listas… essas aí são as default

Agnóstico em relação a ferramentas

org-mode, caderno, BulletJournal, google – tá valendo :-)

@herberthamaral
herberthamaral / init.el
Last active February 23, 2018 17:10
Meu arquivo de config do emacs
;; -*- coding: utf-8 -*-
;; custom
;; Atenção: não esquecer de setar a variável HOME do windows para a
;; pasta home do usuário. Caso contrário o "~" não será reconhecido.
(setq frame-title-format "emacs do amaral")
(tool-bar-mode -1)
(scroll-bar-mode -1)
(set-default 'cursor-type 'hbar)