Skip to content

Instantly share code, notes, and snippets.

View dmitryrck's full-sized avatar

Dmitry L Rocha dmitryrck

View GitHub Profile
┌── 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
@dmitryrck
dmitryrck / nginx
Created December 28, 2011 18:26
/etc/init.d/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
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
#!/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
# 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