Skip to content

Instantly share code, notes, and snippets.

View ochrons's full-sized avatar

Otto Chrons ochrons

View GitHub Profile
import fiddle.Fiddle, Fiddle.println
import scalajs.js
import scalacss.Defaults._
@js.annotation.JSExport
object ScalaFiddle {
println( MyStyles.render )
}
object MyStyles extends StyleSheet.Inline {
import japgolly.scalajs.react._
import org.scalajs.dom
import org.scalajs.dom.raw.{HTMLElement, MouseEvent}
object Dropdown {
import japgolly.scalajs.react.vdom.all._
case class State(isOpen: Boolean = false)
case class Props(classes: String, content: ReactNode)
// $FiddleDependency org.scala-js %%% scalajs-dom % 0.9.0
// $FiddleDependency com.lihaoyi %%% scalatags % 0.5.4
import scalatags.JsDom.all._
import org.scalajs.dom
import fiddle.Fiddle, Fiddle.println
import scalajs.js
object ScalaFiddle extends js.JSApp {
def main() = {
// $FiddleStart
"Macau",
"Macedonia",
"Madagascar",
"Malawi",
"Malaysia",
"Maldives",
"Mali",
"Malta",
"Marshall Islands",
"Mauritania",
@ochrons
ochrons / WorkerMain.scala
Created May 25, 2016 19:59
Web Worker PoC in Scala.js
package poc
import org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
@js.native
object WorkerGlobal extends js.GlobalScope {
def addEventListener(`type`: String, f: js.Function): Unit = js.native
import com.amazonaws.HttpMethod
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.model._
...
val s3Client = new AmazonS3Client
private def getFlow(pathRaw: String, method: HttpMethod) = {
// clean the path
val path = pathRaw.dropWhile(_ == '/').trim
@ochrons
ochrons / ScalaFiddle.scala
Last active April 25, 2016 20:41
Hilber curve demonstration in ScalaFiddle
// $FiddleDependency org.scala-js %%% scalajs-dom % 0.9.0
// $FiddleDependency com.lihaoyi %%% scalatags % 0.5.4
import scalatags.JsDom.all._
import org.scalajs.dom
import fiddle.Fiddle, Fiddle.println
import scalajs.js
object ScalaFiddle extends js.JSApp {
def main() = {
// $FiddleStart
import scala.tools.nsc.interactive, scala.tools.nsc.reporters._, scala.tools.nsc._
object Test {
def main(args: Array[String]): Unit = {
val reporter = new StoreReporter
val s = new Settings()
s.processArgumentString("-Ypresentation-any-thread")
val global = new interactive.Global(s, reporter)
import global._
val Cursor = ""//"_DUMMY_ "
@ochrons
ochrons / gitter.css
Created February 22, 2016 18:36
Custom CSS theme for Gitter
.room-list-item__unread-badge {
color: black;
}
pre code {
text-rendering: optimizeLegibility;
font-family: Hasklig, monospace;
}
@ochrons
ochrons / Osc.scala
Last active April 14, 2018 14:13 — forked from anonymous/SierpinskiTriangle.scala
ScalaFiddle gist
import math._
val (h, w) = (Page.canvas.height, Page.canvas.width)
var x = 0.0
// $FiddleStart
val graphs = Seq[(String, Double => Double)](
("red", sin),
("green", x => 2 - abs(x % 8 - 4)),
("blue", x => 3 * pow(sin(x / 12), 2) * sin(x))
)
// $FiddleEnd