Skip to content

Instantly share code, notes, and snippets.

View gist:7c99893fb44d1c9f6606
/* Inheritance */
@mixin background-blue($color: blue) {
background-color: $color!important;
}
@mixin super-background($height: '300px', $color: white) {
height: $height;
@include background-blue($color);
}
@barseghyanartur
barseghyanartur / gist:188962bb21d73cf42596
Last active Aug 29, 2015
Django's filter_horizontal/filter_vertical functionality in FeinCMS widgets
View gist:188962bb21d73cf42596
"""
Django's filter_horizontal/filter_vertical functionality in FeinCMS widgets
"""
from django.db import models
from feincms.admin.item_editor import FeinCMSInline
class PartyWidgetInlines(FeinCMSInline):
filter_horizontal = ['drinks', 'snacks']
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
View gist:0697927938047973c9be
// http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
@barseghyanartur
barseghyanartur / README.rst
Last active Aug 29, 2015
django-forms-builder add-on for paragraph support
View README.rst

form-builder-addons

Add-ons for django-forms-builder.

List of add-ons

  • NoneField (allows to use paragraphs in the django-forms-builder).

Installation

View print_r.js
/**
* PHP-like print_r() equivalent for JavaScript Object
*
* @author Faisalman <fyzlman@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php
* @link http://gist.github.com/879208
*/
var print_r = function (obj, t) {
// define tab spacing
View slugify.js
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@barseghyanartur
barseghyanartur / pagination_helper.py
Last active Aug 29, 2015
Generate x number of pages to display out of the total number of pages and current page number
View pagination_helper.py
def get_pages_range(total_pages_number, display_pages_number,
current_page_number):
"""
Generate x number of pages to display out of the total number of pages and
current page number.
:param int total_pages_number: Total number of pages.
:param int display_pages_number: Number of pages to display.
:param int current_page_number: Current page number.
:return iterable:
@barseghyanartur
barseghyanartur / pagination_helper.js
Created Jul 2, 2015
Generate x number of pages to display out of the total number of pages and current page number.
View pagination_helper.js
/**
* Generate x number of pages to display out of the total number of pages and
* current page number.
*
* @param {Integer} totalPagesNumber: Total number of pages.
* @param {Integer} displayPagesNumber: Number of pages to display.
* @param {Integer} currentPageNumber: Current page number.
* @return {Array}:
*/
function getPagesRange(totalPagesNumber, displayPagesNumber, currentPageNumber) {
@barseghyanartur
barseghyanartur / pgpass_helper.py
Created Jul 29, 2015
The Password File helper script for PostgreSQL to be used in Django
View pgpass_helper.py
from __future__ import print_function
__all__ = ('read_pgpass',)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def read_pgpass(dbname):
"""