Skip to content

Instantly share code, notes, and snippets.

View juque's full-sized avatar

Juan Pablo Aqueveque juque

View GitHub Profile
@ismasan
ismasan / image_backup.rb
Last active May 9, 2017 00:43
Backup all product images in a Bootic shop
# gem install thread
#
# run with:
# SUBDOMAIN=foobar btc runner image_backup.rb
#
require 'open-uri'
require 'fileutils'
require "thread/pool"
require "logger"
@ismasan
ismasan / themes.rb
Last active December 15, 2016 13:40
Backup a Bootic theme using the Bootic CLI
require "fileutils"
require "open-uri"
require "thread"
require "listen"
# dependencies:
# gem install listen
#
# Put this file in ~/btc/themes.rb
# Theme management

Shopping cart, Event Sourcing style

This is an example of how to interact with a shopping cart by emitting actions or events.

A processor object dispatches incoming events to susbcribers, who are in charge of mutating data (an order in this case).

Run a simple user session that interacts with the cart with

ruby user_session.rb
@ismasan
ismasan / cart-info.js
Last active September 30, 2016 03:19
Collect product information for products in a Bootic cart
/* Collect product information for products in the cart
Usage:
Get all products in the cart
CartInfo.getProducts(function (products) {
// products is an array of product objects
console.log(products)
})
@fuyufjh
fuyufjh / cheatsheet.py
Last active July 24, 2024 15:03
My Python Cheatsheet
Python Cheatsheet
=================
################################ Input & Output ###############################
name = input('please enter your name: ')
print('hello,', name)
ageStr = input('please enter your age: ')
age = int(ageStr)
<h1>{{ search_term }} | {{ products | size }} productos encontrados</h1>
{% if products.size > 0 %}
<ul class="products clearfix">
{% loop products in 'product_item' %}
</ul>
{% else %}
No hay resultados.
{% endif %}
@mdamaceno
mdamaceno / testesavon.rb
Last active December 1, 2015 04:56
Example using WSDL in Ruby
require 'savon'
client = Savon.client(wsdl: 'http://tadeuclasse.zz.mu/WSCartao/Server.php?wsdl')
response = client.call(:validar_cartao, message: {
tDadosCartao: {
"NumeroCartao" => "4522669988574455",
"Codigo" => "168",
"NomeCliente" => "Marco Damaceno",
"Validade" => "201612",
"Valor" => "150",
@juque
juque / custom_add_to_cart.html
Last active August 29, 2015 14:06 — forked from ismasan/custom_add_to_cart.html
custom_add_to_cart.html
<!-- Formulario y botón "agregar al carro" en plantilla product.html.
Los data-attributes son necesarios para la API Ajax del carrito (opcional) -->
<form class="add_to_cart" action="{{ add_to_cart_url }}" method="post" data-bootic-cart-add="add" data-bootic-productId="{{ product.id }}">
<!-- si hay más de 1 variante, muéstralas en una lista -->
{% if product.variants_count > 1 %}
<h4>{{ 'activerecord.models.variant' | t }}</h4>
<ul class="variants">
<!-- primero las variantes disponibles -->
{% for variant in product.available_variants %}
<li class="bootic_variant available {% cycle 'odd', 'even' %} av-variant-{{ forloop.index }}">
@t2
t2 / birthday_liker.rb
Last active September 23, 2016 14:10
Like and Comment on every 'Happy Birthday' post on your Facebook feed at once.
require 'date'
require 'koala'
class BirthdayLiker
FACEBOOK_TOKEN = 'your_oauth_key'
BIRTHDAY_WORDS = %w(birthday bday birfday birth born)
THANKS_OPTIONS = ['Thank you!', 'Thanks!', 'Appreciate it!']
DATE_TIME_FORMAT = '%Y-%m-%d'
def initialize(birthdate, opts={})
@juque
juque / anidamiento_menu.html
Last active August 29, 2015 13:58
anidamiento de menú
{% comment %}
Creando menús de navegación se tiene un control completo de las opciones que ahí
aparecen. En el siguiente ejemplo se creará una navegación anidada utilizando
4 menús.
Se asume que se tiene creado un menu de nombre `global` y 3 submenus de nombres:
- `alfa-local`
- `beta-local`