Skip to content

Instantly share code, notes, and snippets.

@kneipp
kneipp / gem install mysql2
Created May 23, 2011 19:36
Instalação gem mysql2 no OS X 10.6.7
Passos que segui para conseguir instalar a gem mysql2,
pois o comando de forma tradicional gem install mysql2 não estava funcionando.
1) locate mysql_config
Não listava nada, porém tenho mysql rodando aqui com PHP.
2) brew install mysql
3) locate mysql_config
/Applications/MAMP/Library/bin/mysql_config
@kneipp
kneipp / gist:1268581
Created October 6, 2011 20:34
Form rails3.1 view
<div>
<%= f.label t('.name') %>:
<%= f.text_field :name, size: 40 %>
</div>
<div>
<%= f.label :password, 'Password' %>:
<%= f.password_field :password, size: 40 %>
</div>
@kneipp
kneipp / gist:1356785
Created November 11, 2011 00:55
passenger-install-nginx-module
...
-lpthread -lcrypt -lm /var/lib/gems/1.8/gems/passenger-3.0.9/ext/nginx/../common/libpassenger_common.a /var/lib/gems/1.8/gems/passenger-3.0.9/ext/nginx/../common/libboost_oxt.a -lstdc++ -lpthread -lpcre -lssl -lcrypto -ldl -lz
/usr/bin/ld: /var/lib/gems/1.8/gems/passenger-3.0.9/ext/nginx/../common/libpassenger_common.a(aggregate.o): undefined reference to symbol 'pow@@GLIBC_2.0'
/usr/bin/ld: note: 'pow@@GLIBC_2.0' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[1]: *** [objs/nginx] Error 1
make[1]: Leaving directory `/tmp/root-passenger-26428/nginx-1.0.6'
make: *** [build] Error 2
@kneipp
kneipp / gist:1901788
Created February 24, 2012 16:06
Django: Utilização de Local Flavor no Admin
from django.contrib import admin
from django.contrib.localflavor.br.forms import BRZipCodeField
from django.forms import ModelForm
from app.customers.models import Customer, Contact
class ContactInline(admin.TabularInline):
model = Contact
extra = 2
class CepForm(ModelForm):
@kneipp
kneipp / gist:1904980
Created February 25, 2012 00:53
Bug ao usar south por uso errado (alterando mysql manualmente)
~/workspace/django/financeiro$ ./manage.py migrate
Running migrations for customers:
- Migrating forwards to 0001_initial.
> customers:0001_initial
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
@kneipp
kneipp / gist:1937748
Created February 29, 2012 04:30
Exemplo de Formatação de data no ModelAdmin
# def expiration_date(self):
# return self.expiration_date.strftime("%d/%m/%Y")
# expiration_date.short_description = 'data de vencimento'
#
# def payment_date(self):
# return self.payment_date.strftime("%d/%m/%Y")
# payment_date.short_description = 'data do pagamento'
ou
ADOBE
127.0.0.1 hl2rcv.adobe.com
127.0.0.1 t3dns.adobe.com
127.0.0.1 3dns-1.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-4.adobe.com
127.0.0.1 activate.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 activate-sjc0.adobe.com
@kneipp
kneipp / gist:3171835
Created July 24, 2012 18:53
Rails - Comandos úteis
rake db:xxx RAILS_ENV=production
RAILS_ENV=production bundle exec rake assets:precompile
@kneipp
kneipp / gist:3190526
Created July 27, 2012 21:23
Exemplo código pagseguro frete
<form method="post" action="https://pagseguro.uol.com.br/v2/checkout/cart.html?action=add" target="pagseguro">
<input type="hidden" value="[email protected]" name="receiverEmail">
<input type="hidden" value="BRL" name="currency">
<input type="hidden" value="1" name="itemQuantity">
<input type="hidden" value="123" name="itemId"> <!-- ID -->
<input type="hidden" value="Produto XPTO" name="itemDescription"> <!-- NOME -->
<input type="hidden" value="400.00" name="itemAmount"> <!-- PRECO Ex: 29.99 -->
@kneipp
kneipp / gist:3237925
Created August 2, 2012 15:29
[rails] Pegando elementos aleatórios da Active Record
offset = rand(Banner.published.count)
@banner = Banner.published.first(:offset => offset)