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 applyToNew = function(Class, args) { | |
var F = function () {}; | |
F.prototype = Class.prototype; | |
var f = new F(); | |
Class.apply(f, args); | |
return f; | |
}; | |
applyToNew(SomeClass, arrayOfArguments); |
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
# encoding: utf-8 | |
require "test_notifier/runner/autotest" | |
class Autotest | |
alias :original_get_to_green :get_to_green | |
def get_to_green | |
original_get_to_green | |
rerun_all_tests | |
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
Then /url "([^"]*)" is opened in new window/ do |url| | |
browser = page.driver.browser | |
current_id = browser.window_handle | |
tab_id = page.driver.find_window(url) | |
browser.switch_to.window tab_id | |
page.driver.browser.close | |
browser.switch_to.window current_id | |
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
== ImportSql: migrating ====================================================== | |
Connected to database | |
- remove all tables from database | |
- import database from /Users/maksim/Projects/tabletennis-by/db/migrate/../tabletennis_onliner_tournament.sql | |
- rename/remove tables | |
- rename/remove/add columns | |
- create group for single games and remove extra columns | |
- delete relations for removed players | |
- apply group changes: | |
extract league id 6903/6903 |
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 InheritableAttributes | |
def self.included base | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def inheritable_attr *attrs | |
attrs.each do |attr| | |
class_eval <<-CODE | |
def self.#{attr} #{attr}=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
// Borrowed from http://stackoverflow.com/questions/5293174/creating-a-unique-id-from-an-array-of-strings-in-javascript | |
function getHashCode(str) { | |
var h1 = (5381 << 16) + 5381, h2 = h1, index = 0; | |
while (index < str.length) { | |
h1 = ((h1 << 5) + h1 + (h1 >> 27)) ^ str.charCodeAt(index); | |
if (index == str.length - 1) { | |
break; | |
} | |
h2 = ((h2 << 5) + h2 + (h2 >> 27)) ^ str.charCodeAt(index + 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
require "sass" | |
require "compass" | |
def compile_sass(sass_file) | |
sass_dir = File.dirname(sass_file) | |
compass_dir = File.join(Compass.base_directory, "frameworks/compass/stylesheets") | |
Sass.compile(File.read(sass_file), syntax: :sass, load_paths: [sass_dir, compass_dir]) | |
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
#!/bin/bash | |
# bash < <(curl -s https://gist.githubusercontent.com/fantactuka/3228898/raw/f0806a64306426ca72f16734ae7cd16c1f84bd87/update-chrome-driver.sh) | |
echo "Updating Chrome Driver" | |
sudo su | |
if [ -e /usr/bin/chromedriver ]; then | |
rm /usr/bin/chromedriver | |
echo "Removing current Chrome Driver from /usr/bin" |
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
// Hacking Jasmine: adding matchers outside beforeEach to speed up code | |
jasmine.addMatchers = function(matchers) { | |
var parentClass = jasmine.getEnv().matchersClass; | |
var matchersClass = function() { | |
parentClass.apply(this, arguments); | |
}; | |
jasmine.util.inherit(matchersClass, parentClass); | |
jasmine.Matchers.wrapInto_(matchers, matchersClass); | |
jasmine.getEnv().matchersClass = matchersClass; |
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
require "sinatra" | |
require "sinatra/async" | |
require "em-synchrony" | |
require "em-synchrony/em-http" | |
class App < Sinatra::Base | |
register Sinatra::Async | |
aget "/" do | |
Fiber.new { |
OlderNewer