The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
| import 'dart:html'; | |
| import 'dart:async'; | |
| void main() { | |
| // Create the target element. | |
| DivElement menuSprite = new DivElement() | |
| ..style.height = "50px" | |
| ..style.width = "50px" |
The thing that students have the hardest time on when learning functional programming is how to process a recursive structure while maintaining some sort of "state", the result if you will. I'll attempt here to demystify the process.
Functional programming languages almost always use a lot of recursively defined structures. Depending on the language those can be implemented in various ways, but in any case the end result is the same. A structure of this type is either an "atom", i.e. an irreducible thing, or a "compound" consisting of substructures of the same form.
For example a "list" is either an Empty/Nil list (the "atom") or it is formed as a Cons of a value and another list (compound form). That other "sublist" can itself be empty or another cons and so on and so forth. A tree is similar. It is either empty, or it consists of a triple of a value and two sub-trees, left and right.
Almost every problem we encounter is a question about doing something with all entries in a structure. To solve these prob
| // Calendar | |
| // | |
| // Note: This calendar uses some ES6 features, so make sure that the code gets transpilled (f.e. with Babel) in the pipelane. | |
| // Also, there are no DI annotations, so it is recommended to use `gulp-ng-annotate` or equivalent. | |
| (function () { | |
| 'use strict'; | |
| angular | |
| .module('myModule') |
| // Model | |
| case class Thing(id: Option[Int], name: String) | |
| object Thing { | |
| implicit val fmt = Json.format[Thing] | |
| } | |
| class Things(tag: Tag) extends Table[Thing](tag, "thing") { | |
| def id = column[Int]("id", O.PrimaryKey, O.AutoInc) |
| dependencies: | |
| pre: | |
| - bin/create_github_statuses.sh | |
| test: | |
| post: | |
| - bundle exec rake factory_girl:lint | |
| - bundle exec rubocop --format html -o ${CIRCLE_ARTIFACTS}/rubocop_output.html | |
| - bundle exec brakeman -o ${CIRCLE_ARTIFACTS}/brakeman_output.json -o ${CIRCLE_ARTIFACTS}/brakeman_output.html | |
| - bundle exec rubycritic app lib --mode-ci --path ${CIRCLE_ARTIFACTS}/rubycritic/ |
ActiveModel useful tool that some developers tend to overlook when getting started developing with Rails but that, well used, can add a lot of clarity and convenience to the code in some cases.
The use case of ActiveModel to have a class that behave like an ActiveRecord model, but without DB persistence. That allows, just by importing ActiveModel into a regular Ruby class, to get a lot of useful features that usually belong only to Rails models. These features include validation, serialization, callbacks, attribute methods, etc.
ActiveModel is, somehow, still a bit obscure part of Rails, but the official Rails Guide has some useful examples where we can get a glimpse of how poweful it is.
The story of ActiveModel is interesting as well. Back in 2008 there was an important schism of Rails 2 when Ezra Zygmuntowicz and Yehuda Katz developed [Merb](https://en.wikipedia.org/wiki
| #!/bin/bash | |
| # Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/ | |
| set -e | |
| sourceApp="$1" | |
| targetApp="$2" | |
| while read key value; do |
I hereby claim:
To claim this, I am signing this object: