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
| sudo apt-get update | |
| sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y | |
| sudo apt-get install libfreetype6 libfreetype6-dev -y | |
| sudo apt-get install libfontconfig1 libfontconfig1-dev -y | |
| cd ~ | |
| export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" | |
| wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2 | |
| sudo tar xvjf $PHANTOM_JS.tar.bz2 | |
| sudo mv $PHANTOM_JS /usr/local/share | |
| sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/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
| [23] pry(main)> n = 42 | |
| => 42 | |
| [24] pry(main)> x1,x2 = 0, 1 | |
| => [0, 1] | |
| [25] pry(main)> result = [] | |
| => [] | |
| [26] pry(main)> 0.upto(n) { |i| puts i; result << x1; x1+=x2; x1,x2= x2,x1} | |
| 0 | |
| 1 | |
| 2 |
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
| class ValidatedUser < ActiveRecord::Base | |
| validates_each :name do |record, attr, value| | |
| hash = User.parse_name(value) | |
| record.errors.add attr, 'must have a first and last name' if | |
| ( hash[:first_name].nil? || hash[:last_name].nil? ) | |
| end | |
| 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
| # check if hash a include hash b: | |
| [72] pry(main)> [true, false, false, true].reduce(:&) | |
| => false | |
| [73] pry(main)> [true, false, false, true].reduce(:|) | |
| => true | |
| [74] pry(main)> a = {k1: 1, k2: 23, k3: 44} | |
| => {:k1=>1, :k2=>23, :k3=>44} | |
| [75] pry(main)> b = {k1: 1, k2: 23} |
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
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
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
| # Returns the 20 most recent Tweets posted by the specified user | |
| # | |
| # @see https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline | |
| # @note This method can only return up to 3,200 Tweets. | |
| # @rate_limited Yes | |
| # @authentication Requires user context | |
| # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. | |
| # @return [Array<Twitter::Tweet>] | |
| # @overload user_timeline(user, options = {}) | |
| # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object. |
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 LinkedIn | |
| module Helpers | |
| module Request | |
| DEFAULT_HEADERS = { | |
| 'x-li-format' => 'json' | |
| } | |
| API_PATH = '/v1' |
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 'openssl' | |
| module AESCrypt | |
| # Decrypts a block of data (encrypted_data) given an encryption key | |
| # and an initialization vector (iv). Keys, iv's, and the data | |
| # returned are all binary strings. Cipher_type should be | |
| # "AES-256-CBC", "AES-256-ECB", or any of the cipher types | |
| # supported by OpenSSL. Pass nil for the iv if the encryption type | |
| # doesn't use iv's (like ECB). | |
| #:return: => String |
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
| map.namespace :admin do |admin| | |
| admin.root :controller => "news", :action => "index" | |
| admin.resources :addressable_menu_node, :active_scaffold => true | |
| admin.resources :company, :active_scaffold => true | |
| admin.resources :credit, :active_scaffold => true | |
| admin.resources :contributor, :active_scaffold => true | |
| admin.resources :event, :active_scaffold => true | |
| admin.resources :featured_book, :active_scaffold => true | |
| admin.resources :list_page, :active_scaffold => true | |
| admin.resources :location, :active_scaffold => true |
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
| <tr class="subscription_play_row"> | |
| <% fields_for_donation2013_event_line(donation2013_event_line) do |d| %> | |
| <% available_tickets = d.object.donation2013_event.available_tickets %> | |
| <td> | |
| <%= d.hidden_field :donation2013_id %> | |
| <%= d.hidden_field :donation2013_event_id %> | |
| <div class="label_champ_large"><%= d.object.donation2013_event.description %></div> | |
| <div class="label_champ_small"> | |
| <% options = ((available_tickets < 4)) ? {:disabled => 'disabled'} : {} %> |
NewerOlder