Skip to content

Instantly share code, notes, and snippets.

View dmix's full-sized avatar

Daniel P. McGrady dmix

View GitHub Profile
<!-- _message.html.erb -->
<%= @message %>
#new.html.erb
<label>Username </label> <span class="string">&lt;%= f.text_field :username %&gt;&lt;span id="username_message" class="live_validation"&gt;&lt;/span&gt;</span>
<span class="string">&lt;%= observe_field :form_username,
:url =&gt; { :controller =&gt; :live_validations, :action =&gt; :validate_username },
:frequency =&gt; 0.5,
:update =&gt; :username_message,
:with =&gt; "username" %&gt;</span>
#new.html.erb
<label>Username </label>
<%= f.text_field :username %><span id="username_message" class="live_validation"> </span>
<%= observe_field :form_username,
:url => { :controller => :live_validations, :action => :validate_username },
:frequency => 0.5,
:update => :username_message,
:with => "username" %>
</span>
#new.html.erb
<label>Username </label>
<%= f.text_field :username %><span id="username_message" class="live_validation"> </span>
<%= observe_field :form_username,
:url => { :controller => :live_validations, :action => :validate_username },
:frequency => 0.5,
:update => :username_message,
:with => "username" %>
#application.css
.live_validation img { margin-bottom:3px; }
$$('div.fieldWithErrors').each(function(field) {
pageTracker._trackEvent('Form', 'Validation Error', field.down().identify());
});
<div class="fieldWithErrors">
<input id="question_8_street_address" name="question_8[street_address]" type="text" value="" />
</div><
<div class="fieldWithErrors">
<input id="question_8_street_address" name="question_8[street_address]" type="text" value="" />
</div>
def search_food(query)
base = "http://platform.fatsecret.com/rest/server.api"
key = "339df5xx11e42b3e7x3x1b21e7d12"
#added the extra & at the end of the secret
secret = "215ba9f90c6e4f41b23a149f322d2s7b1&"
timestamp = Time.now.to_i
signature_method="HMAC-SHA1"
nonce = rand(100)
method = "food.search"
// model
window.Medication = Backbone.Model.extend({
defaults: {
"user_id": "1002"
},
toJSON : function(){ return {
medication_option: _.clone(this.attributes)};
}
});