Skip to content

Instantly share code, notes, and snippets.

@aelaguiz
aelaguiz / gist:478e651e5c0bb763b5e5
Created July 3, 2014 20:38
Data collection on subscribe page
{% extends "base.html" %}
{% macro ship_option(product, discount) %}
{% if product.ship_option_string == "pricedin" %}
<p class="ship_discount sml-text">FREE Shipping
{% if discount %}
<br />Save {{ ((1 - discount) * 100) | int }}%
{% else %}
<br />
{% endif %}
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://example.com/" />
</head>
<body></body>
</html>
@aelaguiz
aelaguiz / asdfasdf
Created August 6, 2014 13:07
Test gist
Testasdf
@aelaguiz
aelaguiz / index.html
Created August 6, 2014 13:09
Recipe: Embed an Image
<!-- Simplest case -->
{{ "images/my_image.png" | asset_url | img_tag }}
<!-- With alt -->
{{ "images/my_image.png" | asset_url | img_tag(alt="My image") }}
@aelaguiz
aelaguiz / html
Last active August 29, 2015 14:09
Font example
<h1 class="my-class">Custom header</h1>
@aelaguiz
aelaguiz / subscribe.html
Created November 23, 2014 18:49
Metafields
{% extends "base.html" %}
{% macro ship_option(product, discount) %}
{% if product.ship_option_string == "pricedin" %}
<p class="ship_discount sml-text">FREE Shipping
{% if discount %}
<br />Save {{ ((1 - discount) * 100) | int }}%
{% else %}
<br />
{% endif %}
@aelaguiz
aelaguiz / gist:c711f7cbc58dcae34fd4
Created April 7, 2015 16:14
Add a product to the cart on Cratejoy via JS
$.ajax({
url: '/cart/add',
type: 'POST',
data: {
product_id: 1579,
term_cycles: 3,
'variant:Color': 'silver'
}, success: function(data) {
console.log('Cart Item ID: ' + data.id);
console.log('Cart size: ' + data.cart_size);
@aelaguiz
aelaguiz / client.js
Created February 28, 2011 16:55
Communications for chat client using message.socket.io
var ChatRoom = function ChatRoom(chatList, inputArea, list) {
var _chatList = chatList,
_inputText = inputArea,
_userList = list,
_nickList = [];
/*
* Handle three events from the communications layer
*/
this.expose = {
@aelaguiz
aelaguiz / theano_softmax
Last active December 10, 2015 15:19
Equivalent straight numpy/python for Theanos softmax function
import numpy
import theano
import theano.tensor as T
def theano_softmax():
x = T.dmatrix('x')
_y = T.nnet.softmax(x)
f = theano.function([x], _y)
return f
@aelaguiz
aelaguiz / dispatching_model.py
Created November 28, 2013 13:22
Dispatching model pattern with sqlalchemy
import sqlalchemy as sqla
import sqlalchemy.ext.declarative as decl
from .signals import signaler
class _hooked(object):
def __init__(self, validate_func, normalize_func, field_name, private_name):
self.validate_func = validate_func
self.normalize_func = normalize_func
self.field_name = field_name