Skip to content

Instantly share code, notes, and snippets.

rimmer333 /
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)
push: (array, items...) ->
set: (array, index, item) ->
del: (array, index) ->
(item for item, i in array when i isnt index)
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
- # 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
rimmer333 / html_whitelisting.js
Last active Aug 29, 2015
Lightweight client side HTML whitelisting in JavaScript. By no means this is a strong security measure, I use it to simply clean up the (ugly) code from many WYSIWYGs out there.
View html_whitelisting.js
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];
rimmer333 / amphiling.js
Created Feb 20, 2015
A file that is a valid CSS and JS at the same time. Include the same URL into HTML via <link> and <script src> and spare a request.
View amphiling.js
// {} /*
body {
color: red;
body:before {
content: "This is CSS";
rimmer333 / egrul_inn_check.rb
Created Feb 18, 2015
Проверка валидности ИНН юрлица на Ruby (согласно
View egrul_inn_check.rb
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]]
return sum == tax_id[9].to_i
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;
View new_gist_file
Ecwid.Cart.addProduct(productID, callback)
View gist:6497167
Ecwid.Cart.calculateTotal(function(order) {
if (!order)
alert('An error occurred!')
alert('Order total: ' +;