Skip to content

Instantly share code, notes, and snippets.

View lorenzosinisi's full-sized avatar
🦄
Elixir

Lorenzo Sinisi lorenzosinisi

🦄
Elixir
View GitHub Profile
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
set expandtab
set tabstop=2
set shiftwidth=2
set splitright
set number
CIAOOO OOOOCOCOO
@lorenzosinisi
lorenzosinisi / Ruby
Created December 29, 2015 18:06
Ruby
ciao
class Hello
end
Hello.new
@lorenzosinisi
lorenzosinisi / be_boolean.rb
Created October 13, 2015 14:21
be_boolean expectation RSpec Gem
gem install be_boolean
Usage:
expect(value).to be_boolean
@lorenzosinisi
lorenzosinisi / css_truncate_text.css
Created October 13, 2015 14:19
Truncate text with ony CSS
.btn.btn-default {
min-width: 112px;
width: 116px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.btn.btn-danger {
min-width: 112px;
width: 116px;
@lorenzosinisi
lorenzosinisi / Human password generator Gem for Ruby on Rails
Created June 4, 2015 10:39
My first Ruby Gem that makes a little bit of sense
gem install lasslo
Lasslo.unique 10, :user
@lorenzosinisi
lorenzosinisi / gist:4cd35a2848e258affc28
Created June 4, 2015 06:49
Restoring database from Flynn.io to PSQL capistrano
pg_restore --verbose --host localhost --username {USERNAME} --clean --no-owner --no-acl --dbname {DB} latest.dump
@lorenzosinisi
lorenzosinisi / app.rb
Created June 2, 2015 08:05
Rspec Config
config.generators do |g|
g.test_framework :rspec,
:fixtures => true,
:view_specs => true,
:helper_specs => true,
:routing_specs => true,
:controller_specs => true,
:request_specs => true
g.fixture_replacement :factory_girl, :dir => "spec/factories"
end
@lorenzosinisi
lorenzosinisi / faraday.rb
Created June 2, 2015 08:02
Faraday example code for a Rails action
def self.get(url, params)
conn = Faraday.new
response = conn.get url + "?" + params, {}
end
@lorenzosinisi
lorenzosinisi / model.rb
Created June 2, 2015 08:01
Useful scopes for MicroServices in Ruby on Rails
scope :to_do, lambda { where(:processed => false) }
scope :processed, lambda { where(:processed => true) }
scope :to_do_now, lambda { where("due_date > ? AND due_date < ?", DateTime.now, DateTime.now + 3.minutes) }
scope :not_processed, lambda { where(:processed => false) }
scope :circular, lambda { where("minutes IS NOT NULL") }