Skip to content

Instantly share code, notes, and snippets.

View herberthamaral's full-sized avatar

Herberth Amaral herberthamaral

View GitHub Profile
@herberthamaral
herberthamaral / install-mono-centos.sh
Last active March 15, 2018 11:31
Install mono-complete from xamarin repositories on CentOS 7.1 x64 (probably works for other versions)
echo "[xamarin]" > /etc/yum.repos.d/xamarin.repo
echo "name=Xamarin" >> /etc/yum.repos.d/xamarin.repo
echo "baseurl=http://download.mono-project.com/repo/centos/" >> /etc/yum.repos.d/xamarin.repo
echo "enabled=1" >> /etc/yum.repos.d/xamarin.repo
echo "gpgcheck=1" >> /etc/yum.repos.d/xamarin.repo
echo "gpgkey=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF" >> /etc/yum.repos.d/xamarin.repo
yum update
yum install mono-complete
#!/bin/bash
export CLASSPATH=$CLASSPATH:.:./duke-1.2.jar:./lucene-core-4.0.0.jar:./lucene-analyzers-common-4.0.0.jar
java no.priv.garshol.duke.Duke "$@"
@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 / 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 / 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 / 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())
}
}
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 / 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):
set expandtab
set autoindent
syntax enable
set shiftwidth=4
set tabstop=4
set softtabstop=4
filetype plugin indent on
set hlsearch
set incsearch
def meu_decorator(f):
def novo_f():
print 'iniciando f'
print 'finalizando f'
return novo_f
@meu_decorator
def minhafuncao():
print 'dentro da funcao'