This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.rea.core | |
| import scala.util.Try | |
| object MathUtils { | |
| def divide(x: Integer, y: Integer): Option[Double] = { | |
| if (y == 0) None | |
| else Some(x / y) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.http4s.server.{Server, ServerApp} | |
| import org.http4s.server.blaze._ | |
| import scalaz.concurrent.Task | |
| import org.http4s._, org.http4s.dsl._ | |
| import org.http4s.server.syntax._ | |
| object Main extends ServerApp { | |
| val helloService = HttpService { | |
| case GET -> Root / "hello" / name => | |
| Ok(s"Hello, $name.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object Solution { | |
| def main(args: Array[String]): Unit = { | |
| for (ln <- io.Source.stdin.getLines) println("Hello, World.\n" + ln) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = [1, 2, 3]; | |
| var b = [...a, 2, 3] | |
| console.log(b) /* [1, 2, 3, 4, 5, 6] */ | |
| var l1 = [ | |
| {id: 1, name: 'Guido'}, | |
| {id: 2, name: 'Simone'} | |
| ] | |
| var l2 = [ | |
| ...l1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="application/javascript"> | |
| /* Load GeoJSON file. */ | |
| $.getJSON('geojson/1859.geojson', function (result) { | |
| /* Init variables. */ | |
| var geojson = result, | |
| map_1859 = L.map('1859').setView([42.10, 12.50], 5), | |
| opacity = 1.0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% 1000.times do |n| %> | |
| user_<%= n %>: | |
| first_name: <%= ['Bruce', 'Steve', 'Dave', 'Janick', 'Adrian', 'Nicko'].sample %> | |
| last_name: <%= ['Dickinson', 'Harris', 'Murray', 'Gers', 'Smith', 'McBrain'].sample %> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def init_redis | |
| @redis = Redis.new(:host => Rails.configuration.x.redis.host, | |
| :port => Rails.configuration.x.redis.port, | |
| :password => Rails.configuration.x.redis.password) if @redis == nil | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.configure do | |
| # Other stuff | |
| # Rails instance | |
| config.x.redis.host = 'localhost' | |
| config.x.redis.port = 6379 | |
| config.x.redis.password = nil | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| protect_from_forgery with: :exception | |
| before_action :initialize_helper | |
| skip_before_filter :verify_authenticity_token | |
| def initialize_helper | |
| init_redis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationHelper | |
| attr_reader :redis | |
| @redis = nil | |
| def init_redis | |
| @redis = Redis.new(:host => Rails.configuration.x.redis.host, | |
| :port => Rails.configuration.x.redis.port, | |
| :password => Rails.configuration.x.redis.password) if @redis == nil |