This file contains 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
#!/usr/bin/env ruby | |
# vim: set syntax=ruby | |
flag = false | |
files = `git diff --cached --name-only --diff-filter=ACM | grep "_spec\.rb$"`.split("\n") | |
files.each do |file| | |
patterns = ["focus:[ ]*true", ":focus[ ]*=>[ ]*true"] | |
patterns.each do |pattern| | |
results = `git diff --cached #{file} | grep "^\+[^+]" | grep "#{pattern}"`.split("\n").map { |r| r.sub(/^\+[\s\t]*/, '') } |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
build.xml with dead-simple project structure and ability to use JUnit. | |
This build.xml provides next directories structure: | |
. | |
├── build | |
│ ├── main | |
│ │ └── SomeClass.class | |
│ └── test |
This file contains 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
require 'set' | |
# Remove vowels from string | |
# Hash-solution with Ruby 2.3 | |
vowels = {'a' => true, 'e' => true, 'i' => true, 'o' => true, 'u' => true} | |
"cool test".chars.reject(&vowels).join #=> "cl tst" | |
# Set-solution could be in Ruby 2.3 :) | |
vowels = Set.new(%w[a e i o u]) |
This file contains 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
# Monkey patch ConnectionPool#checkout to avoid database connection timeouts | |
# Source: https://github.com/rails/rails/issues/2547 | |
# For Rails 3.2.0 and upper, You need to check if the pool error still occurs | |
if Rails.version < "3.3.0" | |
class ActiveRecord::ConnectionAdapters::ConnectionPool | |
def checkout | |
# Checkout an available connection | |
start_at = Time.now | |
@connection_mutex.synchronize do | |
loop do |
This file contains 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
description "Socket.IO worker" | |
instance $NUM | |
stop on stopping socketio | |
respawn | |
limit nofile 10000 10000 | |
respawn limit 99 5 | |
kill timeout 5 |
This file contains 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
("а".ord.."я".ord).map {|cp| cp.chr('UTF-8')} | |
# => ["а", "б", "в", "г", "д", "е", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я"] |
This file contains 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 User() { | |
this.name = 'Sasha'; | |
} | |
User.prototype.login = function() { | |
console.log("Hello, " + this.name); | |
}; | |
function Admin(self) { | |
if (self) { |
This file contains 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
require 'iconv' | |
utf8 = "123 abc привет" | |
utf8.each_codepoint {|cp| puts cp} | |
ucs4 = Iconv.iconv("UCS-4", "UTF-8", utf8).first | |
# s.pack("C*").unpack("N") - get 4bytes from array and pack them into string | |
# with 4 bytes and then unpack them into one 32bit number | |
ucs4.each_byte.each_slice(4) {|s| puts s.pack("C*").unpack("N")} |
This file contains 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
require 'psych' | |
require 'yaml' | |
yaml_config = <<-YAML | |
development: &common | |
encoding: utf-8 | |
database: dev-base | |
production: | |
<<: *common |
This file contains 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
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js | |
index 41217c7..fe09bc6 100644 | |
--- a/src/ngMock/angular-mocks.js | |
+++ b/src/ngMock/angular-mocks.js | |
@@ -1635,13 +1635,28 @@ window.jstestdriver && (function(window) { | |
window.jasmine && (function(window) { | |
+ var currentSpec = null, | |
+ isSpecRunning = function() { |