Skip to content

Instantly share code, notes, and snippets.

View Wadjetz's full-sized avatar

Egor Berezovskiy Wadjetz

View GitHub Profile
{
"rules": {
"indent": [2, 2],
"quotes": [2, "double"],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"no-console": [0],
"react/prop-types": [0]
},
"env": {
@Wadjetz
Wadjetz / sbtenvconf.sh
Created September 1, 2015 14:21
SBT_OPTS ENV Conf
export SBT_OPTS="-Xms2048m -Xmx3072m -Xss2M"
@Wadjetz
Wadjetz / app.conf
Created August 13, 2015 12:33
Play Slick logger config for show sql queries
logger.scala.slick.jdbc.JdbcBackend.statement=DEBUG
@Wadjetz
Wadjetz / select-random.sql
Created August 13, 2015 06:17
Random SQL Select
SELECT * FROM table OFFSET random() * (SELECT COUNT(*) FROM table) LIMIT 1;
@Wadjetz
Wadjetz / FormFormatters.scala
Last active October 30, 2015 08:47
Custom Play Framework Form Validator
import play.api.data.format.Formatter
import play.api.data.FormError
import play.api.data.Forms
object FormFormatters {
implicit val optionalTextFormatter = new Formatter[Option[String]] {
def bind(key: String, data: Map[String, String]): Either[Seq[FormError], Option[String]] = {
data.get(key) match {
case None => Right(None)
case text => Right(text)
@Wadjetz
Wadjetz / ToInt.scala
Created June 10, 2015 07:50
Safe conversion to int
Try(number.toInt).toOption
@Wadjetz
Wadjetz / PathConversionImplicits.scala
Last active August 29, 2015 14:22
Implicit Conversions in Scala
import java.net.URLDecoder
object PathConversionImplicits {
class StringWraperPathWithSpace(str: String) {
def pathWithSpaces = URLDecoder.decode(str.trim, "UTF-8").replace(" ", "\\ ")
}
implicit def stringToPathWithSpace(str:String) = {
new StringWraperPathWithSpace(str)
}
@Wadjetz
Wadjetz / .vimrc
Last active February 8, 2016 23:06
Vim Config
" VIM Configuration Egor Berezovskiy
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
object LearnOptions {
def foption(i: Int): Option[Int] = {
if (i >= 5) Some(i) else None
}
val res = foption(6)
if (res.isDefined) {
println(res.get)