Ecto is an DSL for writing queries and interacting with databases in Elixir. It has a style similar to ActiveRecord, but since there aren’t objects, you can’t really call it an ORM.
Like ActiveRecord, it has
belongs_to, but it doesn’t have
has_many :through yet. Here is how I implemented a DAG using a many-to-many join in Ecto anyways
The basic idea is I have a Nodes table. And each Node can have multiple parents and multiple children. The most straightforward implementation of this is to have a many-to-many join table and then use that with INNER JOIN to query for parents or children.
First, I needed to create the tables using Ecto’s migration feature.
Then I define the models using the Ecto model DSL.
This wasn’t quite enough though. I ran into trouble getting Node to preload its children and parents via NodeToNode. I ended up adding help functions to the Node module.
This now lets me write an association.
This works as far as I can tell with my unittests. I’m not completely comfortable with Ecto’s association proxy, so there might be a better way to do this that is more idiomatic. I hope that
has_many :through support is added soon so I can concentrate on my business logic instead of mundane joins. I think more documentation of reading and writing associations is necessary.
If you know a better way to express this, please let me know.
So far, I haven’t actually had that much HTML to include, but hopefully that will change as my project takes shape and grows.
Now I just need to find something to do the same for SASS.
(This was a quick write up for a coworker, but others might find it useful)
This assumes you have XCode. I mean, really now.
First thing to do is install mac homebrew. It’s a package manager of useful open source software. You install it by pasting into the terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
then just to make sure it’s working, run:
brew install -v git
Next we want to install the node package manager.
It’s a simple
curl http://npmjs.org/install.sh | sh
Lastly, I like to setup rvm, for managing multiple ruby installations and keeping my base machine clean of stray gems.
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
RVM is a little more complicated since you also have to add a little something to your shell file so that the paths are loaded correctly
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
That's *about* it. I'm still looking into how to setup the RVM equivalent for python, but it seems that community is still figuring out their tools and a clear solution hasn't emerged yet.
After you install it, and launch iChat, it’ll run the iChat config program. After that, it’ll ask you about syncing your Address Book. Don’t do this. I just lost all my contacts from my address book. It then deleted them from my iPhone.
All in all, this hasn’t been a good week between me and Apple.
If you are trying to register a callback on getting a URL passed to your program through AppleEvents, don’t use the documented kAEInternetSuite and kAEISGetURL enums. They are defined as ‘gurl’, but the actual value passed to your program is ‘GURL’. From what I can tell, everyone defines their own enums because this is well known.
Apple can’t fix it though, because it would break everyone’s software. So they keep documenting it as ‘gurl’, and we keep redefining it to the actual value.
I had a hard time finding a definitive statement on MacOS X memory alignment so I did my own tests. On 10.4/intel, both stack and heap memory is 16 byte aligned. So people porting software can stop looking for memalign() and posix_memalign(). It’s not needed.
If you are trying to compile fftw3 on an intel iMac (or any Intel Core processor probably), you’ll need to pass to configure:
That will prevent compiler errors complaining about illegal i386 instructions.