Skip to content

Instantly share code, notes, and snippets.

@jayuen
jayuen / gist:2937591
Created June 15, 2012 17:02
mongoid.yml for staging
staging:
database: app604162
username: <%= ENV['MONGO_USERNAME'] %>
password: <%= ENV['MONGO_PASSWORD'] %>
hosts:
- - staff.mongohq.com
- 10020
max_retries_on_conncection_failure: 30
2012-06-15T16:59:46+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:282:in `get_valid_seed_node': Cannot connect to a replica set using seeds staff.mongohq.com:10020 (Mongo::ConnectionFailure)
2012-06-15T16:59:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:158:in `connect_to_members'
2012-06-15T16:59:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:160:in `connect'
2012-06-15T16:59:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.5.2/lib/mongo/util/pool_manager.rb:30:in `connect'
2012-06-15T16:59:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:500:in `setup'
2012-06-15T16:59:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:144:in `initialize'
2012-06-15T16:59:46+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems
<script type="text/html">
<div>{{mustacheVar}}</div>

...

</script>
<script type="text/html">
<div>{{mustacheVar}}</div>

...

</script>
<script type="text/html">
<div>{{mustacheVar}}</div>

...

</script>
<script type="text/html">
<div>{{mustacheVar}}</div>

...

</script>
var data = [
{brand: 'Kraft', sites: [
{name: 'Strive Morris', integrated: false, jobs_per_day: 50},
{name: 'Strive Aurora', integrated: true, jobs_per_day: 100},
{name: 'Strive Westway', integrated: true, jobs_per_day: 25},
]},
{brand: 'Frito Lay', sites: [
{name: 'BCP', integrated: false, jobs_per_day: 2},
{name: 'Industrial', integrated: false, jobs_per_day: 5},
{name: 'ATCO', integrated: false, jobs_per_day: 10},
@jayuen
jayuen / gist:6338077
Last active December 21, 2015 17:08
Converting a local equivalent date into a DateWithTimezone
// generate a string that only has the time portion
var strWithoutTimezone = moment(localEquivalent).format("YYYY-MM-DDTHH:mm:ss")
// extract out the site's timezone identifier (DateWithTimezone.getTimezone() stores the site's timezone)
var timezone = moment.tz(DateWithTimezone.getTimezone()).format("Z")
// create a moment in the site's timezone and use it to initialize a `DateWithTimezone`
return new DateWithTimezone(moment(strWithoutTimezone + timezone))
@jayuen
jayuen / gist:6787780
Created October 2, 2013 01:22
DateWithTimezone
define("DateWithTimezone", function(module) {
var DateWithTimezone = function(moment){
this.moment = moment
moment.tz(DateWithTimezone.getTimezone())
}
_.extend(DateWithTimezone.prototype, {
toISO: function(){
return this.format()
},
@jayuen
jayuen / has_skus.rb
Last active December 26, 2015 09:19
def has_skus?
from_adjustment_has_sku? or to_adjustment_has_sku?
end
def from_adjustment_has_sku?
from_adjustment.try(:sku).present?
def to_adjustment_has_sku?
to_adjustment.try(:sku).present?
end