Skip to content

Instantly share code, notes, and snippets.

View sshkarupa's full-sized avatar

Sergey Shkarupa sshkarupa

View GitHub Profile
@sshkarupa
sshkarupa / production.rb
Last active February 27, 2016 09:19 — forked from vkurennov/production.rb
Пример конфига unicorn
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "/tmp/unicorn.qna.sock", backlog: 64
# logging
stderr_path "log/unicorn.stderr.log"
@sshkarupa
sshkarupa / capybara cheat sheet
Created December 11, 2015 20:26 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=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')
@sshkarupa
sshkarupa / puzzles.rb
Last active September 4, 2015 11:41 — forked from hrumhrumble/puzzles.rb
# В системе авторизации есть ограничение:
# логин должен начинаться с латинской буквы,
# состоять из латинских букв, цифр, точки и минуса,
# но заканчиваться только латинской буквой или цифрой;
# минимальная длина логина — один символ, максимальная — 20.
# Напишите код, проверяющий соответствие входной строки этому правилу. Придумайте несколько способов решения задачи и сравните их.
class AuthOne
def initialize login
@login = login
@sshkarupa
sshkarupa / sinatra_jquery_test.rb
Last active August 29, 2015 14:26 — forked from mr-rock/sinatra_jquery_test.rb
An example of Sinatra working with Ajaxified JQuery based on some pieces of code published by Rafael George on the Sinatra Google Group.
require 'sinatra'
require 'dm-core'
require 'haml'
DataMapper.setup(:default, 'sqlite3::memory:')
class Message
include DataMapper::Resource
property :id, Serial
@sshkarupa
sshkarupa / xhr.rb
Last active August 29, 2015 14:26 — forked from aaronmoodie/gist:1308100
Sinatra: render template partial without layout when requested va Ajax
if request.xhr?
# renders :template_partial without layout.html
slim :template_partial, :layout => false
else
# renders as normal inside layout.html
slim :template_partial
end
# Place this file inside your ~/.idlerc/ folder
# or paste its contents inside
# /path/to/python/idlelib/config-highlight.def
# Adapted from SublimeText's Monokai
[monokai]
normal-foreground= #F8F8F2
normal-background= #272822
keyword-foreground= #F92672
keyword-background= #272822