Skip to content

Instantly share code, notes, and snippets.

# lib/liquid_i18n_rails.rb
module LiquidI18nRails
def t(string)
I18n.t(string.to_sym)
end
end
# config/initializers/liquid.rb
require 'liquid_i18n_rails'
Liquid::Template.register_filter LiquidI18nRails
@ZenCocoon
ZenCocoon / JSON API Compound Documents.json
Last active August 29, 2015 13:59
JSON API Compound Documents
{
"links": {
"posts.author": {
"href": "http://example.com/people/{posts.author}",
"type": "people"
},
"posts.comments": {
"href": "http://example.com/comments/{posts.comments}",
"type": "comments"
}
en:
locale_names:
af: "Afrikaans"
sq: "Albanian"
ar: "Arabic"
hy: "Armenian"
az: "Azerbaijani"
eu: "Basque"
be: "Belarusian"
bn: "Bengali"
@ZenCocoon
ZenCocoon / custom_inquiry_form
Last active August 29, 2015 14:20
BookingSync Custom/Self-Hosted Inquiry Form
<form accept-charset="UTF-8" action="https://www.bookingsync.com/en/mybookings/1/inquire" method="post">
<div style="display:none"><input name="utf8" type="hidden" value="✓"></div>
<label for="inquiry_rental_id">Rental</label>
<select id="inquiry_rental_id" name="inquiry[rental_id]">
<option selected="selected" value="1234">Villa Boubouki</option>
<option value="1235">Villa Anatoli</option>
<option value="1236">Villa Amoudia</option>
<option value="1237">Villa Sivota</option>
</select>
{
"links": {
"rentals.account": "https://www.bookingsync.com/api/v3/accounts/{rentals.account}",
"rentals.availability": "https://www.bookingsync.com/api/v3/availabilities/{rentals.availability}",
"rentals.destination": "https://www.bookingsync.com/api/v3/destinations/{rentals.destination}",
"rentals.rates_table": "https://www.bookingsync.com/api/v3/rates_tables/{rentals.rates_table}",
"rentals.rental_agreement": "https://www.bookingsync.com/api/v3/rental_agreements/{rentals.rental_agreement}",
"rentals.photos": "https://www.bookingsync.com/api/v3/photos/{rentals.photos}",
"rentals.reviews": "https://www.bookingsync.com/api/v3/reviews/{rentals.reviews}",
"rentals.special_offers": "https://www.bookingsync.com/api/v3/special_offers/{rentals.special_offers}",
@ZenCocoon
ZenCocoon / booknow.liquid
Last active August 29, 2015 14:24
Live price check using BookingSync Javascript API v2
<form id="bs_booknow_form" action="{{ rental.booknow_url }}" method="get">
<input type="hidden" id="bs_booknow_rental_id" name="rental_id" value="{{ rental.bookingsync_id }}" />
<input type="hidden" id="bs_booknow_source" name="source" value="{{ site.domain }}" />
<input type="hidden" id="bs_booknow_include_tentative" name="include_tentative" value="{{ site.tentatives_as_available }}">
<div class="row">
<div class="col-xs-6 col-sm-12 col-md-6">
<div class="form-group date">
<label class="date control-label" for="bs_booknow_start_at">
{% t 'search.form.checkin' %}</label>
<input autocomplete="off" class="date form-control" data-datepicker=""
@ZenCocoon
ZenCocoon / bootstrap.datepicker.js
Created July 8, 2015 13:52
BookingSync version for the Bootstrap Datepicker. Adding support for availability map and more
/* ===========================================================
* bootstrap-datepicker.js v1.3.0
* http://twitter.github.com/bootstrap/javascript.html#datepicker
* ===========================================================
* Copyright 2011 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
/**
* Inspired from Mootools 1.2 Element.Storage (http://blog.mootools.net/2008/1/22/Element_Storage)
*
* License:
* MIT-style license.
*
* Author:
* Sebastien Grosjean (http://zencocoon.com)
*
* Tested under FF 2, FF3, Safari 3, Opera 9.25, IE6, IE7, Camino 1.6
# In Ruby
# How to deeply fetch an Hash
# Having :
hash = {"parent" => {"child" => "value"}}
# How to get value from "parent.child" ?
# Ideal solution
hash.deep_fetch(["parent", "child"])
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>untitled</title>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
<script type="text/javascript">