Unable to find a compiler officially supported by v8.
brew install v8
bundle config build.libv8 --with-system-v8
bundle
@nathancolgate / www.nathancolgate.com
I needed mustache.js to iterate over a list in groups of 2 to take advantage of Twitter Bootstraps "row" and "span" classes. Here is how I got it done (using jQuery).
$.fn.inGroupsOf = function( countPerGroup, groupName ) { var groups = [], offset = 0, $group, jsonOptions; while ( ($group = this.slice( offset, (countPerGroup + offset) )).length ) { jsonOptions = {}; jsonOptions[groupName] = $group.toArray(); groups.push( jsonOptions ); offset += countPerGroup; } return groups; }; var renderEmailImageCategories = function(email_image_categories){ $.each(email_image_categories, function(index, email_image_category) { email_image_category.image_groups = function() { return $(this.images).inGroupsOf(2,'images'); }; }); template = $.mustache('{{#email_image_categories}}<h4>{{name}}{{^name}}My Images{{/name}}</h4>{{#image_groups}}<div class="row">{{#images}}{{#.}}<a href="#" class="email_image_link" data-id="{{id}}" data-url="{{file.span3.url}}"><img src="{{file.span3.url}}" class="span3" style="margin-bottom:1em;" /></a>{{/.}}{{/images}}</div>{{/image_groups}}{{/email_image_categories}}',{"email_image_categories": email_image_categories}); $('#custom_email_image_body').html(template); };
$ curl -v -H "X-Auth-User: <your_rackspace_username>" -H "X-Auth-Key: <your_rackspace_api_key>" https://auth.api.rackspacecloud.com/v1.0 * About to connect() to auth.api.rackspacecloud.com port 443 (#0) * Trying 67.192.1.11... connected * Connected to auth.api.rackspacecloud.com (67.192.1.11) port 443 (#0) * SSLv3, TLS handshake, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS handshake, Server finished (14): * SSLv3, TLS handshake, Client key exchange (16): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSL connection using RC4-SHA * Server certificate: * subject: C=US; O=auth.api.rackspacecloud.com; OU=GT47404894; OU=See www.geotrust.com/resources/cps (c)09; OU=Domain Control Validated - QuickSSL(R); CN=auth.api.rackspacecloud.com * start date: 2009-07-10 11:34:54 GMT * expire date: 2014-07-11 02:57:59 GMT * common name: auth.api.rackspacecloud.com (matched) * issuer: C=US; O=Equifax; OU=Equifax Secure Certificate Authority * SSL certificate verify ok. > GET /v1.0 HTTP/1.1 > User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5 > Host: auth.api.rackspacecloud.com > Accept: */* > X-Auth-User: <your_rackspace_username> > X-Auth-Key: <your_rackspace_api_key> > < HTTP/1.1 204 No Content < Server: Apache/2.2.3 (Red Hat) < vary: X-Auth-User,X-Auth-Key,X-Storage-User,X-Storage-Pass < X-Storage-Url: <your_x_storage_url> < Cache-Control: s-maxage=84787 < Content-Type: text/xml < Date: Wed, 02 Jan 2013 19:05:23 GMT < X-Auth-Token: <your_x_auth_token> < X-Server-Management-Url: <your_x_server_management_url> < X-Storage-Token: <your_x_storage_token> < Connection: Keep-Alive < X-CDN-Management-Url: <your_x_cdn_management_url> < Content-Length: 0 < * Connection #0 to host auth.api.rackspacecloud.com left intact * Closing connection #0 * SSLv3, TLS alert, Client hello (1): $ curl -X POST -H "X-Auth-Token: <your_x_auth_token>" -H "X-Account-Meta-Temp-Url-Key: <your_rackspace_temp_url_key>" <your_x_storage_url>
1. Delete the SSH keys from your current account:
$ heroku keys:clear
You have to clear these first because Heroku won’t allow two accounts to have the same SSH key.
2. Delete your locally stored credentials:
$ rm ~/.heroku/credentials
3. Re-enter your (new) credentials by entering any command that requires access to an account, e.g.:
$ heroku create
Enter your Heroku credentials.
Email: my@email.com
Pass: mypass
The command line utility will record your new credentials in your ~/.heroku/credentials file and automatically add your machine’s SSH key. If you hadn’t deleted the key from your other account, it would complain about multiple accounts using the same key.
As my rails apps get more complex, I find myself spending more time getting them booted up. While this may not be a big deal for you, my early morning brain doesn't do well with it.
After a bit of searching I found some code for launching rails server in a new terminal tab, opening text mate, launching delayed job in a new terminal tab, and opening the browser.
I put this in a file called rock_and_roll.sh in my Rails.root folder:
#!/bin/sh osascript -e 'tell application "Terminal"' \ -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \ -e "do script with command \"cd ~/path/to/my/app/;rails server;\" in selected tab of the front window" \ -e 'end tell' &> /dev/null osascript -e 'tell application "Terminal"' \ -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \ -e "do script with command \"cd ~/path/to/my/app/;rake jobs:work;\" in selected tab of the front window" \ -e 'end tell' &> /dev/null mate . open http://localhost:3000
Then all I gotta do:
$ cd /path/to/my/app/ $ . rock_and_roll.sh
The key here is to convert the x and y deltas into translate values, which the path object understands.
jQuery(function () { var startPath = function () { // path coordinates are best kept as relative distances // so that you can use the built in translate method this.ox = 0; this.oy = 0; }, movePath = function (dx, dy) { // move is called with dx and dy, which we convert // into translate values, which are reset at the end // of the function var trans_x = dx-this.ox; var trans_y = dy-this.oy; this.translate(trans_x,trans_y); this.ox = dx; this.oy = dy; }, upPath = function () { // nothing special }; var fly_paper = Raphael('application',500,500); var fly_path = "M28.589,10.903l-5.828,1.612c-0.534-1.419-1.338-2.649-2.311-3.628l3.082-5.44c0.271-0.48,0.104-1.092-0.38-1.365c-0.479-0.271-1.09-0.102-1.36,0.377l-2.924,5.162c-0.604-0.383-1.24-0.689-1.9-0.896c-0.416-1.437-1.652-2.411-3.058-2.562c-0.001-0.004-0.002-0.008-0.003-0.012c-0.061-0.242-0.093-0.46-0.098-0.65c-0.005-0.189,0.012-0.351,0.046-0.479c0.037-0.13,0.079-0.235,0.125-0.317c0.146-0.26,0.34-0.43,0.577-0.509c0.023,0.281,0.142,0.482,0.352,0.601c0.155,0.088,0.336,0.115,0.546,0.086c0.211-0.031,0.376-0.152,0.496-0.363c0.105-0.186,0.127-0.389,0.064-0.607c-0.064-0.219-0.203-0.388-0.414-0.507c-0.154-0.087-0.314-0.131-0.482-0.129c-0.167,0.001-0.327,0.034-0.481,0.097c-0.153,0.063-0.296,0.16-0.429,0.289c-0.132,0.129-0.241,0.271-0.33,0.426c-0.132,0.234-0.216,0.496-0.25,0.783c-0.033,0.286-0.037,0.565-0.009,0.84c0.017,0.16,0.061,0.301,0.094,0.449c-0.375-0.021-0.758,0.002-1.14,0.108c-0.482,0.133-0.913,0.36-1.28,0.653c-0.052-0.172-0.098-0.344-0.18-0.518c-0.116-0.249-0.263-0.486-0.438-0.716c-0.178-0.229-0.384-0.41-0.618-0.543C9.904,3.059,9.737,2.994,9.557,2.951c-0.18-0.043-0.352-0.052-0.516-0.027s-0.318,0.08-0.463,0.164C8.432,3.172,8.318,3.293,8.23,3.445C8.111,3.656,8.08,3.873,8.136,4.092c0.058,0.221,0.181,0.384,0.367,0.49c0.21,0.119,0.415,0.138,0.611,0.056C9.31,4.556,9.451,4.439,9.539,4.283c0.119-0.21,0.118-0.443-0.007-0.695c0.244-0.055,0.497-0.008,0.757,0.141c0.081,0.045,0.171,0.115,0.27,0.208c0.097,0.092,0.193,0.222,0.286,0.388c0.094,0.166,0.179,0.368,0.251,0.608c0.013,0.044,0.023,0.098,0.035,0.146c-0.911,0.828-1.357,2.088-1.098,3.357c-0.582,0.584-1.072,1.27-1.457,2.035l-5.16-2.926c-0.48-0.271-1.092-0.102-1.364,0.377C1.781,8.404,1.95,9.016,2.43,9.289l5.441,3.082c-0.331,1.34-0.387,2.807-0.117,4.297l-5.828,1.613c-0.534,0.147-0.846,0.699-0.698,1.231c0.147,0.53,0.697,0.843,1.231,0.694l5.879-1.627c0.503,1.057,1.363,2.28,2.371,3.443l-3.194,5.639c-0.272,0.481-0.104,1.092,0.378,1.363c0.239,0.137,0.512,0.162,0.758,0.094c0.248-0.068,0.469-0.229,0.604-0.471l2.895-5.109c2.7,2.594,5.684,4.123,5.778,1.053c1.598,2.56,3.451-0.338,4.502-3.976l5.203,2.947c0.24,0.138,0.514,0.162,0.762,0.094c0.246-0.067,0.467-0.229,0.603-0.471c0.272-0.479,0.104-1.091-0.377-1.362l-5.701-3.229c0.291-1.505,0.422-2.983,0.319-4.138l5.886-1.627c0.53-0.147,0.847-0.697,0.696-1.229C29.673,11.068,29.121,10.756,28.589,10.903z"; var fly; fly = fly_paper.path(fly_path); fly.translate(250,250); fly.scale(4, 4); fly.attr({ 'stroke-width': 0, 'fill': '#cccccc', 'fill-opacity': 1.0 }); fly.drag(movePath, startPath, upPath); });