Skip to content

Instantly share code, notes, and snippets.

Hélio Costa e Silva hlegius

Block or report user

Report or block hlegius

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hlegius
hlegius / dial.pl
Created Aug 31, 2010
[Perl] Leitura de linhas para o Asterisk
View dial.pl
#!/usr/bin/perl
#Script para o usuário escolher por quais portas ZAP as ligações irão sair.
#Com esse script, o usuário não tem a necessidade de editar o zapata.conf, nem dar reload no módulo zap nem no Asterisk.
print "Digite os ramais separando-os por virgulas:\n";
$line = <>;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
@args = split(',', $line);
View mixins_inhe.rb
module Foo
def save
puts 'in save'
end
end
module Foo
def self.included(resource)
resource.extend ClassMethods
end
@hlegius
hlegius / Criteria.php
Created Sep 19, 2010
[PHP] Realiza queries SQL com PDO.
View Criteria.php
<?php
/**
* Criteria para a QueryObject
*
* @author Hélio Costa e Silva <helio@shokstudio.com.br>
*
* @created Novembro, 25 2008
* @revised Dezembro, 26 2008
* @version desenvolvimento / development
*
@hlegius
hlegius / projeto.txt
Created Apr 25, 2012
Season - Projeto final
View projeto.txt
Projeto final: Gerenciador financeiro.
O sistema web deverá contemplar as seguintes ideias:
- Cadastro de despesa
- Listagem de gastos/recebimentos com filtro por data.
- Cadastro de categorías de despesas
Bonus points (opcional):
- Cadastro de "budget" para uma categoria.
@hlegius
hlegius / paperclip_mocking_test.rb
Last active Dec 14, 2015
Mocking Paperclip with Mocha
View paperclip_mocking_test.rb
YourModel.any_instance.stubs(:save_attached_files).returns(true)
@hlegius
hlegius / test_helper.rb
Created May 27, 2013
Solr Sunspot Mocking session
View test_helper.rb
::Sunspot.session = ::Sunspot::Rails::StubSessionProxy.new(::Sunspot.session)
@hlegius
hlegius / Authenticator.java
Created Oct 27, 2013
Chain of Responsibility - GoF Way
View Authenticator.java
abstract class Authenticator {
private Authenticator next;
public static Authenticator chain() {
Authenticator defaultMethod = new EmailAuthenticator();
Authenticator networkMethod = new NetworkAuthenticator();
defaultMethod.setNext(networkMethod);
Authenticator partnerMethod = new PartnerAuthenticator();
networkMethod.setNext(partnerMethod);
@hlegius
hlegius / Rails Datetime Timezone
Last active Dec 27, 2015
This is the price to pay when you "love" Black Magic frameworks. As you can see, Rails' ActiveRecord will override timezone for all time/datetime attributes up to your "rails configuration". There is nothing to do about it. This is the Rails way. Nice, huh?
View Rails Datetime Timezone
2.0.0p247 :001 > e = Event.new(start_date_time: DateTime.now, date_offset: 'GMT-4')
=> #<Event id: nil, start_date_time: "2013-11-01 13:03:31", date_offset: "GMT-4", created_at: nil, updated_at: nil>
2.0.0p247 :002 > e.start_date_time
=> Fri, 01 Nov 2013 11:03:31 BRST -02:00
2.0.0p247 :003 > d = DateTime.now
=> Fri, 01 Nov 2013 13:04:02 -0200
2.0.0p247 :004 > DateTime.new(d.year, d.month, d.day, d.hour, d.minute, d.second, e.date_offset)
=> Fri, 01 Nov 2013 13:04:02 -0400
@hlegius
hlegius / monkeypatch.rb
Created May 25, 2016
It's so cool - c'mon and join us.
View monkeypatch.rb
5.days.from.this.time.here.let.me.give.to.you.as.parameter(last.year.the.day.before.last.day.of.february)
@hlegius
hlegius / .vimrc
Last active Jan 25, 2018
Personal Vim's dotfile
View .vimrc
" Original "Vi behaviour" disabled (I am not that tr00 user [yet])
set nocompatible " better safe than sorry
" Fair Vim
noremap <Left> <NOP>
noremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
inoremap <Left> <NOP>
You can’t perform that action at this time.