Skip to content

Instantly share code, notes, and snippets.

View dmitryrck's full-sized avatar

Dmitry L Rocha dmitryrck

View GitHub Profile
server {
listen 81;
root /home/dmitry/project/public;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
┌── info ──────────────────────────────┐
J-_-L │ http://github.com/janlelis/clipboard │
├── usage ─────────────────────────────┤
│ require 'clipboard' │
│ Clipboard.copy '42' │
│ Clipboard.paste #=> 42 │
└──────────────────────────────────────┘
@dmitryrck
dmitryrck / user.rb
Last active August 29, 2015 14:06 — forked from dannluciano/user.rb
class User < ActiveRecord::Base
validates :username, presence: :true
validates :password_digest, presence: :true
has_secure_password
end
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
class Model < ActiveRecord::Base
def self.search(term)
words = sanitize(term.parameterize(" ").scan(/\w+/) * "+")
where("name @@ to_tsquery('portuguese', #{words})")
end
end
require 'rails_helper'
describe BookCreator do
context 'create a book by isbn' do
before do
VCR.use_cassette('search-isbn') do
book
end
end
class ApplicationController < ActionController::Base
protect_from_forgery :with => :exception
helper_method :categories_ordered
def categories_odered
Category.order(:name)
end
end
class HomeController < ApplicationController
def foo
render layout: false
end
end
@dmitryrck
dmitryrck / README.md
Last active October 7, 2017 22:01
rails-api + activeadmin

Files

Gemfile

gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin.git'
gem 'devise'
gem 'sass', '~>3.0'
@dmitryrck
dmitryrck / Dockerfile
Last active December 4, 2016 17:15
Sample of Dockerfile and docker-compose.yml
from ruby:2.3.0
env DEBIAN_FRONTEND noninteractive
run sed -i '/deb-src/d' /etc/apt/sources.list
run apt-get update
run apt-get install -y build-essential postgresql-client nodejs
env PHANTOMJS_VERSION 1.9.8