Skip to content

Instantly share code, notes, and snippets.

View danilomo's full-sized avatar

Danilo Oliveira danilomo

View GitHub Profile

Code of Conduct

Communication

Times
  • All times will be communicated in a way that is unambiguous. This communication may be a local time, with a UTC offset specified.

For example:

@Allan-Gong
Allan-Gong / tricks.scala
Created May 3, 2016 14:21
Tricks in scala language
// when passing parameters to method calls. You may replace parenthesis with curly braces if, and only if,
// the method expects a single parameter. For example:
List(1, 2, 3).reduceLeft{_ + _} // valid, single Function2[Int,Int] parameter
List{1, 2, 3}.reduceLeft(_ + _) // invalid, A* vararg parameter
// Why multiple parameters lists scala ?
// First: you can have multiple var args:
@jeffjohnson9046
jeffjohnson9046 / UuidHelper.java
Last active December 11, 2023 11:06
Convert UUID to byte array and vice versa. Useful for when UUIDs are stored in MySQL tables as VARBINARY(16)
import java.nio.ByteBuffer;
import java.util.UUID;
public class UuidAdapter {
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
@julienroubieu
julienroubieu / JavaOptionals.scala
Last active November 14, 2019 20:46
Implicit conversions between Scala Option and Java 8 Optional
import java.util.Optional
/**
* Conversions between Scala Option and Java 8 Optional.
*/
object JavaOptionals {
implicit def toRichOption[T](opt: Option[T]): RichOption[T] = new RichOption[T](opt)
implicit def toRichOptional[T](optional: Optional[T]): RichOptional[T] = new RichOptional[T](optional)
}
@owainlewis
owainlewis / pg.lisp
Created January 3, 2013 12:18
Source code for Paul Grahams Common Lisp Book
; The code in this file was mechanically extracted from the TeX
; source files of _Ansi Common Lisp_, except for bst-remove and
; bst-delete and their subroutines, which replace broken versions
; in the book.
; If you have questions or comments about this code, or you want
; something I didn't include, send mail to lispcode@paulgraham.com.
; This code is copyright 1995 by Paul Graham, but anyone who wants
; to use it is free to do so.
@quelgar
quelgar / filesizerer.scala
Created July 15, 2012 01:45
Simple Scala example of a pure functional program that does I/O
/*
* Referentially transparent program to print the size of files.
*
* Techniques inspired by:
* "Dead-Simple Dependency Injection"
* Rúnar Óli Bjarnason
* Northeast Scala Symposium, 2012
*
* To run: "scala filesizerer.scala"
* When prompted, enter a file name.