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 JSON.pretty_generate(PresenceSerializer.new(Presence.first).serializable_hash) |
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 self.to_google_params(params) | |
| def self.map_it(hash, mappings) | |
| sliced_hash = hash.slice(*mappings.keys) | |
| Hash[sliced_hash.map {|k, v| [mappings[k], v] }] | |
| end | |
| # Our style is exclude = true. Google's is include = true. So we need to invert the value. | |
| params[:privacy] = !params[:privacy] if params.has_key? :privacy | |
| {}.tap do |google_params| |
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
| # add newer versions to this array if the method definition didn't change, otherwise do an if-cascade | |
| if ['0.7.0'].include?(I18n::VERSION) | |
| module I18n | |
| module Backend | |
| class Simple | |
| # Monkey-patch-in localization debugging.. ( see: http://www.unixgods.org/~tilo/Rails/which_l10n_strings_is_rails_trying_to_lookup.html ) | |
| # Enable with ENV['I18N_DEBUG']=1 on the command line in server startup, or ./config/environments/*.rb file. | |
| # | |
| def lookup(locale, key, scope = [], options = {}) | |
| init_translations unless initialized? |
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
| Devise.stretches = 1 | |
| User.find_each do |user| | |
| user.password = 'q1w2e3r4' | |
| user.save | |
| end | |
| Devise.stretches = 10 |
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
| test "Sebastian commented on Matylda's gallery: Looks awesome!", (assert) -> | |
| assert.expect 1 | |
| commenter = Ember.Object.create( # mock for Ember DS.Model | |
| displayName: "Sebastian" | |
| ) | |
| galleryOwner = Ember.Object.create( | |
| id: 2, | |
| displayName: "Matylda" | |
| ) |
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 solution(n) | |
| binary_array = to_binary(n) | |
| i = 0 | |
| j = 0 | |
| max = 0 | |
| counter = 0 | |
| while i < binary_array.size - 1 |
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 solution(a) | |
| hash = {} | |
| a.each do |element| | |
| if hash[element].nil? | |
| hash[element] = 1 | |
| else | |
| hash[element] += 1 | |
| 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
| def solution(a) | |
| ((1..a.size + 1).to_a - a).first | |
| 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
| def solution(a) | |
| sum = 0 | |
| sum = a.inject(&:+) | |
| l = 0 | |
| r = 0 | |
| p = 0 | |
| ret = nil | |
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 solution(a) | |
| # write your code in Ruby 2.2 | |
| i = 1 | |
| hash = {} | |
| a.each do |element| | |
| hash[element] = 1 | |
| end | |
| while 1 do |
OlderNewer