Skip to content

Instantly share code, notes, and snippets.

@Aankhen
Aankhen / abc.scala
Created February 10, 2012 07:31 — forked from sheki/abc.scala
func() = {
Stream.range(0, noItems) map {
_ => channel.basicGet(queueName, true) match {
case x: GetResponse => Some(x.getBody)
case _ => None
}
} takeWhile (_.isDefined) toList
}
@Aankhen
Aankhen / abc.scala
Created February 10, 2012 08:03 — forked from sheki/abc.scala
func() = {
def rec(i: Int, acc: List[Array[Byte]]) {
if (i == 0)
acc
else
channel.basicGet(queueName, true) match {
case x: GetResponse => rec(i - 1, x.getBody +: acc)
case _ => acc
}
}
@Aankhen
Aankhen / gist:1788524
Created February 10, 2012 10:18
Ensuring contiguity among pairs
def ensureContiguity(xs: List[(Int, Int)], acc: List[(Int, Int)] = List.empty): List[(Int, Int)] =
(xs, acc) match {
case (Nil, l) => l
case (l, Nil) => ensureContiguity(l dropRight 1, List(l.last))
case _ => {
val t = xs.last
val h = acc.head
if (t._2 == h._1)
ensureContiguity(xs dropRight 1, t +: acc)
@Aankhen
Aankhen / ContinuationsExample.scala
Created April 9, 2012 15:31 — forked from raymondtay/gist:2289042
Interactive Input
import scala.util.continuations._
// might need to be compiled and run separately due to a bug in App
object ContinuationsExample extends App {
def prompt(display: String): Boolean = {
print(display + " (Y/N) ")
Console.readLine.trim.headOption match {
case Some('Y') | Some('y') => true
case Some('N') | Some('n') => false
@Aankhen
Aankhen / Console
Last active April 18, 2018 20:10
Unable to use async generators with ts-node (+ generated index.js)
vagrant@ubuntu-xenial:/async-generators-test$ npm i -S typescript ts-node
...omitted...
vagrant@ubuntu-xenial:/async-generators-test$ node --version
v9.11.1
vagrant@ubuntu-xenial:/async-generators-test$ npm ls ts-node
/async-generators-test
└── ts-node@6.0.0
vagrant@ubuntu-xenial:/async-generators-test$ npx ts-node --harmony_async_iteration index.ts
> .exit
vagrant@ubuntu-xenial:/async-generators-test$ npx tsc -p tsconfig.json
@Aankhen
Aankhen / Cargo.toml
Created September 1, 2018 17:25
‘Recommending books (with Rust)’, enhanced
cargo-features = ["edition"]
[package]
name = "goodbooks-recommender"
version = "0.1.0"
authors = ["A"]
edition = "2018"
[dependencies]
reqwest = "0.8.8"
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy("images");
eleventyConfig.addPassthroughCopy("admin");
eleventyConfig.addPassthroughCopy("CSS");
eleventyConfig.addPassthroughCopy("Javascript");
eleventyConfig.addWatchTarget("images");
eleventyConfig.addWatchTarget("admin");
eleventyConfig.addWatchTarget("CSS");
eleventyConfig.addWatchTarget("Javascript");