Skip to content

Instantly share code, notes, and snippets.

View seguelador's full-sized avatar
🏠
Working from home

Matias Seguel seguelador

🏠
Working from home
  • Mercado Libre
  • Chile
View GitHub Profile
devise.rb
config.omniauth :google_oauth2, Rails.application.secrets.google_oauth2_key, Rails.application.secrets.google_oauth2_secret,
scope: 'email, profile', image_aspect_ratio: 'square', image_size: 300, access_type: 'online'
user.rb
def self.find_for_oauth(auth, signed_in_resource = nil)
identity = Identity.find_for_oauth(auth)
user = signed_in_resource ? signed_in_resource : identity.user
@seguelador
seguelador / zsh.md
Created April 12, 2017 02:53 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@seguelador
seguelador / fog.rb
Last active April 18, 2017 18:08 — forked from gsanchezd/fog.rb
Base Fog Carrierwave config
if Rails.env.test?
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false
end
else
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV['aws_access_key_id'], # required
@seguelador
seguelador / additional-methods.js
Created May 2, 2017 15:25
Method for letters only with accents on Jquery Validation
$.validator.addMethod( "lettersonly", function( value, element ) {
return this.optional( element ) || /^[a-z\s-a-záéíóúý]+$/i.test( value );
}, "Solo letras por favor" );
@seguelador
seguelador / postgis.rb
Last active July 14, 2017 13:43
All points inside a circle POSTGIS Rails
Crea un circulo en base a un punto de 2km
ActiveRecord::Base.connection.execute("SELECT ST_Buffer(ST_GeomFromText('POINT(100 90)'), 2000, 'quad_segs=3')")
###########################
Trae todos los customers ordenados segun distancias, tomando la distancia mas cercana primero respecto al punto
ActiveRecord::Base.connection.execute("SELECT * FROM customers ORDER BY customers.location <-> 'POINT(-70 -33)'")
###########################
@seguelador
seguelador / _products.html.erb
Last active August 30, 2017 17:57
Will Paginate Boostrap with Ajax
<% @products.each do |product| %>
<span> <%= product.title %> </span>
<span> <%= product.price %> </span>
<% end %>
<%= will_paginate @products, renderer: BootstrapPagination::Rails %>
<%#= will_paginate @products, renderer: BootstrapPagination::Rails, :params => { :controller => "optional controller", :action => "optional action" } %>
@seguelador
seguelador / active_record_extension.rb
Created September 8, 2017 14:12
Active Record Union Scopes
# from https://stackoverflow.com/questions/6686920/activerecord-query-union
# lib/active_record_extension.rb
module ActiveRecordExtension
extend ActiveSupport::Concern
class_methods do
def union_scope(*scopes)
id_column = "#{table_name}.#{primary_key}"
sub_query = scopes.map { |s| s.select(id_column).to_sql }.join(" UNION ")
where "#{id_column} IN (#{sub_query})"
# EvilCorp terminal
PROMPT='%{$fg_bold[blue]%} s3gu3l4d0r##$:%d: %{$reset_color%} $(git_prompt_info) '
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
@seguelador
seguelador / README-Template.md
Created April 20, 2018 07:49 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@seguelador
seguelador / iterm2-solarized.md
Created April 24, 2018 08:19 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k