This Gist was automatically created by Carbide, a free online programming environment.
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
name := "demoProject" | |
version := "1.0" | |
scalaVersion := "2.11.8" |
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
# -- coding: utf-8 | |
require "open-uri" | |
require "rubygems" | |
require "nokogiri" | |
url = "https://gist.github.com/" | |
charset = nil | |
html = open(url) do |f| |
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
<!-- | |
Snake Game | |
version: 0.3 | |
created at: 2013/04/11 | |
author: yutaono | |
--> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset=utf-8> |
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
/* | |
* array = new Array(1,2,3,2,4); | |
* => array (1,2,3,2,4) | |
* array.delte(2); | |
* => array (1,3,4) | |
*/ | |
Array.prototype.delete = function(v) { | |
var check = false; | |
for (var i in this) { | |
if (this[i] == v) { |
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
var quicksort = function(seq){ | |
if(seq.length<=1){ | |
return seq; | |
} | |
var pivot = seq[0]; | |
var left = new Array(); | |
var right = new Array(); | |
for(var i=1; i<seq.length; i++){ | |
if(pivot>seq[i]){ | |
left.push(seq[i]); |
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
sealed trait Animal | |
case class Dog(name: String) extends Animal | |
case class Cat(name: String) extends Animal | |
val dogs = List(Dog("pochi"), Dog("gon")) | |
val cats = List(Cat("tama"), Cat("kuro")) | |
val animals: List[Animal] = List(dogs, cats).flatten |
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 com.aerospike.client.policy.ClientPolicy | |
import com.aerospike.client.{AerospikeClient, Bin, Key} | |
object AerospikeIntLongSpec extends App { | |
val policy = new ClientPolicy | |
policy.user = ""; policy.password = "" | |
val client = new AerospikeClient(policy, "127.0.0.1", 3000) | |
val (keyName, binName) = ("budget", "spend") |
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
trait State { | |
import State._ | |
val seq: Seq[(Double, State)] | |
def next: State = | |
(seq sortWith { (s1, s2) => | |
(s1._1 * randValue) > (s2._1 * randValue) | |
}).head._2 |
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
// stackable trait pattern | |
// http://www.artima.com/scalazine/articles/stackable_trait_pattern.html | |
abstract class IntQueue { | |
def get: Int | |
def put(x: Int) | |
} | |
import scala.collection.mutable.ArrayBuffer |
NewerOlder