Skip to content

Instantly share code, notes, and snippets.

View oleksiilevzhynskyi's full-sized avatar

Oleksii Levzhynskyi oleksiilevzhynskyi

View GitHub Profile
sudo apt-get install unzip;
wget -O /tmp/chromedriver.zip http://chromedriver.googlecode.com/files/chromedriver_linux64_19.0.1068.0.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/;
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests

#Quiz:

  1. What’s the result of:

     function A() {}
     A.prototype.name = 'A';
    
     var a = new A();
     var b = new A();
    

#Quiz:

  1. What’s the result of:

     console.log(f());
     function f() {
         return 1;
     }
    

Answers:

Answer this questions to check you general understanding of the topic:

Quiz:

  1. How do you write a conditional statement for executing some code if i is equal to 5?

    • if (i==5)
    • if i=5
    • if i=5 then
    • if i==5 then
  2. What is an array?

@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:2690092
Created May 13, 2012 20:44 — forked from gnepud/gist:1429965
Launch Pry in Rails project
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
if Rails.version[0..0] == "2"
require 'console_app'
@oleksiilevzhynskyi
oleksiilevzhynskyi / 0-readme.md
Created April 17, 2012 08:29 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@oleksiilevzhynskyi
oleksiilevzhynskyi / capybara_webkit_screenshot_env.rb
Created April 6, 2012 11:46 — forked from mattheworiordan/capybara_webkit_screenshot_env.rb
Cucumber and Capybara-Webkit automatic screenshots on failure
def screen_shot_and_save_page
require 'capybara/util/save_and_open_page'
path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
Capybara.save_page body, "#{path}.html"
page.driver.render Rails.root.join "#{Capybara.save_and_open_page_path}" "#{path}.png"
end
begin
After do |scenario|
screen_shot_and_save_page if scenario.failed?
@oleksiilevzhynskyi
oleksiilevzhynskyi / rails31init.md
Created February 9, 2012 09:29
Rails 3.1 with Rspec, Capybara, Factory Girl, Haml

Set up Gemfile

# in Gemfile

gem 'rails', '3.1.1'

gem 'haml'
gem 'haml-rails', :group => :development
(function($) {
$.cookieEnabled = function () {
var key = 'testCookieEnabled';
var value = '1';
$.cookie(key, value, { path: '/' });
return $.cookie(key) == value;
};
$(document).ready(function(){
if( !$.cookieEnabled() ) {