Skip to content

Instantly share code, notes, and snippets.

View ozgg's full-sized avatar

Maxim Khan-Magomedov ozgg

View GitHub Profile
@ozgg
ozgg / rdoc-mail.txt
Created May 22, 2017 09:56
Output of rdoc --verbose for mail gem
developer@comunit:~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mail-2.6.5$ rdoc --verbose
Parsing sources...
0% [ 1/150] CHANGELOG.rdoc
1% [ 2/150] CONTRIBUTING.md
2% [ 3/150] Dependencies.txt
2% [ 4/150] Gemfile
3% [ 5/150] MIT-LICENSE
4% [ 6/150] README.md
4% [ 7/150] Rakefile
5% [ 8/150] TODO.rdoc
@ozgg
ozgg / .railsrc
Created April 11, 2017 13:47
Rails RC file
--database=postgresql --skip-test --skip-turbolinks
@ozgg
ozgg / search.scss
Created February 14, 2017 11:06
Extending search field
input[type=text] {
background: #fff image_url('comunit/base/icons/search.svg') no-repeat center right / 2.4rem 2.4rem;
border-radius: 1.4rem;
box-sizing: border-box;
box-shadow: 0 0 .5rem .5rem rgba(255, 255, 255, .5);
display: inline-block;
font-size: $normal_font_size;
height: 2.8rem;
line-height: 2.4rem;
margin: 0 .4rem;
@ozgg
ozgg / comment_spec.rb
Created March 5, 2014 15:14
Changing counters after create
require 'spec_helper'
describe Comment do
let(:comment) { build(:comment) }
let(:user) { create(:user) }
let(:dream) { create(:dream) }
context "integrity" do
it "has non-blank body" do
comment.body = ' '
@ozgg
ozgg / message-test
Created February 11, 2014 10:21
Testing that object receives message
# controller
class UsersController < ApplicationController
def send_recovery
user = User.where(email: params[:email].to_s.downcase).first
if user.nil?
flash[:message] = t('email_not_found')
redirect_to recover_form_users_path
else
send_recovery_code user
redirect_to recover_users_path
@ozgg
ozgg / deploy.rb
Created August 19, 2013 12:11
Deployment settings
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
@ozgg
ozgg / host.conf
Last active December 21, 2015 04:18
Nginx + puma
upstream site {
server unix:///var/www/example.com/shared/tmp/puma.sock;
}
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com/current/public;
access_log /var/log/nginx/example.com/access.log main;
error_log /var/log/nginx/example.com/error.log info;
@ozgg
ozgg / puma.rb
Last active December 21, 2015 03:18
Puma config
require 'pathname'
environment 'production'
app_root = Pathname.new('../../../../current').expand_path(__FILE__)
tmp_dir = app_root.join('tmp')
pids_dir = tmp_dir.join('pids')
logs_dir = app_root.join('log')
pidfile pids_dir.join('puma.pid').to_s
@ozgg
ozgg / Ticker
Last active December 17, 2015 09:59
<?php
$tick = function($name) { error_log($name . ': ' . (microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])); }
foo();
$tick('foo');
bar();
$tick('bar');
baz();
@ozgg
ozgg / factory_di
Created April 26, 2013 13:50
Factory and DI example
<?php
class Car
{
protected $power;
protected $doors;
public static function factory($type, Engine $engine, Transmission $transmission)
{
$instance = null;
switch ($type) {