How to implement a custom search for Hugo usig Gruntjs and Lunrjs.
Install the following tools:
| /** | |
| git clone https://github.com/twitter/scalding.git | |
| cd scalding | |
| ./sbt scalding-repl/console | |
| */ | |
| import scala.io.Source | |
| val alice = Source.fromURL("http://www.gutenberg.org/files/11/11.txt").getLines | |
| // Add the line numbers, which we might want later | |
| val aliceLineNum = alice.zipWithIndex.toList |
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.
| # Add this to your boot.rb before Padrino.load! | |
| # and add: gem 'pry' | |
| # to your Gemfile and run bundle to install. | |
| begin | |
| require 'pry' | |
| $VERBOSE = nil | |
| IRB = Pry | |
| $VERBOSE = false | |
| rescue LoadError |
| // A Unit test template for Tape | |
| // See 5 Questions every unit test must answer: | |
| // https://medium.com/javascript-scene/what-every-unit-test-needs-f6cd34d9836d | |
| import test from 'tape'; | |
| test('What are you testing?', assert => { | |
| const msg = 'what should it do?' | |
| const actual = 'what was the output?'; |
| def nQueens(n: Int) = (0 until n).permutations filter {col => // col[r] = column of queen on r-th row | |
| val p = col.zipWithIndex.toSet // col[] must be a permutation of (0 until n) because of rook attacks | |
| p.map{case (c, d) => c + d}.size == n && // No 2 queens can have same col + diag because of left-bishop attacks | |
| p.map{case (c, d) => c - d}.size == n // No 2 queens can have same col - diag because of right-bishop attacks | |
| } | |
| /*************************************** [Printing code below] *************************************************/ | |
| for ((solution, num) <- nQueens(8).zipWithIndex) { | |
| println(s"Solution #${num + 1}:") | |
| solution foreach {col => | |
| val row = solution.indices.map(i => if (i == col) 'Q' else '-') |
| // initialize the Shanghai component which keeps track of | |
| // shipping data in and out of the Port of Shanghai. | |
| var shanghai = Elm.worker(Elm.Shanghai, { | |
| coordinates:[0,0], | |
| incomingShip: { name:"", capacity:0 }, | |
| outgoingShip: "" | |
| }); | |
| function logger(x) { console.log(x) } | |
Max Goldstein | July 30, 2015 | Elm 0.15.1
In Elm, signals always have a data source associated with them. Window.dimensions is exactly what you think it is, and you can't send your own events on it. You can derive your own signals from these primitives using map, filter, and merge, but the timing of events is beyond your control.
This becomes a problem when you try to add UI elements. We want to be able to add checkboxes and dropdown menus, and to receive the current state of these elements as a signal. So how do we do that?