Skip to content

Instantly share code, notes, and snippets.

View vitorprado's full-sized avatar

Vitor Prado vitorprado

View GitHub Profile
class ContextValidation(private val validator: FormValidator) : DefaultValidation(validator) {
fun whenBrazil(conditions: BrazilValidations.() -> Unit) {
if (isBrazilApp()) BrazilValidations(validator).conditions()
}
fun whenColombia(conditions: ColombiaValidations.() -> Unit) {
if (isColombiaApp()) ColombiaValidations(validator).conditions()
}
@itod
itod / split_keyboards.md
Last active May 23, 2024 01:51
Every "split" mechanical keyboard currently being sold that I know of
@haskellcamargo
haskellcamargo / Function.java
Last active May 5, 2020 12:16
Java maybe monad
package br.com.ngi.ginga.business.util.seq;
/**
* Copyright (C) 2015 - NG Informática
*
* @author Marcelo Camargo
* @since 08/12/2015
*/
public interface Function<Ret, Arg> {
Ret call(Arg arg);
#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
SEARCH_URL = 'http://www.ofertaesperta.com/?ContentViewMode=Search&Search=ps4'
doc = Nokogiri::HTML(open(SEARCH_URL))
rows = doc.css('.oferta-title h4').select { |h4| h4.text =~ /Console/ }
@andrewhr
andrewhr / Adapt.java
Last active August 29, 2015 14:07
Some kind of API to be more descriptive while instantiating adapters and binding them to `ListView`s. In reality, will be just a bunch of Builder classes... just sugar. Maybe I've just become spoiled by keyword arguments from other languages (like you see a lot in Ruby)
/*
* Let take the simplest example possible... our beloved `ArrayAdapter`.
*/
adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, arrayOrList);
listView.setAdapter(adapter);
// becomes
Adapt.with(context, android.R.layout.simple_list_item_1)
.load(arrayOrList)
.into(listView); // or `.build()` when we need to store the adapter for later use
@andrewhr
andrewhr / ReallyAwesomeActivity.java
Created August 15, 2013 01:30
List view com uma view especial de header que contém um `ViewPager`. Esse código permite a navegação normal da `ListView` caso algum dos itens seja tocado. Para o caso de tocar diretamente no `ViewPager`, ele assume os eventos. Para tanto, além do código normalmente esperado para cabeçalhos de uma `ListView`, precisamos adicionar um listener de …
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View header = getLayoutInflater().inflate(R.layout.sections, null);
assert header != null;