This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- # _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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var whiteListHTML = function(content, whiteList) { | |
var sanitizeInPlace = function(DOMElement, keepTop) { | |
var allowed, item, i; | |
for (i = DOMElement.children.length-1; i >= 0 ; i--) { | |
item = DOMElement.children[i]; | |
sanitizeInPlace(item, false); | |
} | |
allowed = keepTop || whiteList[DOMElement.localName]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// {} /* | |
/*/ | |
body { | |
color: red; | |
} | |
body:before { | |
content: "This is CSS"; | |
} | |
/*/ | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def valid_le_tax_id? (tax_id) | |
tax_id = tax_id.to_s.split('') | |
weights = [2,4,10,3,5,9,4,6,8,0] | |
sum = tax_id.each_with_index.reduce(0){|result,item| | |
result += item[0].to_i * weights[item[1]] | |
}%11%10 | |
return sum == tax_id[9].to_i | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
product = { | |
id: 10, | |
quantity: 3, | |
options: { | |
someTextOption: "optionVal", | |
someDateOption: new Date().getTime().toString() | |
}, | |
callback: function(success, product, cart) { | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var productId = 10; | |
Ecwid.Cart.addProduct(productId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ecwid.Cart.addProduct(productID, callback) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ecwid.Cart.addProduct(product) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ecwid.Cart.calculateTotal(function(order) { | |
if (!order) | |
alert('An error occurred!') | |
else | |
alert('Order total: ' + order.total); | |
}); |
NewerOlder