View gist:35bf12f29c24991523db

The Anatomy of an Onyx Program

In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.

The Workflow

At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.

Let's examine the workflow pictorially:

View gist:5d6910c160fc3caa2365
user=> (load-file "src/flow_combine/core.clj")
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[{:n -2} {:n 0} {:n 2} {:n 4} {:n 5} {:n 6} {:n 8} :done]
#onyx.system.OnyxDevelopmentEnv{:logging-config #onyx.logging_configuration.LoggingConfiguration{:file "onyx.log", :config nil}, :log #onyx.log.zookeeper.ZooKeeper{:config {:hornetq/mode :vm, :hornetq.server/type :vm, :hornetq/server? true, :zookeeper/address "127.0.0.1:2186", :zookeeper/server? true, :zookeeper.server/port 2186, :onyx/id #uuid "afc875f7-2978-489e-aac4-84e527fa7889"}, :prefix #uuid "afc875f7-2978-489e-aac4-84e527fa7889", :conn #<ZooKeeper State:CLOSED sessionid:0x14ca93bb3a400
View gist:abc50985b12f08684a5c
Thoughts on http://words.steveklabnik.com/a-new-introduction-to-rust
1. Better than previous readings (though those were good too! Maybe just too quick?)
2. For visual learners, picturing/seeing chunk of lines is very useful.
2a. This becomes less clear across function calls. Any help in those cases? Similarly, investigation of hard to follow ownership examples will likely be valuable.
3. A 3-4 point quick summary to figure out ownership in any context would be helpful. Not sure how possible this is, but if the essentials can be boiled down to something easily remembered and applied, the overall understanding can grow from repeated application of the correct rules.
4. Know of any editor support for showing ownership? At least in very simple cases it seems straightforward.
5. lifetime, ownership, borrow, etc. They seem to be good choices, but generic enough that they don't help until you already understand things. It might be easier to really nail home the concept and then finally say "and that? That's borro
View gist:23b5de780226d6309194
2.2.0 :058 > def action
2.2.0 :059?> if true
2.2.0 :060?> puts "call some api thing" && return
2.2.0 :061?> end
2.2.0 :062?> puts "does this happen"
2.2.0 :063?> end
=> :action
2.2.0 :064 > action
=> nil
2.2.0 :065 > def action
View points.rb
require "fiddle"
require "fiddle/import"
module RustPoint
extend Fiddle::Importer
dlload "./libpoints.dylib"
extern "Point* make_point(int, int)"
extern "double get_distance(Point*, Point*)"
View gist:a78916919aad71133faa
puts "Example 1: No rescue inside loop"
begin
5.times do |i|
begin
p i
raise "loop stops here"
end
end
rescue => e
puts "error caught here: #{e}"
View gist:e625f3a839cae2cc19e6
> factorial n = \
| if n < 1 then 1 \
| else n * factorial (n-1)
[1 of 1] Compiling Repl ( repl-temp-000.elm )
Parse error at (line 6, column 1):
unexpected "i"
expecting newline or spaces
> factorial n = \
| if n < 1 then 1 \
View gist:9884820

I like Learn You a Haskell as a reference and cheat-sheet but I found it a little slow for learning Haskell.

Here's my recommended order for just learning Haskell:

http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/ 80% completion here is fine if you feel your attention waning, the next thing will address hammering in things like functors and monads via typeclasses.

https://github.com/NICTA/course/ this will hammer in the lessons in a very direct form by forcing you to confront the challenges and lessons learned by the creators and community of Haskell itself. Doing the exercises here is critical for being fluent.

Real World Haskell is available online. (Thanks bos!)

View angular_directive.coffee
angular.module("FundooDirectiveTutorial", []).controller("FundooCtrl", ($scope, $window) ->
$scope.rating = 5
$scope.saveRatingToServer = (rating) -> $window.alert "Rating selected - " + rating
).directive "fundooRating", ->
restrict: "A"
template: "<ul class=\"rating\">" + "<li ng-repeat=\"star in stars\" ng-class=\"star\" ng-click=\"toggle($index)\">" + "" + "</li>" + "</ul>"
scope:
ratingValue: "="
max: "="
readonly: "@"
View gist:8189527
scala> Json.toJson((1, 2))
<console>:20: error: No Json deserializer found for type (Int, Int). Try to implement an implicit Writes or Format for this type.
Json.toJson((1, 2))
^
scala> implicit val x = new Writes[(Int, Int)] {
| def writes(t: (Int, Int)): JsValue = {
| JsArray(Seq(JsNumber(t._1), JsNumber(t._2)))
| }
| }