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
def join(list : List[Int]) : String = list match {
case List() => ""
case List(x) => x.toString
case List(x,y) => x + " and " + y
case List(x,y,z) => x + ", " + y + ", and " + z
case _ => list(0) + ", " + join(list.tail)
}
for{
event <- events
diff <- event.notifyList
val now = new DateTime().plusDays(diff)
if (now.getMonthOfYear == event.month && now.getDayOfMonth == event.date)
} {
hits = hits + 1
Mailer.mail("Reminder: " + event.name + " (" + event.textualDate + ")",
"The event '" + event.name + "' occurs " + event.textualDate + ".\n" +
<form method="POST" action="<%= url_for :action => :update %>">
<input type="hidden" name="id" value="<%= @question.object %>"/>
<h1 class="groupTitle"><%= @question.q %></h1>
<ul>
<li>
<label for="question[answer]">Eagle</label>
<% if @question.answer == "eagle" %>
<input type="radio" name="question[answer]" checked="checked" value="eagle"/>
<% else %>
1. Installer MacFuse : http://code.google.com/p/macfuse/
2. Installer brew : https://github.com/mxcl/homebrew
3. brew install python && brew install pip
4. Sette path til brew sin python
5. sudo touch /usr/include/osreldate.h
#fordi macfuse av en eller annen grunn sier at den er FreeBSD og da forventer fuse-ptyhon at den filen skal finnes
6. pip install beautifulsoup && pip install fuse-ptyhon
7. git clone <nrkfs>
8. ./nrkfs-py <mappe å mounte til>
#!/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)&
@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}
@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 =>
~ λ /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
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.
@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
}