This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root = Node.create! | |
| child = Node.create!(:parent => root, :value => 12) | |
| grandchild = Node.create!(:parent => child) | |
| root.effective_value # nil | |
| child.effective_value # 12 | |
| grandchild.effective_value # 12 -- inherited from child | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActiveRecord::Schema.define do | |
| create_table :nodes, :force => true do |t| | |
| t.string :name | |
| t.string :value | |
| t.string :ancestry, :index => true | |
| end | |
| end | |
| class Node < ActiveRecord::Base | |
| has_ancestry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Records": [ | |
| { | |
| "EventSource": "aws:sns", | |
| "EventVersion": "1.0", | |
| "EventSubscriptionArn": "arn:aws:sns:us-east-1:XXX", | |
| "Sns": { | |
| "Type": "Notification", | |
| "MessageId": "XXX", | |
| "TopicArn": "arn:aws:sns:us-east-1:XXX", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var https = require('https'); | |
| var util = require('util'); | |
| var webhook = '/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'; | |
| exports.handler = function(event, context) { | |
| console.log(JSON.stringify(event, null, 2)); | |
| console.log('From SNS:', event.Records[0].Sns.Message); | |
| var postData = { | |
| "text": "*" + event.Records[0].Sns.Subject + "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BootstrapDialog.show({ | |
| title: 'Yo DAWG! A popup on your popup', | |
| message: function(dialog) { | |
| return $('<div>I heard you like that</div>'); | |
| }, | |
| buttons: [ | |
| { | |
| label: 'Close', | |
| cssClass: 'btn btn-default btn-sm', | |
| action: function(dialogItself){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BootstrapDialog.show({ | |
| title: 'Hello', | |
| message: 'I love this blog!' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| before 'deploy:started', "puma:phased-restart" | |
| after 'deploy:started', 'reenable_phased_restart' | |
| task :reenable_phased_restart do | |
| ::Rake.application['puma:phased-restart'].reenable | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| en: | |
| activerecord: | |
| attributes: | |
| issue: | |
| statuses: | |
| open: OMG A BUG | |
| closed: YAH, WE FIXED IT | |
| reopened: DOH! | |
| inprogress: WERKIN' ON IT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = form_for @issue do |form| | |
| = form.select :status, options_for_enum(Issue, :status, @issue), {:include_blank => true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module EnumHelper | |
| def enum_to_translated_option(klass, enum, enum_value, default = enum_value.to_s.titleize) | |
| key = "activerecord.attributes.#{klass.to_s.underscore.gsub('/', '_')}.#{enum}.#{enum_value}" | |
| translated = I18n.t(key, :default => default) | |
| end | |
| def enums_to_translated_options_array(klass, enum) | |
| enum_values = klass.send(enum) | |
| enum_values.map do |enum_value, db_value| | |
| translated = enum_to_translated_option(klass, enum, enum_value) |
NewerOlder