Skip to content

Instantly share code, notes, and snippets.

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

Pelayo Maojo pmaojo

🏠
Working from home
View GitHub Profile
import React, { PropTypes } from 'react';
import BaseComponent from 'libs/components/BaseComponent';
import CommentBox from '../CommentBox/CommentBox';
import css from './CommentScreen.scss';
export default class CommentScreen extends BaseComponent {
static propTypes = {
class User < ApplicationRecord
before_create :check_user_exists
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
private
def check_user_exists
@pmaojo
pmaojo / company.rb
Created February 8, 2017 19:04
Búsqueda sin acentos.
#en el modelo
#...
def self.search(search)
where("companies.name ILIKE ?", "%#{search}%")
end
#...
@pmaojo
pmaojo / gist:fd4ca77bb4c036c7a37a399ef556aa2e
Last active March 13, 2017 13:54
haml loop de posts con banner cada cuatro posts
- n = 0
- @posts.each_with_index do |post, i|
%p= post.title
- if n < @banners.count
- if ((i+1) % 3 == 0)
%p= @banners.drop[n].first.title
- n += 1
@pmaojo
pmaojo / avatar.rb
Created April 24, 2017 16:35 — forked from jusk02/avatar.rb
def get_avatar(container,file,access_token)
@avatar_clean = ApiConecction.get("/Contenedores/#{container}/download/#{file}",access_token)
// aqui deberia tomar @avatar_clean.response_body y convertirlo en la imagen, pero no se que hacer
end
#...
after_save :facebookapplink
#...
private
require 'open-uri'
def facebookapplink
if self.facebook.present?
@pmaojo
pmaojo / prueba.rb
Last active January 31, 2018 00:09
Intento de selección aleatoria con peso
@inserciones = Adblock.where(code: @sponsorsection).inject({}) {|h, p| h[p.id] = p.ranking; h}
@ofertas_select2 = WeightedRandomizer.new(@inserciones)
@ofertas_select = @ofertas_select2.sample(10)
@ofertas = []
@ofertas_select.each do |o|
@insert = Adblock.find(o)
@oferta = @insert.coupon
if @oferta.publicada == true
@ofertas << @oferta
end
@pmaojo
pmaojo / demo-pure-javascript-intl-tel-input.markdown
Created September 26, 2018 19:01
Demo: Pure JavaScript intl-tel-input
@pmaojo
pmaojo / autumn-falling-leaves-gsap.markdown
Created October 4, 2019 14:07
Autumn falling leaves ( GSAP )