Skip to content

Instantly share code, notes, and snippets.

View hlegius's full-sized avatar

Hélio hlegius

  • 21:30 (UTC -03:00)
View GitHub Profile
@hlegius
hlegius / Dockerfile
Last active February 4, 2020 18:55
Docker base configuration for Scala projects with Docker (tested against Docker Beta for OS X)
FROM hseeberger/scala-sbt
# For a Alpine Linux version, comment above and uncomment below:
# FROM 1science/sbt
RUN mkdir -p /exampleapp
RUN mkdir -p /exampleapp/out
WORKDIR /exampleapp
COPY . /exampleapp
@hlegius
hlegius / .vimrc
Last active January 25, 2018 19:22
Personal Vim's dotfile
" 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>
@hlegius
hlegius / monkeypatch.rb
Created May 25, 2016 02:03
It's so cool - c'mon and join us.
5.days.from.this.time.here.let.me.give.to.you.as.parameter(last.year.the.day.before.last.day.of.february)
@hlegius
hlegius / Rails Datetime Timezone
Last active December 27, 2015 04:29
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?
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 / Authenticator.java
Created October 27, 2013 21:37
Chain of Responsibility - GoF Way
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 / test_helper.rb
Created May 27, 2013 23:45
Solr Sunspot Mocking session
::Sunspot.session = ::Sunspot::Rails::StubSessionProxy.new(::Sunspot.session)
@hlegius
hlegius / paperclip_mocking_test.rb
Last active December 14, 2015 02:49
Mocking Paperclip with Mocha
YourModel.any_instance.stubs(:save_attached_files).returns(true)
@hlegius
hlegius / projeto.txt
Created April 25, 2012 11:52
Season - Projeto final
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 / Criteria.php
Created September 19, 2010 18:13
[PHP] Realiza queries SQL com PDO.
<?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 / mixins_inhe.rb
Created September 17, 2015 17:21
Mixins & Self
module Foo
def save
puts 'in save'
end
end
module Foo
def self.included(resource)
resource.extend ClassMethods
end