Skip to content

Instantly share code, notes, and snippets.

<input type="submit" onClick="plusOne()" value="+1"/>
<input type="submit" onClick="minusOne()" value="-1"/>
<input type="submit" onClick="reset()" value="reset"/>
<table width="200" border="0" align="center">
<tbody style="display:flex"><tr>
<td><img src="on.png" name="C1" width="50" height="50" id="C1" alt=""></td>
<td><img src="on.png" name="C2" width="50" height="50" id="C2" alt=""></td>
<td><img src="on.png" name="C3" width="50" height="50" id="C3" alt=""></td>
<td><img src="off.png" name="C4" width="50" height="50" id="C4" alt=""></td>
</tr>
@tyrcho
tyrcho / Main.scala
Last active January 26, 2021 11:01 — forked from anonymous/Main.scala
Scala.js Asynchronous REST call (Ajax) demo with JSON parsing - http://www.scala-js-fiddle.com/gist/484e6ca68976aadb2cac63b55069acd8
import util._
import dom.ext._
import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow
object ScalaJSExample extends js.JSApp{
def main(): Unit = {
val url =
"http://jsonplaceholder.typicode.com/posts/1"
val f=Ajax.get(url)
f.onComplete{
@tyrcho
tyrcho / Main.scala
Last active December 30, 2017 12:45 — forked from anonymous/Main.scala
SPA (Single Page Application) demo with scala-js and scalatags. Live http://www.scala-js-fiddle.com/gist/0fbfc1a74a4f91e033e531a68012e145
// See http://www.lihaoyi.com/hands-on-scala-js/#Scalatags
import org.scalajs.dom
import dom.html
import scalajs.js.annotation.JSExport
object ScalaJSExample extends js.JSApp {
val document = js.Dynamic.global.document
def main() = {
@tyrcho
tyrcho / OpenWithSublimeText2.bat
Created May 11, 2016 14:17 — forked from mrchief/LICENSE.md
Add "Open with Sublime Text 2" to Windows Explorer Context Menu (including folders)
@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@tyrcho
tyrcho / index.html
Last active August 29, 2015 14:21 — forked from tyrcho/README.md
<!DOCTYPE html>
<html>
<title>Agile Catalog</title>
<xmp theme="cerulean" style="display:none;">
This catalog references books and videos on agile.
@tyrcho
tyrcho / AstarGraph.scala
Last active August 29, 2015 14:17 — forked from tyrcho/AstarGraph.scala
A star (A*) Graph traversal to find lowest cost
//CodinGame - Bender
object Solution extends App {
val n = readInt
val exterior = -1 -> new Room(-1, 0, -1, -1)
val roomsRead = for {
i <- (0 until n).toList
Array(id, value, next1, next2) = readLine split " "
} yield id.toInt -> Room(id.toInt, value.toInt, if (next1 == "E") -1 else next1.toInt, if (next2 == "E") -1 else next2.toInt)
val rooms = (exterior :: roomsRead).toMap
@tyrcho
tyrcho / README.md
Last active August 29, 2015 14:06 — forked from tyrcho/README.md
Implementation of Hearthstone mulligans with scala-js-fiddle.

Open with scala-js-fiddle for a demo

Implementation of Hearthstone mulligans with scala-js-fiddle.

Examples

  • There are 2 important cards in a deck, but you don't keep them in the mulligan phase (let's say 2 Doomguards in zoo). What is the probability to have at least one in hand at a given turn, if the player did not start the game ?
  • You think an opponent plays one Sylvanas. You started the game. What is the probability he has drawn it, assuming he does not keep it in the mulligans ?
  • You play 4 acceleration (Innervate, Wild Growth) cards. By mulliganing everything except those, what is the probability to have exactly one in starting hand ?
@tyrcho
tyrcho / README.md
Last active August 29, 2015 13:56 — forked from mbostock/.block

A basic HTML bar chart with log scale.

@tyrcho
tyrcho / ExprParser.scala
Last active December 15, 2015 16:50 — forked from aneveux/LCEB.java
package info.daviot.lceb
import scala.util.parsing.combinator._
sealed trait Expr { def eval: Int }
case class Number(value: Int) extends Expr {
val eval = value
}
case class Prod(left: Expr, right: Expr) extends Expr {
def eval = left.eval * right.eval
}
@tyrcho
tyrcho / gist:1511016
Created December 22, 2011 17:04 — forked from svenefftinge/gist:1506285
should be even faster (size only called once)
public static void main(String[] args) {
int iterations = 1000000;
Object[] items = {"foo", 23, true};
int size = items.length;
Object[] absoluteResult = new Object[iterations*size];
long before = System.currentTimeMillis();
for (int i=0; i < iterations; i++) {
for (int j=0 ; j< size; j++) {
absoluteResult[3*i+j]=foo(items[j]);
}