Code Snippets, Ideas and Rants from a Tech Lead interested primarily in server side web development and leading teams who build web apps.
Monday, May 25, 2015
Functional Thinking with Neal Ford
Pretty basic stuff, but I enjoyed watching it. He tries to stick to mostly Java.
Touches on some interesting variables & Clojure stuff towards the end.
https://www.youtube.com/watch?v=JeK979aqqqc
Thursday, April 16, 2015
A little more on Scala Futures
After continuing the article and continuing to functional compositions and the flatmap.
I thought it helpful to include my Eclipse worksheet code, which can be played with and run.
I thought it helpful to include my Eclipse worksheet code, which can be played with and run.
import scala.concurrent._ import ExecutionContext.Implicits.global import scala.util.{Try,Success,Failure} object Actors3 { println("Actors3----") val r = scala.util.Random val usdQuote = future { Thread.sleep(1000) r.nextInt(10) } val canQuote = future { Thread.sleep(1000) r.nextInt(10) } val purchase = for { usd <- usdQuote can <- canQuote if (can > usd) } yield "Can Strong" purchase onSuccess { case e => println(s"e1=${e}") } println("This is the most interesting") val purchase2 = usdQuote flatMap { usd => canQuote.withFilter(can => (can > usd)).map(can => "Can Strong") } recover { case _ => "Falsies" } println(s"purchase2=${purchase2}") purchase2 onSuccess { case e => println(s"e2=${e}") } Thread.sleep(4000) println("End----") }
Wednesday, April 15, 2015
Scala & Play
Just learnings in Scala. Some decent resources
http://danielwestheide.com/scala/neophytes.html
And the Book Scala for the Impatient
http://www.horstmann.com/scala/index.html
http://danielwestheide.com/scala/neophytes.html
And the Book Scala for the Impatient
http://www.horstmann.com/scala/index.html
Scala Futures
A nice walkthrough of Futures what they are in Scala and how to use them
http://docs.scala-lang.org/overviews/core/futures.html
In Eclipse the following Worksheet code can be executed based on the examples. You can run in a worksheet to see the async calls all come back at the same time.
http://docs.scala-lang.org/overviews/core/futures.html
In Eclipse the following Worksheet code can be executed based on the examples. You can run in a worksheet to see the async calls all come back at the same time.
import scala.concurrent._ import ExecutionContext.Implicits.global import scala.util.{Try,Success,Failure} object Actors { println("Actors----") val r = scala.util.Random def getAmount(): Int = { Thread.sleep(3000) r.nextInt(10) } println("Lets do three getAmount which take 3 seconds each") val f1: Future[Int] = future { getAmount() } val f2: Future[Int] = future { getAmount() } val f3: Future[Int] = future { getAmount() } println("OnComplete starts") f1 onComplete { case Success(ans) => println(s"1.ASYNC COMPLETED : ${ans}") case Failure(t) => println(s"ERROR : ${t}") } f2 onComplete { case Success(ans) => println(s"2.ASYNC COMPLETED : ${ans}") case Failure(t) => println(s"ERROR : ${t}") } f3 onComplete { case Success(ans) => println(s"3.ASYNC COMPLETED : ${ans}") case Failure(t) => println(s"ERROR : ${t}") } println("Wait") Thread.sleep(4000) println("Wait Over") println("Doing syncronously takes long") println(getAmount()) println(getAmount()) println(getAmount()) println("Composition----Callback") val amount = future { getAmount() } Thread.sleep(4000) amount onSuccess { case a => val purchase = future { if (a >= 5) "BUY" else "SELL" } purchase onSuccess { case a => println(s"purchase [${a}]") } } Thread.sleep(1000) println("Composition----Map") val amount2 = future { getAmount() } Thread.sleep(4000) val purchase = amount2 map { a => if (a >= 5) "BUY" else "SELL" } purchase onSuccess { case a => println(s"purchase [${a}]") } println("End----") }
Thursday, March 26, 2015
Great Play 2.3 starting point video
I found this video a great overview with some very interesting depth.
I was finding getting started in the play/activator a bit messy. I just could not see the overall picture, what is included and what serves what purpose.
This video really cleared that up nicely.
It covers activator, play, ide, sbt-web, slick, akka, json reader/writer, and scala.
I was finding getting started in the play/activator a bit messy. I just could not see the overall picture, what is included and what serves what purpose.
This video really cleared that up nicely.
It covers activator, play, ide, sbt-web, slick, akka, json reader/writer, and scala.
Play - Java - Video Tutorial
I found this to be a good start in Play (Java) and Activator
https://www.youtube.com/watch?v=bLrmnjPQsZc
For some reason the final coffee script part was not working for me, but that was of less interest than seeing an overview of Play and CRUD in Play.
FYI
What was happening for me was the .js was being generated and could be seen
http://localhost:9000/assets/js/index.js
But for some reason if I tried to debug in chrome it would always break in the index.coffee and then fail on the first line
$ ->
I found out this is because jQuery was not being included, I had to add the following line in main.scala.html
A great follow up is the exact same video but now using Scala in place of Java.
https://www.youtube.com/watch?v=eNCerkVyQdc
This time the sorm ORM was missing and the following line had to be added to build.sbt
https://www.youtube.com/watch?v=bLrmnjPQsZc
For some reason the final coffee script part was not working for me, but that was of less interest than seeing an overview of Play and CRUD in Play.
FYI
What was happening for me was the .js was being generated and could be seen
http://localhost:9000/assets/js/index.js
But for some reason if I tried to debug in chrome it would always break in the index.coffee and then fail on the first line
$ ->
I found out this is because jQuery was not being included, I had to add the following line in main.scala.html
<script src=" https://code.jquery.com/jquery-1.11.2.js")" type="text/javascript"></script>
A great follow up is the exact same video but now using Scala in place of Java.
https://www.youtube.com/watch?v=eNCerkVyQdc
This time the sorm ORM was missing and the following line had to be added to build.sbt
libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.16"
Wednesday, March 4, 2015
Testing Visual Layout
Working on a responsive Single Page Application. Backend java webservice have solid test, but the AngularJS front end is more difficult. I need to be able to test layout issues on different browsers and at different resolutions.
A little bit of googling lead me to Galen Framework.
I started by reading some documentation and then this video. Unfortunately the video is out of date and on Windows and chrome there are a ton of gotchas.
P.s. if you want IE to work go here you will have to restart your computer
Here are my files that I got working with the video.
introduction.test
command line
homepage.spec
I started by reading some documentation and then this video. Unfortunately the video is out of date and on Windows and chrome there are a ton of gotchas.
- Add Galen to your path
- Get the selenium chromedriver and place it in the Galen directory, that was added to your path
- Galen is VERY VERY wierd about tabs, you have to use spaces. if there is a tab it ignored it completely making this line
selenium chrome http://galenframework.com/[tab]1024x768 Completely different to selenium chrome http://galenframework.com/ 1024x768
P.s. if you want IE to work go here you will have to restart your computer
Here are my files that I got working with the video.
introduction.test
@@ Set domain galenframework.com @@ Table devices | device | tags | size | | mobile | all,mobile | 320x640 | | desktop | all,desktop | 1024x768 | @@ Parameterized using devices Home page on ${device} selenium chrome http://${domain} ${size} check homepage.spec --include "${tags}"
command line
galen test introduction.test --htmlreport reports
homepage.spec
========================================= header-container id header header-brand css #header .navbar-brand header-logo css #header .navbar-brand img header-news css #bs-example-navbar-collapse-1 .nav ========================================= @all ------------------------- header-container inside: screen 0px top width: 100% of screen/width height: 50px header-brand inside: header-container 0px top left header-logo width: 26px height: 26px @desktop ------------------------- header-news visible @mobile ------------------------- header-news absent
Thursday, February 19, 2015
Starting to Learn AngularJS
For a quick pass at Angular JS I recommend
Good old W3Schools
I particularly like the try it now, where I can see the code immediately without having to download. It also only took 25 minutes.
My local Angular Wizard recommended this code school tutorial
Monday, January 5, 2015
Great Akka Video
Subscribe to:
Posts (Atom)