This file contains 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
<div pub-key="..." sub-key="..." ssl="off" ...></div> | |
<script src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script> | |
Enter Chat and press enter | |
<div><input id="input" value="you-chat-here" /></div> | |
Chat Output | |
<div id="output"></div> | |
<script> |
This file contains 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
#input { | |
font-size: 20px; | |
line-height: 20px; | |
} | |
#output, #input { | |
border-radius: 4px 4px 4px 4px; | |
box-shadow: 0 0 30px #EEEEEE inset; | |
margin: 10px; | |
padding: 10px; |
This file contains 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 FizzBuzz extends App { | |
implicit class MyInt(thisNumber: Int) { | |
def isDivisibleByOrHasDigit(other: Int) = { isDivisibleBy(other) || hasDigit(other) } | |
def isDivisibleBy(other: Int) = (thisNumber % other == 0) | |
def hasDigit(c: Char): Boolean = thisNumber.toString.contains(c) | |
def hasDigit(x: Int): Boolean = { | |
assert(x >= 0 && x < 10, s"Number should be 1 digit long (found: $x)") | |
hasDigit(x.toString.head) | |
} |
This file contains 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.robovm.cocoatouch.coregraphics._ | |
import org.robovm.cocoatouch.foundation._ | |
import org.robovm.cocoatouch.uikit._ | |
object Utils { | |
import scala.language.implicitConversions | |
implicit class RichUIControl(control: UIControl) { |
This file contains 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
require 'date' | |
# Creates a calendar of _year_. Returns this calendar as a multi-line | |
# string fit to _columns_. | |
def cal(year, columns) | |
# Start at January 1. | |
# | |
# Date::ENGLAND marks the switch from Julian calendar to Gregorian | |
# calendar at 1752 September 14. This removes September 3 to 13 from |
This file contains 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 toRoman( v:Int ) : String = { | |
val romanNumerals = List(1000->"M",900->"CM",500->"D",400->"CD",100->"C",90->"XC", | |
50->"L",40->"XL",10->"X",9->"IX",5->"V",4->"IV",1->"I") | |
var n = v | |
romanNumerals.foldLeft(""){(s,t) => {val c = n/t._1; n = n-t._1*c; s + (t._2 * c) } } | |
} |
This file contains 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.sebnozzi.katas.tictactoe | |
object TicTacToe { | |
sealed class Player | |
case object O extends Player | |
case object X extends Player | |
case class Board(state: State = State()) { |
This file contains 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 scala.collection.mutable.Buffer | |
val frames = Buffer[String]() | |
frames += """ | |
> _______ | |
> |/ | | |
> | | |
> | | |
> | |
This file contains 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.scalatest.BeforeAndAfterAll | |
import org.openqa.selenium.WebDriver | |
import org.openqa.selenium.htmlunit.HtmlUnitDriver | |
import org.scalatest.FlatSpec | |
import play.api.test.TestServer | |
import org.scalatest.Matchers | |
import play.api.test.Helpers | |
import org.scalatest.selenium.WebBrowser | |
import play.api.test.FakeApplication |
This file contains 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
case class GreetingEvent(msg: String) | |
class Greeter extends Publisher[GreetingEvent] { | |
def greet(msg:String) = { | |
println("Firing event") | |
publish(GreetingEvent(msg)) | |
} | |
} | |
class GreetingSubscriber(name: String) |
OlderNewer