Skip to content

Instantly share code, notes, and snippets.

@rimmer333
rimmer333 / dabblet.css
Created May 21, 2013 — forked from anonymous/dabblet.css
Ecwid's loading indicator in pure CSS
View dabblet.css
/**
* Ecwid's loading indicator in pure CSS
*/
@keyframes move {
from { background-position-x: 0%; }
to { background-position-x: 100%; }
}
#load-indicator {
@rimmer333
rimmer333 / nma.coffee
Last active Jun 13, 2016
Non-mutating actors for Array and Object in CoffeeScript / JavaScript (like immutable, but not completely, results are still usual Array or Object that you can mutate)
View nma.coffee
NMA =
Array:
push: (array, items...) ->
array.concat(items)
set: (array, index, item) ->
array[...index].concat([item]).concat(array[index+1...])
del: (array, index) ->
(item for item, i in array when i isnt index)
Object:
@rimmer333
rimmer333 / Inline_helpers.html.haml
Last active Apr 26, 2016
"Inline" named helpers in HAML. You don't always need to **ck with .rb helpers or partials.
View Inline_helpers.html.haml
- # _hamlout is the secret sauce
- def test text, _hamlout
%h1 You gave me this:
-# the usual HAML structures can live here
%pre=text
- # remember I told of _hamlout? Kind of annoying, yeah, I know. But anyway.
- test "ohhai", _hamlout
- # notice that we don't =test, we call it as -test, or else you will see an unwanted 0
View new_gist_file
product = {
id: 10,
quantity: 3,
options: {
someTextOption: "optionVal",
someDateOption: new Date().getTime().toString()
},
callback: function(success, product, cart) {
// ...
}
View new_gist_file
var productId = 10;
Ecwid.Cart.addProduct(productId);
View new_gist_file
Ecwid.Cart.addProduct(productID, callback)
View gist:6497160
Ecwid.Cart.get(function(cart) {
alert(cart.productsQuantity + " products in cart now");
});
View gist:6497167
Ecwid.Cart.calculateTotal(function(order) {
if (!order)
alert('An error occurred!')
else
alert('Order total: ' + order.total);
});
View gist:6496872
product = {
id: 10,
quantity: 3,
options: {
someTextOption: "optionVal",
someDateOption: (new Date()).getTime().toString()
},
callback: function(success, product, cart) {
// ...
}