Skip to content

Instantly share code, notes, and snippets.

View merqlove's full-sized avatar

Alexander Merkulov merqlove

View GitHub Profile
@merqlove
merqlove / sinatra_schemata.rb
Last active August 29, 2015 14:02
Domain based scheme selection in Sinatra via Postgres-Schemata extension for Sequel.
before do
case env["SERVER_NAME"]
when /test\./
App.db.search_path = [:test, :public]
when /test2\./
App.db.search_path = [:test2, :public]
else
App.db.search_path = [:public]
end
end
@merqlove
merqlove / base_mailer.rb
Last active August 29, 2015 14:01
Sinatra Mailer, similar with Rails :)
module Project
module Mailers
class BaseMailer < Sinatra::Mailer::Base
default from: ENV["MAIL_FROM"] || 'localhost', content_type: 'text/html'
class << self
def feedback!(text, email = nil, name='')
mail(to: "[email protected]", subject: 'Feedback', body: text) do
reply_to "#{name}<#{email}>" if email.present?
end
@merqlove
merqlove / app.rb
Created January 28, 2014 01:22 — forked from hendrikswan/app.rb
require 'sinatra'
require 'mongoid'
require 'json'
require "sinatra/reloader" if development?
Mongoid.load!("mongoid.yml")
class Price
include Mongoid::Document
#!/usr/bin/env bash
set -o errtrace
set -o errexit
facter_version=$1
puppet_version=$2
target_volume=$3

ruby-1.9.3 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird and Slayer who I forked this from.)

From merqlove:

I just made little improvement to this fix:

Now you can select Ruby BUILD via same name variable. Otherwise build version will be used by default.

@merqlove
merqlove / puma.rb
Last active December 28, 2015 06:39
Another one Puma shell script. Here i can set path to Puma config. Very useful for multiple environments.
# Capistrano 3 tasks for Puma
namespace :puma do
%w[start stop restart status].each do |command|
desc "#{command} puma"
task command do
on roles (:app) do
within current_path do
execute "bin/puma.sh", "#{command} -c config/puma/#{fetch(:stage)}.rb"
@merqlove
merqlove / vagrant_berkshelf.sh
Last active December 27, 2015 02:09
Vagrant-Berkshelf plugin installation on Mac OS X 10.9.
#!/bin/bash
$ sudo vagrant plugin install vagrant-berkshelf && sudo chown -R "$USER":staff ~/.vagrant.d/*