Skip to content

Instantly share code, notes, and snippets.

Avatar

Herberth Amaral herberthamaral

View GitHub Profile
@herberthamaral
herberthamaral / install-mono-centos.sh
Last active Mar 15, 2018
Install mono-complete from xamarin repositories on CentOS 7.1 x64 (probably works for other versions)
View install-mono-centos.sh
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
View duke.sh
#!/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 Jan 14, 2014
Add --settings option to manage.py
View 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 Apr 24, 2012
Simple, but effective JavaScript class system
View class-tests.js
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:{
View wtf.js
console.log(999999999999999)
//999999999999999
console.log(9999999999999999)
//10000000000000000 ==> WTF??
console.log(9999999999999999+1)
//10000000000000000
console.log(9999999999999999+2)
View gist:1607387
// 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())
}
}
View gist:1386854
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 Nov 13, 2011
Exemplo de uso de decorators na vida real utilizando views no django
View tests.py
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):
View gist:1360589
set expandtab
set autoindent
syntax enable
set shiftwidth=4
set tabstop=4
set softtabstop=4
filetype plugin indent on
set hlsearch
set incsearch
View gist:1355886
def meu_decorator(f):
def novo_f():
print 'iniciando f'
print 'finalizando f'
return novo_f
@meu_decorator
def minhafuncao():
print 'dentro da funcao'
You can’t perform that action at this time.