Skip to content

Instantly share code, notes, and snippets.

View heathermiller's full-sized avatar

Heather Miller heathermiller

View GitHub Profile
/** @constructor */
ScalaJS.c.example_ScalaJSExample$ = (function() {
ScalaJS.c.java_lang_Object.call(this)
});
ScalaJS.c.example_ScalaJSExample$.prototype = new ScalaJS.inheritable.java_lang_Object();
ScalaJS.c.example_ScalaJSExample$.prototype.constructor = ScalaJS.c.example_ScalaJSExample$;
ScalaJS.c.example_ScalaJSExample$.prototype.main__V = (function() {
var paragraph = ScalaJS.g["document"]["createElement"]("p");
paragraph["innerHTML"] = "<strong>It works!</strong>";
ScalaJS.c.example_ScalaJSExample$.prototype.main__V = (function() {
var paragraph = ScalaJS.g["document"]["createElement"]("p");
var l = ScalaJS.modules.scala_collection_immutable_List().apply__Lscala_collection_Seq__Lscala_collection_immutable_List(ScalaJS.modules.scala_Predef().wrapIntArray__AI__Lscala_collection_mutable_WrappedArray(ScalaJS.makeNativeArrayWrapper(ScalaJS.data.scala_Int.getArrayOf(), [1, 2, 3])));
var l2 = ScalaJS.as.scala_collection_immutable_List(l.$$colon$plus__O__Lscala_collection_generic_CanBuildFrom__O(ScalaJS.bI(4), ScalaJS.modules.scala_collection_immutable_List().canBuildFrom__Lscala_collection_generic_CanBuildFrom()));
paragraph["innerHTML"] = (("<strong>Here's a list" + l2) + "</strong>");
ScalaJS.g["document"]["getElementById"]("playground")["appendChild"](paragraph)
});
Scala
/** @constructor */
ScalaJS.c.example_Person = (function() {
ScalaJS.c.java_lang_Object.call(this);
this.name$1 = null;
this.age$1 = 0
});
ScalaJS.c.example_Person.prototype = new ScalaJS.inheritable.java_lang_Object();
ScalaJS.c.example_Person.prototype.constructor = ScalaJS.c.example_Person;
ScalaJS.c.example_Person.prototype.name__T = (function() {
return this.name$1
/** @constructor */
ScalaJS.c.example_Person = (function() {
ScalaJS.c.java_lang_Object.call(this);
this.name$1 = null;
this.age$1 = 0
});
ScalaJS.c.example_Person.prototype = new ScalaJS.inheritable.java_lang_Object();
ScalaJS.c.example_Person.prototype.constructor = ScalaJS.c.example_Person;
ScalaJS.c.example_Person.prototype.name__T = (function() {
return this.name$1
(function(){'use strict';function e(a){return function(){return this[a]}}function f(a){return function(){return a}}var k,aa="object"===typeof global&&global&&global.Object===Object?global:this,ba="object"===typeof __ScalaJSExportsNamespace&&__ScalaJSExportsNamespace?__ScalaJSExportsNamespace:"object"===typeof global&&global&&global.Object===Object?global:this;function ca(a){return function(b,c){return!(!b||!b.a||b.a.Ra!==c||b.a.Qa!==a)}}function da(a){var b,c;for(c in a)b=c;return b}function n(a){return!(!a||!a.a)}
function p(a,b){throw(new ea).x(a+" is not an instance of "+b);}
function fa(a,b){var c;if(n(a))if(ga(),a===b)c=!0;else if(q(a))if(c=ha(a),q(b)){var d=ha(b),h=ia(c),g=ia(d),h=g>h?g:h;switch(h){default:c=h===s().K?c.y()===d.y():h===s().X?c.B().j(d.B()):h===s().W?c.P()===d.P():h===s().V?c.N()===d.N():d&&d.a&&d.a.g.cc&&!(c&&c.a&&c.a.g.cc)?t(d,c):null===c?null===d:t(c,d)}}else u(b)?(d=ja(b),c=ka(c,d)):c=null===c?null===b:t(c,b);else u(a)?(c=ja(a),u(b)?(d=ja(b),c=c.m===d.m):q(b)?(d=ha(b),c=ka(d,c)):c=nu
val codeToChars: Map[Char, String] =
Map(
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL",
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ"
)
/**
* Inverse of codeToChars,
* e.g. 'A' -> '2', 'B' -> '2'.
*/
@heathermiller
heathermiller / tagged.scala
Created November 12, 2014 21:33
TypeInfo pickling
package tagged
import scala.pickling._
import internal._
import json._
// final case class TypeInfo(erasureClass: String, typeArguments: Seq[TypeInfo] = Seq.empty)
// final case class AttributeKey(name: String, manifest: TypeInfo)
@heathermiller
heathermiller / so.xml
Created April 7, 2015 19:34
Excerpt of StackOverflow dump
<?xml version="1.0" encoding="UTF-8" ?>
<row Id="4" PostTypeId="1" AcceptedAnswerId="7" CreationDate="2008-07-31T21:42:52.667" Score="322" ViewCount="21888" Body="&lt;p&gt;I want to use a track-bar to change a form's opacity.&lt;/p&gt;&#xA;&#xA;&lt;p&gt;This is my code:&lt;/p&gt;&#xA;&#xA;&lt;pre&gt;&lt;code&gt;decimal trans = trackBar1.Value / 5000;&#xA;this.Opacity = trans;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&#xA;&lt;p&gt;When I try to build it, I get this error:&lt;/p&gt;&#xA;&#xA;&lt;blockquote&gt;&#xA; &lt;p&gt;Cannot implicitly convert type 'decimal' to 'double'.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&#xA;&lt;p&gt;I tried making &lt;code&gt;trans&lt;/code&gt; a &lt;code&gt;double&lt;/code&gt;, but then the control doesn't work. This code has worked fine for me in VB.NET in the past. &lt;/p&gt;&#xA;" OwnerUserId="8" LastEditorUserId="451518" LastEditorDisplayName="Rich B" LastEditDate="2014-07-28T10:02:50.557" LastActivityDate="2014-12-20T17:18:47.807" Title="When setting a form's opacity should I use a
@heathermiller
heathermiller / clojure-to-scala.scala
Created November 6, 2011 14:08
Clojure to Scala, line by line
def slow = Thread.sleep(700)
def fast = Thread.sleep(100)
def threadDeliver[T](fun: => T, prom: SyncVar[T]) =
actor { prom set fun }
def main[T](a: => T, aw: Long, b: => T, overall: Long, default: T): T = {
val p = new SyncVar[T]
threadDeliver(a, p)
@heathermiller
heathermiller / clojure-to-scala-clean.scala
Created November 6, 2011 14:10
Clojure to Scala, cleaned up
def slow = Thread.sleep(700)
def fast = Thread.sleep(100)
def threadDeliver[T](fun: => T, prom: SyncVar[T]) =
actor { prom set fun }
def tryDeliver[T](promise: SyncVar[T], a: => T, timeout: Long)(otherwise: => T): T = {
threadDeliver(a, promise)
promise.get(timeout) match {