Skip to content

Instantly share code, notes, and snippets.

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
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 / 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 / float_description.css
Created Mar 21, 2011
Floating product description in Ecwid. This snippet goes into Ecwid custom CSS. Subsequent modifications to divs in this area may become tricky
View float_description.css
div.ecwid-productBrowser-details-leftPanel div {
float: left;
div.ecwid-productBrowser-details-thumbnail {
width: 225px;
margin-right: 5px;
div.ecwid-productBrowser-details-leftPanel div.ecwid-productBrowser-details-descr, div.ecwid-productBrowser-details-leftPanel div.ecwid-productBrowser-details-descr div{
rimmer333 / pager-top.css
Created Mar 25, 2011
The way to move the category pagination in Ecwid from bottom to top. This is to be applied into your Ecwid custom CSS theme.
View pager-top.css
div.ecwid-pager {
position: absolute;
top: 0;
width: 100%;
margin: 0;
div.ecwid-productBrowser-category {
padding-top: 2em;
position: relative;
rimmer333 / eg2.xml
Created Apr 20, 2011
Ecwid's fine-grained Google Gadget
View eg2.xml
<?xml version="1.0" encoding="UTF-8"?>
<ModulePrefs title="Ecwid Demo Store" title_url="" author="Ecwid team" scrolling="true">
<Require feature="dynamic-height"/>
<UserPref name="storeid" display_name="Your Ecwid Store ID" default_value="1003" datatype="int" />
<UserPref name="defaultCategoryId" display_name="Default category ID" default_value="0" datatype="int" />
<UserPref name="categoriesPerRow" display_name="Categories per row" default_value="2" datatype="int" />
<UserPref name="K" display_name="Grid view: number of products in a column" default_value="2" datatype="int" />
<UserPref name="L" display_name="Grid view: number of products in a row" default_value="2" datatype="int" />
rimmer333 / ecwid-scripts-work.js
Created May 17, 2011
Ecwid addon: a drop-in script to make any scripts inserted in product description to work out of the box.
View ecwid-scripts-work.js
(function(){(function(k,h,M){function H(){var a=l;a.loader={load:N,i:0};return a}function N(a,c,e){var m=c=="c"?O:I;w=0;c=c||"j";x(a)?P(m,a,c,this.i++,y,e):(s.splice(this.i++,0,a),s.length==1&&z());return this}function P(a,c,e,m,n,i){function t(){!f&&(!b.readyState||b.readyState=="loaded"||b.readyState=="complete")&&(g.r=f=1,!w&&o(),b.onload=b.onreadystatechange=null,p(function(){A.removeChild(b)},0))}var b=h.createElement(a),f=0,g={t:e,s:c,e:i};;!B&&("none");b.width=
b.height="0";a!="object"&&(b.type=e);b.onload=b.onreadystatechange=t;a=="img"?b.onerror=t:a=="script"&&(b.onerror=function(){g.e=g.r=1;z()});s.splice(m,0,g);A.insertBefore(b,B?null:v);p(function(){f||(A.removeChild(b),g.r=g.e=f=1,o())},l.errorTimeout)}function z(){var a=s.shift();w=1;a?a.t?p(function(){a.t=="c"?Q(a):R(a)},0):(a(),o()):w=0}function Q(a){var c=h.createElement("link"),e;c.href=a.s;c.rel="stylesheet";c.type="text/css";if(!a.e&&(C||D)){var m=function(n){p(function(){if(!e)try{n.sheet.cssRules.length?
rimmer333 / gist:1186041
Created Sep 1, 2011 — forked from qetzal/gist:1118615
SSO Complete Example in PHP
View gist:1186041
if (!$_REQUEST['logoff']) {
$profile = array(
'appId' => '123',
'userId' => '234',
'profile' => array(
'email' => '',
'billingPerson' => array(
rimmer333 / ecwid-catid-class.js
Created Sep 13, 2011
Adds class with category ID into div.ecwid-productBrowser so various CSS customizations can be targeted to products in some particular category
View ecwid-catid-class.js
Ecwid.OnAPILoaded.add(function(){var a;a=window.document.getElementById("ProductBrowser-1");window.Ecwid.ProductBrowser.element=a.getElementsByClassName&&a.getElementsByClassName("ecwid-productBrowser")[0]||function(){var b,c;c=/(^| )ecwid-productBrowser( |$)/;for(b in a.getElementsByTagName("div"))if(b.className.match(c))return b}()});Ecwid.OnPageLoaded.add(function(a){if(a.type==="PRODUCT")window.Ecwid.ProductBrowser.element.className+=" ecwid-productBrowser-ProductInCategory-"+a.categoryId});
View gist:1229387
window.ecwidMessages = window.ecwidMessages||{};
ecwidMessages["OrderComponent.order_no"] = "<span class=\"invoice-taxnum\">ABN: 1234567890</span>Order <span>\# ";