Skip to content

Instantly share code, notes, and snippets.

View fabio-filho's full-sized avatar

Fábio Filho fabio-filho

View GitHub Profile
@fabio-filho
fabio-filho / CardViewCollapsible.kt
Created April 13, 2018 18:03
Card View Easy Collapsible - With Kotlin =D
// Usage - MainActivity
val collapsible = myCardView.buildCollapsible()
myButton.onClick {
collapsible.toggle()
}
// ============================================================================================================================
package your_package
import android.animation.ValueAnimator
import android.support.v7.widget.CardView
@fabio-filho
fabio-filho / Sample.cs
Created June 14, 2018 13:25
Controller using a repository factory result.
public class BaseController : Controller
{
protected IActionResult GetActionResult(RepositoryResult repositoryResult)
{
// TODO
return default;
}
}
@fabio-filho
fabio-filho / Sample.kt
Last active August 15, 2018 23:18
Contract and implementation
// Contract
interface INormalize{
fun order()
fun normalize()
fun getScore()
}
@fabio-filho
fabio-filho / SOLID.java
Last active August 20, 2018 20:15
SOLID Principles - SRP, OCP, ISP, DIP
// Contracts
interface IBookRepository{
@Nullable
String getBook(Long id);
List<Object> getBooksByDescription(String description);
List<Object> getBooksByDescriptionOrder(String description);
@fabio-filho
fabio-filho / s1.py
Last active August 27, 2018 18:45
SOLID - Single responsability
def main(a, b, operation):
result = None
if operation == "sum":
result = a + b
elif operation == "sub":
result = a - b
elif operation == "mult":
result = a * b
@fabio-filho
fabio-filho / o.py
Last active August 27, 2018 18:45
SOLID - Open/Closed
class Calculator:
def __init__(self, a, b):
self._a = a
self._b = b
pass
def calculate(self, operation):
if operation == "sum":
@fabio-filho
fabio-filho / l.py
Created August 27, 2018 18:52
SOLID - Liskov
class Calculator:
@abstractmethod
def calculate(self, a, b):
raise NotImplemented()
class SumCalculator(Calculator):
def calculate(self, a, b):
return a + b
@fabio-filho
fabio-filho / utils.kt
Last active May 23, 2020 01:26
An easy way to mock a class using Kotlin and Mockito - dependency free \o/
import org.mockito.Mockito.mock
inline fun <reified TClass> easyMock(): TClass = mock(TClass::class.java)
// ---------- Usage
// Before
@fabio-filho
fabio-filho / globals.js
Created February 25, 2021 13:59
JavaScript - Overriding console functions to ignore propTypes errors and warnings
const originalConsoleWarn = console.warn;
global.console.warn = (...args) => {
const propTypeFailures = [/Warning: componentWillMount/];
if (propTypeFailures.some(p => p.test(args[0]))) {
return;
}
originalConsoleWarn.call(console, ...args);
};
// eslint-disable-next-line no-console
@fabio-filho
fabio-filho / move-docker-installation-to-external-storage.md
Last active April 22, 2021 14:14
Move Docker installation to an external Storage / Partition

Move Docker installation to an external Storage / Partition

  1. Stop the docker daemon:

    sudo service docker stop

  2. Add a configuration file to tell the docker daemon what is the location of the data directory:

    sudo vim /etc/docker/daemon.json