| #!/usr/bin/env ruby | |
| # This Rules file is an attempt at a near zero configuration for the common | |
| # use cases when creating a simple site with nanoc. It's meant to have | |
| # better defaults so new users don't have to configure it much if at all. | |
| # For the most part, it copies all files from the content folder to the | |
| # output folder with the same name. It has the following features: | |
| # | |
| # * Certain predefined page extensions such as html, haml, md, markdown and | |
| # textile are routed to "clean" URI's (see below regarding Item identifiers). |
Kris Nuttycombe asks:
I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?
I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.
I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.
It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:
>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
| # Original from Ox0dea - http://irclog.whitequark.org/ruby/2015-06-29#13259662; | |
| # Yes, it produces FizzBuzz | |
| _=$$/$$;__=_-_;@_=_+_;$_=@_+_;$__=@_+$_;$-_=$__*$_;@__=''<<$-_*($__+$_)+@_;$___=''<<$-_*$__-$__<<$-_*($__+@_)<<@__<<@__;@___=''<<$-_*$__-$_*$_<<$-_*($__+$_)-$_<<@__<<@__;(___=->____{$.+=_;____<<($.%$-_==__ ?$___+@___:$.%$_==__ ?$___:$.%$__==__ ?@___:$.);$.<($__*@_)**@_?___[____]:____})[[]] | |
| # Wtf!? Let's disect it then | |
| _ = $$ / $$ # PID / PID or 1 | |
| __ = _ - _ # 1 - 1 or 0 | |
| @_ = _ + _ # 1 + 1 or 2 |
| #[link(name = "logger")] | |
| extern { | |
| fn CrystalLog(text: *const u8); | |
| } | |
| fn log(text: &'static str) { | |
| unsafe{ CrystalLog(text.as_bytes().as_ptr()) }; | |
| } | |
| fn main() { |
| # gem install guard | |
| # gem install guard-process | |
| guard 'process', :name => 'Spec', :command => 'crystal spec' do | |
| watch(/spec\/(.*).cr$/) | |
| watch(/src\/(.*).cr$/) | |
| end | |
| guard 'process', :name => 'Build', :command => 'crystal build app.cr' do | |
| watch(/src\/(.*).cr$/) |
| FROM ruby:2.4 | |
| ADD Gemfile /opt/ | |
| ADD Gemfile.lock /opt/ | |
| WORKDIR /opt | |
| RUN bundle install | |
| CMD bundle exec nanoc -v |
| ///////////////////////////////////////////////////////////////////////////////// | |
| // Generating "A Sequence Problem" using iterators, without integers or arrays // | |
| // See http://raganwald.com/2017/06/04/sequences.html // | |
| ///////////////////////////////////////////////////////////////////////////////// | |
| ///////////////////////////////////////////////////////////////////// | |
| // Generic things useful for working with interables and iterators // | |
| ///////////////////////////////////////////////////////////////////// | |
| // 1. These operations produce repeatable iterables. |