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
| function locateMe() { | |
| var supportsLocation = function() { | |
| return 'geolocation' in navigator; | |
| } | |
| var geocoder = new google.maps.Geocoder(); | |
| var onError = function(error) { | |
| console.log(error); |
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
| 2012-03-10T14:15:47+00:00 app[web.1]: Completed 200 OK in 37ms (Views: 29.5ms | ActiveRecord: 0.0ms) | |
| 2012-03-10T14:15:47+00:00 app[web.1]: cache: [GET /berattelser] miss | |
| 2012-03-10T14:15:47+00:00 heroku[router]: GET host/berattelser dyno=web.1 queue=0 wait=0ms service=243ms status=304 bytes=0 | |
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
| REGEXP = %r{ | |
| \b | |
| ( | |
| (?: | |
| https?:// | |
| | | |
| www\d{0,3}[.] | |
| | | |
| [a-z0-9.\-]+[.][a-z]{2,4}/ | |
| ) |
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_save :hash_new_key, :if => :key_not_blank? | |
| def key_not_blank? | |
| !self.key.blank? | |
| end | |
| before_save :hash_new_key, :unless => :no_key? | |
| def no_key? | |
| self.key.blank? | |
| 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
| module Encryptor | |
| def encryptor(salt) | |
| ActiveSupport::MessageEncryptor.new(Digest::SHA1.hexdigest(salt + Configuration.encryption_salt)) | |
| end | |
| end | |
| class Thing | |
| include Encryptor | |
| def hash_new_key |
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
| def http_methods | |
| methods = Array.new | |
| methods << 'GET' if self.http_get | |
| methods << 'POST' if self.http_post | |
| methods << 'PUT' if self.http_put | |
| methods << 'DELETE' if self.http_delete | |
| methods << 'HEAD' if self.http_head | |
| methods | |
| 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
| module Blargh | |
| class Engine < Rails::Engine | |
| initializer 'blargh.authentication' do |app| | |
| ActiveSupport.on_load :action_controller do | |
| # loloololol | |
| end | |
| end | |
| end | |
| 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
| # Page has datums ( data[] ) | |
| # A datum can have datums (data[]) [sic!] | |
| # I need to pull a datum from page.data[0..infinity].data[something] == 'stuff' | |
| # Tried: | |
| Page.pull({}, { | |
| data: { | |
| data: { 'content_template_id' => some_id } | |
| } |
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
| puts $db.collection('pages').update({ 'data._type' => 'ContentBlock' }, { | |
| '$set' => { | |
| 'data.$.allow_texts' => true, | |
| 'data.$.allowed_asset_filetypes' => ['image'], | |
| 'data.$.allowed_page_template_ids' => page_template_ids | |
| } | |
| }, :multi => true, :safe => 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
| class Sku | |
| attr_reader :identifier | |
| attr_reader :price | |
| end | |
| class Cart | |
| many :cart_items | |
| def quantity | |
| cart_items.inject(0) { |quantity, item| quantity += item.quantity } |