/handsonscala

Discussion and and code examples for the book Hands-on Scala Programming

Primary LanguageTSQLOtherNOASSERTION

Hands-on Scala Programming

This repository is the online hub for the book Hands-on Scala Programming:

Executable Code Examples

The executable code examples from Hands-on Scala are freely available online, and open source under an MIT license. These examples are meant to be useful to anyone who is interested in learning Scala, whether or not they are working through Hands-on Scala Programming, though following along with the book will give you the best experience and help you get the most out of them.

Each example is:

  • Self-contained: to be run either using the Ammonite script runner or Mill build tool, with no other setup

  • Tested: with simple test suites provided and instructions on how to run each example in that folder's readme.md file

  • Executable: you can download the folder and run the example yourself to see it in action

Many of the examples are related, with only small code changes between them to illustrate a new feature or technique. The readme.md file of such downstream examples will show a diff from the upstream example that it was based upon, so you can focus your attention on the important code changes that are happening, with a link back up to the upstream example.

The executable code examples below are organized by each part and each chapter of the book.

  • 9.1 - Printing: Listing blog-post-like files in a folder and printing them out
  • 9.2 - Index: Rendering an index.html for our static blog using Scalatags
  • 9.3 - Markdown: Rendering individual blog posts using Atlassian's Commonmark-Java library
  • 9.4 - Links: Adding links between our index.html and the individual blog posts
  • 9.5 - Bootstrap: Prettifying our static blog using the Bootstrap CSS framework
  • 9.6 - Deploy: Optionally deploying our static blog to a Git repository
  • 9.7 - DeployTimestamp: Displaying the .md file last-modified time on each blog post
  • 10.1 - Simple: Simple linear build pipeline
  • 10.2 - Nonlinear: Simple non-linear build pipeline with two branches
  • 10.3 - Modules: Simple non-linear build pipeline, replicated in several modules
  • 10.4 - NestedModules: Nested modules in a Mill build pipeline
  • 10.5 - CrossModules: Using cross-modules to dynamically construct a build graph based on the filesystem
  • 10.6 - Blog: Our static blog generator, converted into an incremental Mill build pipeline
  • 10.7 - ExtendedBlog: Adding previews and bundled Bootstrap CSS to our static blog build pipeline
  • 10.8 - Push: Re-adding the ability to deploy our static blog by defining a T.command
  • 11.1 - ScrapingWiki: Scraping headlines off the Wikipedia front page using Jsoup
  • 11.2 - ScrapingDocs: Scraping semi-structured content off of the Mozilla Development Network Web API docs
  • 11.3 - ApiStatus: Using Jsoup to scrape the status annotations for every Web API on MDN
  • 11.4 - ExternalLinks: Crawling the pages of a static website to extract every external link on the site
  • 17.1 - Main: Simple two-process batch file synchronizer that could work over a network
  • 17.2 - FileSyncer: Simple two-process batch file synchronizer that could work over a network
  • 17.3 - Pipelined: Pipelined version of our two-process file synchronizer, minimizing the chattiness of the protocol
  • 17.4 - Deletes: Pipelined two-process file synchronizer that supports deletions
  • 18.1 - Simple: Simple real-time file synchronizer that uses os.watch to react to filesystem changes as they happen
  • 18.2 - Pipelined: Pipelined real-time file synchronizer, allowing RPCs and hashing to take place in parallel
  • 18.3 - InitialFiles: Real-time file synchronizer that supports syncing an initial set of files
  • 18.4 - ForkJoinHashing: Real-time file synchronizer that does hashing of files in parallel
  • 18.5 - Deletes: Real-time file synchronizer supporting deletion of files
  • 18.6 - VirtualFileSystem: Real-time file synchronizer that keeps track of synced files, avoiding RPCs for destination file hashes