Skip to content

Instantly share code, notes, and snippets.

View sjrd's full-sized avatar

Sébastien Doeraene sjrd

View GitHub Profile
@sjrd
sjrd / build.sbt
Created May 28, 2017 08:24
CrossProject Pure with Eclipse, requires 'set every EclipseKeys.useProjectId := true'
scalaVersion in ThisBuild := "2.11.11"
version in ThisBuild := "0.1-SNAPSHOT"
lazy val foo = crossProject.crossType(CrossType.Pure).
settings(
)
lazy val fooJS = foo.js
lazy val fooJVM = foo.jvm
@sjrd
sjrd / WithGlobals.scala
Created April 30, 2017 22:20
I wrote a monad
/* __ *\
** ________ ___ / / ___ __ ____ Scala.js tools **
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2017, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ **
** /____/\___/_/ |_/____/_/ | |__/ /____/ **
** |/____/ **
\* */
package org.scalajs.core.tools.linker.backend.emitter
@sjrd
sjrd / CompatParColls.scala
Created March 22, 2017 12:54
Compat code for parallel collections across 2.10/2.11/2.12 and 2.13
package test
private[test] object CompatParColls {
val Converters = {
import Compat._
{
import scala.collection.parallel._
CollectionConverters
@sjrd
sjrd / ScalaJSRewrites.scala
Created March 21, 2017 09:38
scalafix rewrites for Scala.js: migrate facades to using @jsglobal, new in Scala.js 0.6.15
package scalafix.rewrite
import scala.collection.immutable.Seq
import scala.meta._
import scala.meta.contrib._
import scalafix.util.Patch
import scalafix.util.TokenPatch._
import scalafix.util.TreePatch.AddGlobalImport
import scalafix.util.TreePatch.Rename
@inline
def *(b: RuntimeLong): RuntimeLong = {
val alo = a.lo
val blo = b.lo
val a0 = alo & 0xffff
val a1 = alo >>> 16
val b0 = blo & 0xffff
val b1 = blo >>> 16
diff --git a/src/main/scala/org/scalajs/dom/experimental/push/PushManager.scala b/src/main/scala/org/scalajs/dom/experimental/push/PushManager.scala
index f721e20..da5005b 100644
--- a/src/main/scala/org/scalajs/dom/experimental/push/PushManager.scala
+++ b/src/main/scala/org/scalajs/dom/experimental/push/PushManager.scala
@@ -41,7 +41,8 @@ trait PushManager extends js.Object {
* MDN
*/
def permissionState(
- options: PushSubscriptionOptions = js.native): js.Promise[PushPermissionState] = js.native
+ options: PushSubscriptionOptions = js.native): js.Promise[
(function(){
'use strict';
/* Scala.js runtime support
* Copyright 2013 LAMP/EPFL
* Author: Sébastien Doeraene
*/
/* ---------------------------------- *
* The top-level Scala.js environment *
* ---------------------------------- */
@sjrd
sjrd / ImprovedInference.scala
Last active September 9, 2016 13:27
Scala 2.12.0-RC1's new inference improves JS interop!
package helloworld
import scala.scalajs.js
import js.|
import js.annotation._
@ScalaJSDefined
trait Foo extends js.Object {
val bar: Int | String
val baz: js.UndefOr[Int]
@sjrd
sjrd / compile-errors.txt
Created September 9, 2016 12:03
Compile errors with 2.12.0-RC1
> ;++2.12.0-RC1;testSuiteJVM/test
[info] Setting version to 2.12.0-RC1
[info] Reapplying settings...
[info] Set current project to scalajs-java-time (in build file:/localhome/doeraene/projects/scalajs-java-time/)
[info] Compiling 23 Scala sources to /localhome/doeraene/projects/scalajs-java-time/testSuite/jvm/target/scala-2.12.0-RC1/test-classes...
[error] /localhome/doeraene/projects/scalajs-java-time/testSuite/shared/src/test/scala/org/scalajs/testsuite/javalib/time/PeriodTest.scala:32: value getYears is not a member of java.time.temporal.TemporalAmount
[error] assertEquals(p.getYears.toLong, p.get(YEARS))
[error] ^
[error] /localhome/doeraene/projects/scalajs-java-time/testSuite/shared/src/test/scala/org/scalajs/testsuite/javalib/time/PeriodTest.scala:33: value getMonths is not a member of java.time.temporal.TemporalAmount
[error] assertEquals(p.getMonths.toLong, p.get(MONTHS))
@sjrd
sjrd / test-suite-fastopt.js.diff
Created June 28, 2016 22:37
RuntimeLong optimizations
This file has been truncated, but you can view the full file.
diff --git "a/C:\\Users\\Sepi\\Documents\\Projets\\scalajs-test-suite-test-fastopt.js" "b/C:\\Users\\Sepi\\Documents\\Projets\\scalajs\\test-suite\\js\\target\\scala-2.11\\scalajs-test-suite-test-fastopt.js"
index 6ac58c3..edb5b0f 100644
--- "a/C:\\Users\\Sepi\\Documents\\Projets\\scalajs-test-suite-test-fastopt.js"
+++ "b/C:\\Users\\Sepi\\Documents\\Projets\\scalajs\\test-suite\\js\\target\\scala-2.11\\scalajs-test-suite-test-fastopt.js"
@@ -1366,15 +1366,17 @@ function $s_Lorg_scalajs_testsuite_javalib_io_CommonStreamsTests$class__should$u
};
stream.reset__V();
var this$21 = $m_Lorg_junit_Assert$();
- var actual$5 = stream.skip__J__J(new $c_sjsr_RuntimeLong().init___I__I(40, 0));
- this$21.assertEquals__T__O__O__V(null, new $c_sjsr_RuntimeLong().init___I__I(40, 0), actual$5);