Skip to content

Instantly share code, notes, and snippets.

View dmitryrck's full-sized avatar

Dmitry L Rocha dmitryrck

View GitHub Profile
View gist:2d6fe274c5c1a970eda1
┌── 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
View user.rb
class User < ActiveRecord::Base
validates :username, presence: :true
validates :password_digest, presence: :true
has_secure_password
end
View style.css
/*! 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;
}
View gist:66e47d488517cd38e19f
class Model < ActiveRecord::Base
def self.search(term)
words = sanitize(term.parameterize(" ").scan(/\w+/) * "+")
where("name @@ to_tsquery('portuguese', #{words})")
end
end
View spec_business_book_creator_spec.rb
require 'rails_helper'
describe BookCreator do
context 'create a book by isbn' do
before do
VCR.use_cassette('search-isbn') do
book
end
end
@dmitryrck
dmitryrck / nginx
Created December 28, 2011 18:26
/etc/init.d/nginx
View nginx
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx
### END INIT INFO
View gist:e0e586ddaa6cdd8c575b
class ApplicationController < ActionController::Base
protect_from_forgery :with => :exception
helper_method :categories_ordered
def categories_odered
Category.order(:name)
end
end
View app-controllers-home_controller.rb
class HomeController < ApplicationController
def foo
render layout: false
end
end
View init-mongodb.sh
#!/bin/sh
NAME=$(basename $0)
dbprefix=${HOME}/Data/mongodb
mkdir -p "${dbprefix}/db" >/dev/null 2>/dev/null
repair() {
mongod --repair --dbpath ${dbprefix}/db
@dmitryrck
dmitryrck / gist:1973996
Created March 4, 2012 17:27
Run mongodb on ubuntu 11.10 x64
View gist:1973996
# Passos:
% wget -c http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.3.tgz
tar xfz mongodb-linux-x86_64-2.0.3.tgz
mkdir -p ${HOME}/db
./mongodb-linux-x86_64-2.0.3/bin/mongod run --dbpath ${HOME}/db