If you have a site where users can send content, and they often send emails on it, it’s good to protect them from spam bots.
Here follows a simple helper method that uses a javascript technique to do that.
def hide_emails_from_bots(text) match = text.match(/\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6}/).to_s if match.blank? text else size = match.size splitter = size / 3 string1 = match[0...splitter] string2 = match[splitter...2*splitter] string3 = match[2*splitter..size] js = " <script type="\"text/javascript\""><!--mce:0--></script> " text.gsub(/#{match}/, js) end end
While I’m working, I always have a minimum of 3 or 4 open terminals: one for watching the logs, one for ssh and so on.
It’s not good to have a lot of windows open, and tab switching can be a pain, specially when you want to see what’s going on in one window while you type in another one.
So I’ve found recently Terminator.
Taken from terminator’s home page:
The goal of this project is to produce a useful tool for arranging terminals.
It is inspired by programs such as gnome-multi-term, quadkonsole, etc. in that the main focus is arranging terminals in grids (tabs is the most common default method, which Terminator also supports).Much of the behaviour of Terminator is based on GNOME Terminal, and we are adding more features from that as time goes by, but we also want to extend out in different directions with useful features for sysadmins and other users. If you have any suggestions, please file wishlist bugs! (see below for the address)
Features:
* Arrange terminals in a grid
* Tabs
* Drag and drop re-ordering of terminals
* Lots of keyboard shortcuts
* Config file to override gnome-terminal settings
* Simultaneous typing to arbitrary groups of terminals
You can put your default configurations in the file ~/.config/terminator/config
Mine configurations are this:
#/home/mauricio/.config/terminator/config enable_real_transparency=True force_no_bell=True scrollbar_position=disabled titlebars=False handle_size=1
This increased a lot my productivity. Unfortunately I haven’t found anything like Terminator for Mac.
Estava procurando uma forma de escrever no twitter de forma rápida e sem precisar abrir nenhum cliente, nem mesmo o site. Foi quando uma pergunta rápida ao guru me trouxe esse artigo.
Fiz algumas modificações (não conseguia postar mensagems com !) e acabei com esse script:
#!/usr/bin/ruby `curl --basic --user "<myusername>:<mysecretpassword>" --data-ascii "status=#{ARGV.join(" ")}" "http://twitter.com/statuses/update.json"`
Substitua
$ twit Estou postando a partir da linha de comando!
Se essa dica foi útil à você, poste nos comentários.
Fiquei um longo período sem postar nada. A coisa está corrida por aqui. Estou fazendo o deployment da minha aplicação, refatorando pedaços de código, corrigindo bugs, enfim, aparando as últimas arestas antes de colocar no ar.
Assim sendo, vamos com uma dica rápida para facilitar o acesso aos recursos de internacionalização inseridos no Rails 2.2.
Até o Rails 2.1 eu usava o Brazilian Rails para a formatação de datas, moeda, etc. Resolvi que era hora de tentar o I18n do Rails 2.2.
Primeiro passo: criar o locale ‘pt-BR.yml’ dentro de config/locales/:
time:
formats:
default: "%A, %d de %B de %Y, %H:%M"
short: "%d/%m, %H:%M"
long: "%A, %d de %B de %Y, %H:%M"
hour: "%H:%M"
am: ''
pm: ''no config/environment.rb:
I18n.default_locale = "pt-BR"
e vualá:
>> I18n.localize(Time.now) => "Segunda, 08 de Dezembro de 2008, 17:00" >> I18n.localize(Time.now, :format => :short) => "08/12, 17:00"
Muito bem. Tudo funcionando. Mas é muito chato ter que chamar a classe I18n todo o tempo. Então vamos usar o poder de DSLs que Ruby nos dá.
Crie um arquivo em config/initalizers com o nome que preferir e adicione:
class Time def localize(options={}) I18n.localize(self, options) end end
Agora ficou muito mais fácil e intuitivo:
>> Time.now.localize => "Segunda, 08 de Dezembro de 2008, 17:04" >> Time.now.localize :format => :short => "08/12, 17:04"
Isso pode ser feito similarmente com outros métodos, de outras classes também. Fica para o próximo post.