Skip to content

Instantly share code, notes, and snippets.

View bjartek's full-sized avatar
💭
No power in the verse can stop me

Bjarte S. Karlsen bjartek

💭
No power in the verse can stop me
  • Shiny && Find && Versus
  • Lillesand, Norway
  • X @0xBjartek
View GitHub Profile
# [Created by task 1.9.4 4/26/2011 23:22:06]
# Taskwarrior program configuration file.
# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-faq',
# 'man task-tutorial', 'man task-color', 'man task-sync' or 'man taskrc'
# Here is an example of entries that use the default, override and blank values
# variable=foo -- By specifying a value, this overrides the default
# variable= -- By specifying no value, this means no default
# #variable=foo -- By commenting out the line, or deleting it, this uses the default
class MineSweeper(val input:String) {
val grid = input.split("\n").map(_.toArray)
def isCellBomb(cell:(Int, Int)) = {
for{
row <- grid.lift(cell._1)
cell <- row.lift(cell._2)
if(cell == '*')
} yield 1
}
class MineSweeper(val input:String) {
val grid = input.split("\n").map(_.toArray)
def isCellBomb(cell: Tuple2[Int,Int]) = {
for{
row <- grid.lift(cell._1)
cell <- row.lift(cell._2)
if(cell == '*')
} yield 1
}
val input = "..*\n...\n*..";
val grid = input.split("\n").map(_.toArray)
def bomb(coord: Tuple2[Int,Int]) = {
for{
row <- grid.lift(coord._1)
cell <- row.lift(coord._2)
if(cell == '*')
} yield 1
@bjartek
bjartek / sweep.scala
Created March 29, 2011 08:38
Minesweeper solver in scala
val input = "..*\n...\n*..";
val grid = input.split("\n").map(_.toArray)
def bomb(coord: Tuple2[Int,Int]) = grid.lift(coord._1).flatMap(_.lift(coord._2)) match {
case Some('.') => 0;
case Some('*') => 1;
case None => 0
}
copy paste this into a shell
/Users/bjartek/.vim-addons/vim-addon-async/C/vim-addon-async-helper mvim 'VIM' '1' '/Users/bjartek/tmp/vcnZGwR/3' '/Users/bjartek/tmp/vcnZGwR/5' '2000' '/Users/bjartek/.vim-addons/ensime/dist/bin/server.sh '\''/Users/bjartek/tmp/vcnZGwR/2'\'' '\''vim'\'''
pid: 33882, bufnr: 4
VIM LOG : sent: [1,"swank:init-project","sexp-string"," ( :project-package \"synonyms\" :use-sbt t )","/Users/bjartek/foo"]
server : s shell
server : using json protocol
server : Project waiting for init...
server : Server listening on 55957..
server : Wrote port 55957 to /Users/bjartek/tmp/vcnZGwR/2.
~ λ /Users/bjartek/.vim-addons/vim-addon-async/C/vim-addon-async-helper mvim 'VIM' '2' '/Users/bjartek/tmp/vHx9uCJ/7' '/Users/bjartek/tmp/vHx9uCJ/9' '2000' '/bin/bash -i'
arg 0 mvim
arg 1 --servername
arg 2 VIM
arg 3 --remote-expr
arg 4 async#Receive("2","pid",["22667"])
0
got data
sending bytes: bash: no job control in this shell
, len 35
@bjartek
bjartek / QuizCLIUi
Created November 15, 2010 22:16
CLI ui for quiz
package scalaexamples.quiz.console
import scalaexamples.quiz.{Answer, Question, Quiz}
import annotation.tailrec
class ConsoleGame(quiz: Quiz) {
println("Welcome to our faboulus quiz called '" + quiz.title + "'")
val answers = quiz.questions.map {
question =>
@bjartek
bjartek / Input.scala
Created November 15, 2010 22:05
why does this not work? runtime exception
import annotation.tailrec
object Input {
def main(args: Array[String]) {
println(askInput)
}
@tailrec
private def askInput: String = {
lazy val input = try readLine.toInt -1 catch {case _ => -1}
#!/bin/bash
(ssh bjartka@pvv -o PermitLocalCommand=no \
": > ~/.irssi/fnotify ; tail -f ~/.irssi/fnotify " | \
while read heading message; do \
growlnotify -t "${heading}" -m "${message}"; \
done)&