Listen to Midnight by Dstllry Music.
(defn recursive-reverse [coll] (loop [coll coll acc '() ] (if (= (count coll) 0) acc (recur (rest coll) (cons (first coll) acc)) ) ) )
I struggled with this one for a while - I don’t want to admit it, but honestly even though i have been coding since I was 16 years old - there are still many areas where I am rusty or weak.
There is actually a surprising amount of low level concepts operating in a list recursive reverse in clojure.
- tail-call recursion
- loop construct
I think I need to make sure that I always remember the following :
- the arity of the recur call must match the arity of the loop form
- recur must be in the tail position.
I’m not sure how this loop / recur mechanism is implemented in the JVM - I imaging that the binding created by ‘loop’ is associated with registers that are overwritten as part of the call to ‘recur’. The documentation says the bindings are rebound on call of recur in parallel and the execution of recur - is done in order.
My questions are
- Is recur causing some kind of local jump after each binding?
- What happens with the return address?
- If recur doesn’t consume stack - what is going on with the return address?
- Is the return address always the same for the same recursive call?
More importantly - Is there a chapter in Knuth AOC that could help me with this? Any other resources?
I feel like I am really missing some context.
You can go fast, you can go smooth, but you are going to have to get out of thinking you can go fast and smooth - if you want to be really fast - you need to start with smooth [ Curtis Schofield : Racing Cars and Developing Software]
I’m currently playing with using a ‘column’ definition and then redeclaring it’s width for each device i’m supporting - tablet, desktop.
Using the ‘base’ unset media query as lowest common denominator.
I spent the last few days struggling with chef.
What can i tell you so that you need not have to have the same struggle.
What ended up confusing me the most:
Essentially ruby needs to exist on the server side - I use RVM because it is easy to script and i know it well enough. The client side Capistrano script expects the gem bundler to exist on the client side and to be part of the gemset described in Capistrano - this gemset is named ‘blazing_gemset_for_client_xxx’ for the purpose of this post.
[RVM + Chef-Solo ]:: Server Side -> responsible for bootstrapping a fresh ubuntu 10.10 LTS machine into complete ready state (DB+WEB)
[RVM + Capistrano ]:: Client Side -> cap production deploy should just work as it always does in the regular dev-cycle
Easy to start a new production machine from scratch
Developers do not need root to deploy
What is less than vanilla in our setup:
Had some legacy perl that expected to have apache.
What web stack did we choose :
What did I end up doing in the end
- Install apache as the same user as is running the rails app (avoid permission issues and isolate user from root )
- System Wide RVM
- Create Gemset and manually bootstrap bundler into the gemset
What I wish i could do differently
- Didn’t like having to couple the name ‘blazing_gemset_for_client_xxx’ (the rvm gemset that the capistrano script knows about) into the chef scripts
What I like about what was accomplished
- Implemented a Internet-friendly chef-solo bootstrap script
- Installed vim and my jan repo for nicer editing experience server side
- discovered the tricky part about capistrano + chef + rvm
What was in the way from taking a userland based approach for RVM
- Passenger is a server side component that requires a config file with pointers to ruby runtime - because of this - ‘client’ knowledge ended up embedded in the chef repository
- Capistrano assumes that a machine is setup in a particular configuration and it’s RVM support did not seem to include bootstrapping a gemset - event if it did - there would be more work to integrate it into passenger
- Unicorn runs in a different model and wouldn’t have encountered exactly this same issue
- There would still be the issues of coupling gemset name between Capistrano and chef - a detail that i think only one should know about.
- I have been a unix script banger since i was a teenager.
- I’ve been coding ruby since 2003 and rails since 2005.
- I’ve used Capistrano on pretty much every project.
- I deploy my node.js scripts with chef and it works ok.
- This is my second chef based machine rollout package and my first time integrating it with capistrano.
- I just started learning how to plie.
Footnote 1 :
I implemented a internet-hostile standalone chef-solo system for unpacking complete systems inside user accounts on lockdown intranet virtual machines as well - this was a build based solution and did not use rvm - but took a userland based ruby approach.
When using ’export’ a typo of ’exports’ will result in a warning that your functions are not used.
a function declaration seems to be a collection of ’,’ separated statements ending in a period.
If a process executes a function with a runtime error then an error report will be generated and the exit value, the error with it will be described.