java8 and scala on Ubuntu

By default:

sudo apt-get install java scala

Istalled for my Ubuntu OpenJDK 7. webupd8.org blog post help me install Java 8 from Oracle:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Test what version is installed:

java -version
javac -version

Installation of latest scala (2.11.7) I’ve done based on Larysa Visengeriyeva instructions on github:

sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.7.deb
sudo dpkg -i scala-2.11.7.deb

SBT was installed by default in latest version.

Check installed version:

scala
scala> util.Properties.versionString

It worked. I deserve a beer. Cheers!

java logo with beer

Posted in Uncategorized | Tagged , , | Leave a comment

scala(z) – how to (not?) learn

Learning Scala is a crazy task, if you want to grasp its syntax and everything else at the same time. Everything else for me is:

and a new IDE – InteliJ Idea🙂

Anyhow I have found two great places to learn Scalaz:

Usually after each slide/page/video frame I have to googleout what are those implicit parameters, ???, Try class and other Scala features to understand anything.

Pros: I have to learn a lot in the process
Cons: Sometimes all I get from full day reading and watching is a bunch of new terms that have only connections between themselves and not any other part of my brain🙂

Posted in Uncategorized | Tagged | Leave a comment

angular.js tutorial – npm install problems

Running command:

npm install -g karma protractor bower http-server

on Windows 8.1 64bit was a bit painfull.

What finally worked was:

  1. install python 2.7 (3.x did not work)
  2. install Visual Studio 2015 and make sure C++ Compiler is installed

The last part I learned the hard way. For this error:

Could not load the Visual C++ component "VCBuild.exe"

Installation of .NET Framework did not helped. After installing Visual Studio 2015 Comunnity I got:

TRK0005: Failed to locate: "CL.exe"

Only reinstall with more options checked – worked.

Posted in Uncategorized | Tagged , | Leave a comment

Hey bro before you buy a book

My colleague from work was talking about books he intended to buy. So I have said.

But bro internet is full of free, surprisingly good and fun places to get some info about what is happening in software development.

If one of them will look interesting one may read official documentation and done some coding (preferably with friends) to really grasp stuff🙂

Posted in Uncategorized | Leave a comment

Git fun and usefull tutorials

UPDATE: Sufyan bin Uzayr on speckybooy summarized free Git resources far better than me in below post.

Here are 2 fun, interactive tutorials for Git

Oh if only I got cherry-pick command in svn😦

There is official Git tutorial. I did not find link in main page. But is less interactive.

And for good end here is insightful and fun vid about gamer behaviors on random dungeons:

Posted in Uncategorized | Tagged | Leave a comment

SBT + ScalaTest from WoW addict perspective

Reading SBT Tutorial is a bit painful if your Scala-fu is not very strong. You may feel a bit like a leveling player travelling trough SV in WoW:

But SBT is easy. Check out following short info and judge by yourself:

Hello World in SBT

Simple program printing some stuff, that can be handeld by SBT (sample project)
We have config file: build.sbt

lazy val root = (project in file(".")).
	settings(
		name := "hello",
		version := "1.0",
		scalaVersion := "2.11.7"
	)

add some Scala code inside root dir or src/main/scala:

object Hi {
	def main(args: Array[String]) = println("Hi!")
}

We can compile this by:

sbt compile

or play around with more commands (sbt run, sbt package, sbt help) or even more SBT commands.

Super easy stuff.

SBT project with ScalaTest

To do some testing we need to (sample project):
1) add dependency for ScalaTest in build.sbt:

lazy val second = (project in file(".")).
	settings(
		name := "second",
		version := "1.0",
		scalaVersion := "2.11.7",
		libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
	)

2) add some tests in src/test/scala:

import org.scalatest.FlatSpec

class SetSpec extends FlatSpec {

  "An empty Set" should "have size 0" in {
    assert(Set.empty.size == 0)
  }

}

and run tests: sbt test or even better ask SBT to compile and run tests whenever something is changed:

sbt ~ test

Easy and straight forward.

Some more stuff about SBT and ScalaTest:

Posted in Uncategorized | Tagged , | Leave a comment

Scheme macro examples

I got stuck with macro explanation in Teach yoursef Scheme in fixnum days. Idea was pretty simple but implementation …. well I felt a bit lost like a gnome trying to get to AH in SW:

Then I dig out the define-syntax, experiment on my own and … here are some simple-like-pie examples:

Hello world are considered harmfull but one have to start somwhere:

#lang r6rs
(import (rnrs base(6))
        (rnrs io simple(6)))

(define-syntax do-magic
  (syntax-rules ()
    ((do-magic)
     (display "Huh? Why not just a procedure?"))))

(do-magic)
; uh? Why not just a procedure?

Example with macro witch invoke the procedure and passes parameter, for showing that usual way of interpreting list elements can be changed in macro:

#lang r6rs
(import (rnrs base(6))
        (rnrs io simple(6)))

(define-syntax apply1
  (syntax-rules ()
    ((_ proc-name proc-arg)
     (proc-name proc-arg))))

(apply1 display 7)
; 7

Now the same trick but with variable number of arguments

#lang r6rs
(import (rnrs base(6))
        (rnrs io simple(6)))

(define-syntax apply2
  (syntax-rules ()
    ((_ proc-name arg ...)
     (proc-name arg ...))))

(apply2 min 7 8 9)
; 7

More examples – this time with defining when. The simple way …

#lang r6rs
(import (rnrs base(6))
        (rnrs io simple(6)))

(define-syntax when1
  (syntax-rules ()
    ((_ test-expr expr-to-eval)
     (if test-expr expr-to-eval))))

(when1 (< 1 2) (display "it's a small steps for list programmer but enormous for my"))

… and proper way:

#lang r6rs
(import (rnrs base(6))
        (rnrs io simple(6)))

(define-syntax when2
  (syntax-rules ()
    ((_ test expr1 expr2 ...)
    (if test
        (begin expr1 expr2 ...)))))

(when2 #t (display 42) (newline) (display "it works"))
; 42
;
; it works

Cool🙂

Posted in Uncategorized | Tagged | Leave a comment