Skip to content

Instantly share code, notes, and snippets.

class CreateIdentities < ActiveRecord::Migration
def change
create_table :identities do |t|
t.string :provider
t.string :uid
t.integer :user_id
t.timestamps null: false
end
@IvikGH
IvikGH / deploy_rails_ubuntu.sh
Last active August 29, 2015 14:26 — forked from ssuprunenko/deploy_rails_ubuntu.sh
Deploy Ruby on Rails app to Digital Ocean droplet
for Manual
Manual:
ssh root@xxx.xxx.xx.xx
1. Fix locale issue
$ sudo nano /etc/default/locale
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LC_TYPE=en_US.UTF-8
@IvikGH
IvikGH / Rakefile
Last active August 26, 2015 10:00 — forked from barrettclark/Rakefile
Example file download rake task
require 'rake'
# http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html
require 'net/http'
desc "this is a test"
task :testing_rake do
puts "Hello from rake!"
end
namespace :remote_file do
@IvikGH
IvikGH / Slim for loop
Last active August 28, 2015 19:54 — forked from beausmith/Slim for loop
Iterating through an array using a for loop in slim lang template
- for i in (1..5)
div #{i}
- for i in [0,4,8,12,16,20,24] do
div #{i} #{i + -12}
- if (i == 0)
div 0
- elsif (i < 12)
div lt 12
- else
@IvikGH
IvikGH / gist:1cb03a007a05bfb11271
Created October 24, 2015 10:32 — forked from vickys/gist:3212425
Changing repository URL from github to bitbucket, could not parse error from Capistrano
rm -rf shared/cached-copy
@IvikGH
IvikGH / mechanize_with_proxy_and_basicauth.rb
Created January 17, 2016 15:47 — forked from emergent/mechanize_with_proxy_and_basicauth.rb
Using mechanize with proxy and basic auth
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
agent.set_proxy('proxy.example.com', 80, 'username', 'password')
agent.add_auth('http://hoge.com','b_username','b_password')
agent.user_agent_alias = "Windows Mozilla"
res = agent.get('http://hoge.com/some/page')
puts res.body
@IvikGH
IvikGH / app datatables products_datatable.rb
Created February 1, 2016 12:38
Need HELP with 340 RailsCast
class ProductsDatatable
delegate :params, :h, :link_to, :number_to_currency, to: :@view
def initialize(view)
@view = view
end
def as_json(options = {})
{
sEcho: params[:sEcho].to_i,
require 'mechanize'
def google_search(query_text)
agent=Mechanize.new
goog = agent.get "http://www.google.com"
search = goog.form_with(:action => "/search")
search.field_with(:name => 'q').value = query_text
results = search.submit
return results
end
@IvikGH
IvikGH / Ruby_finance_testcase.md
Created March 5, 2016 10:43 — forked from beshkenadze/Ruby_finance_testcase.md
Тестовое задание для Ruby-разработчика

Задание

Реализовать на Ruby с использованием Rails приложение со следующим функционалом:

  1. Регистрация / авторизация пользователей.
  2. Создание портфеля акций (5-6 акций достаточно) для пользователя: стандартный CRUD.
  3. Данные должны скачиваться с Yahoo Finance.
  4. Сделать вывод графика "стоимость портфеля от времени" за 2 последних года по выбранным в п.2 акциям.

Требования

@IvikGH
IvikGH / capybara.md
Created March 15, 2016 09:36 — forked from steveclarke/capybara.md
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)