Skip to content

Instantly share code, notes, and snippets.

View littlemove's full-sized avatar

Diego Fernández Fernández littlemove

  • BeBanjo
  • Asturias - Spain
View GitHub Profile
# current
add_ad_hoc_metadata_key "Available Offline" do
return false if [territory_iso, business_model].any?(&:blank?)
target = title.series.try(:mov_series) || title.mov_title
availabilities = metadata(target, "WHATS'On:Offline Availability")
availabilities.any? do |entry|
entry = OfflineAvail.new(*entry.split('^'))
entry.business_model_matches?(business_model) &&
@littlemove
littlemove / my-ruby.el
Created March 18, 2016 11:40
Spacemacs: Code folding for ruby-mode
;; Code folding
(add-hook 'ruby-mode-hook
(lambda () (hs-minor-mode)))
(eval-after-load "hideshow"
'(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start
,(rx (or "}" "]" "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
require 'execjs'
# JS file path with the Kigo price calculation algorithm.
kigo_js_path = "#{Rails.root}/db/kigo_price_calculation.js"
source = %Q(
var price_info = '{}';
var checkin = new Date('2016-05-07');
var checkout = new Date('2016-05-17');
var guests = 2;
@littlemove
littlemove / gist:751d86849b6f71a74cb8
Last active August 29, 2015 14:27
Escenario calendario tipo 2
Dos escenarios con una propiedad con un calendario tipo 2, con dos períodos de disponibilidad (de s1 a e1 y de s2 a e2), para unas fechas dadas (de fi a ff):
s1 fi ff e1 s2 e2
--------|----|-----|-----|--------|------|--------
s1 fi e1 s2 ff e2
--------|----|----------|--------|----|---|--------
>> response
=> #<HTTParty::Response:0x1019182f8 parsed_response={"datos"=>{"codiclie"=>"UATG10560533", "email"=>"diego.fernandez.fernandez@gmail.com", "nombre"=>"Diego", "apellido1"=>"Fernández", "apellido2"=>nil, "deseainfo"=>"N", "TipoIdentificacion"=>"N", "NumeroIdentificacion"=>nil, "sexo"=>nil, "tipousuario"=>"ECI", "pais"=>"ESPAÑA", "provincia"=>nil, "codpostal"=>nil, "municipio"=>nil, "localidad"=>nil, "tipovia"=>nil, "via"=>nil, "numerovia"=>nil, "puerta"=>nil, "telefono1"=>nil, "telefono2"=>nil, "birthdate"=>nil, "idPais"=>"011", "cnumecli"=>"UATG10560533"}}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"set-cookie"=>["TESTPRE=r4049877317; path=/; expires=Fri, 1 Jan 2016 01:01:50 GMT", "JSESSIONID_PROFILE=0000dkYFKTufUw7IMb4bi62GktN:13e6chc1k; Path=/"], "p3p"=>["CP=\"NON CUR OTPi OUR NOR UNI\""], "content-type"=>["text/xml;charset=ISO-8859-1"], "date"=>["Thu, 21 Feb 2013 16:50:48 GMT"], "content-length"=>["680"], "content-language"=>["en-US"], "connection"=>["close"]}>
>> response.parsed_
@littlemove
littlemove / ability.rb
Created November 14, 2012 11:11
CanCan, Rolify and RailsAdmin took my baby away
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.has_role?(:metadmin)
can :manage, :all
can :manage, Carousel, market_id: user.market_id
elsif user.has_role?(:editor)
irb(main):005:0> Hotel.first
Hotel.first
Hotel Load (58.6ms) SELECT `hotels`.* FROM `hotels` LIMIT 1
EXPLAIN (68.0ms) EXPLAIN SELECT `hotels`.* FROM `hotels` LIMIT 1
EXPLAIN for: SELECT `hotels`.* FROM `hotels` LIMIT 1
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | hotels | ALL | NULL | NULL | NULL | NULL | 1 | |
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
@littlemove
littlemove / gist:3040473
Created July 3, 2012 15:28
Drag-n-Drop dataTransfer manipulation
$('<image selector>').bind('dragstart', function(e) {
var old_src = e.originalEvent.dataTransfer.getData('text/html');
var new_src = old_src.replace('str_to_replace','str_replacement');
e.originalEvent.dataTransfer.setData('text/html', new_src);
});
@littlemove
littlemove / gist:1014600
Created June 8, 2011 15:08
Ya lo decía Platón
"Para Platón el lenguaje escrito (Fedro, 274b i s., ver texto ) es solamente un pálido reflejo del lenguaje hablado, y la escritura debe entenderse solamente como un medio para apoyar la memoria y como una especie de pasatiempo, de juego o de recreación."