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
$timeout(function() { | |
if (!$scope.promiseComplete && $scope.submitted) { | |
$scope.message = { | |
content: [{ | |
title: '', | |
msg: 'Service down - created' | |
}], | |
type: 'error' | |
}; | |
$timeout(function() { |
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
focusOn = ($timeout) -> | |
link = (scope, element, attrs) -> | |
scope.$watch attrs.focusOn, (newValue) -> | |
$timeout(-> element.focus()) if !!newValue | |
restrict: 'A' | |
link: link | |
focusOn.$inject = ['$timeout'] |
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
editInPlace = -> | |
restrict: 'A' | |
require: 'ngModel' | |
scope: | |
onSuccess: '&' | |
link: (scope, element, attrs, ngModelCtrl) -> | |
originalValue = ngModelCtrl.$modelValue | |
element.focus -> | |
originalValue = ngModelCtrl.$modelValue |
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 Guest(session) { | |
this.session = session; | |
this.name = "Anonymous"; | |
this.avatar = session.avatar || "https://api.adorable.io/avatars/128/" + Math.random(); | |
session.avatar = this.avatar; | |
} | |
Guest.prototype.getCart = function() { | |
this.cart = this.cart || Cart.find(this.session.cartId) || Cart.create(); | |
return cart; |
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
# https://www.hackerrank.com/contests/worldcodesprint/challenges/print-string | |
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
require 'set' | |
t = gets.strip.to_i | |
class TestCase < Struct.new(:a, :b, :string); end | |
test_cases = [] |
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
#!/bin/ruby | |
# https://www.hackerrank.com/contests/worldcodesprint/challenges/colorful-ornaments | |
require 'set' | |
A,B,C,D = gets.strip.split(' ').map(&:to_i) | |
RR = %w(R R) | |
RB = %w(R B) | |
BB = %w(B B) |
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
# https://www.hackerrank.com/contests/worldcodesprint/challenges/two-pluses | |
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
N, M = gets.strip.split(' ').map(&:to_i) | |
GOOD = 'G' | |
class Plus < Struct.new(:x, :y, :length); end | |
def print_grid(grid) | |
puts grid.map(&:join) |
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
#!/bin/ruby | |
# https://www.hackerrank.com/contests/worldcodesprint/challenges/powerplants-in-flatland | |
n,m = gets.strip.split(' ') | |
n = n.to_i | |
m = m.to_i | |
c = gets.strip | |
c = c.split(' ').map(&:to_i) | |
max_distance = 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
#!/bin/ruby | |
# https://www.hackerrank.com/contests/worldcodesprint/challenges/save-our-ship | |
S = gets.strip | |
wrong_letters = 0 | |
SOS = "SOS" | |
S.each_char.each_slice(3) do |sos| | |
wrong_letters += sos.each_with_index.select { |char, i| char != SOS[i] }.length |
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
teste |