Skip to content

Instantly share code, notes, and snippets.

View zandroid's full-sized avatar

Andrey Zaytsev zandroid

  • Nizhny Novgorod
View GitHub Profile
@zandroid
zandroid / paginate_helper.rb
Last active September 26, 2017 21:55
This is a custom link renderer that will format the pagination bar with Bootstrap4
module PaginateHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag(:nav, tag(:ul, html, class: "pagination"))
end
def previous_or_next_page(page, text, classname)
if page
@zandroid
zandroid / example.js
Created March 17, 2016 16:15
Especially for reselect (https://github.com/reactjs/reselect). Reducing of number of arguments in selector with help of spread operator.
var xSelector = () => 11;
var ySelector = () => 22;
var zSelector = () => ({ z1: 31, z2: 32 });
var mainSelector = createSelector(
xSelector, ySelector, zSelector,
(...all) => {
let [x, y, { z1, z2 }] = all;
return {
x,
@mixin multiline-ellipsis(
$lines,
$lineHeight: 1.4,
$ellipsisWidth: 3em,
$bgColor: white
) {
box-sizing: content-box;
overflow: hidden;
height: $lines * $lineHeight * 1em;
line-height: $lineHeight;
@zandroid
zandroid / hashfile
Created June 17, 2013 19:06
hashfile node utility for shell
#!/usr/bin/env node
/*
Usage in shell:
hashfile [--sha1|--md5] <file> [--eq <hash2>|--eqf <file2>]
Examples:
> hashfile package.json => print sha1 hash of package.json
function Rect(width, height) {
this.width = width;
this.height = height;
}
Rect.prototype.type = function() { return "rect"; };
function Square(width) {
return new Rect(width, width);
}
Square.prototype.type = function() { return "square"; };
var rc = new Rect();
var sq = new Square();
console.log(rc instanceof Rect); //=> true
console.log(sq instanceof Square); //=> true
console.log(sq instanceof Rect); //=> true !!!
function Rect(color, width, height) {
// определяем геттеры
this.color = function() {
return color;
};
this.width = function() {
return width;
};
this.height = function() {
return height;
function Rect(colot, width, height) {
// задаём поля, в будущем можем их изменить напрямую
this.color = color;
this.width = width;
this.height = height;
}
// [1.1] расширяем прототип:
// то же самое получим вызовом jQuery.extend(Rect.prototype, { ... });
Rect.prototype.s = function() {