Skip to content

Instantly share code, notes, and snippets.

View denysdovhan's full-sized avatar
👨‍💻
Working for @wix

Denys Dovhan denysdovhan

👨‍💻
Working for @wix
View GitHub Profile
@denysdovhan
denysdovhan / onDomChange.js
Created May 24, 2014 11:04
Detect changes in the DOM
(function (window) {
var last = +new Date();
var delay = 100; // default delay
// Manage event queue
var stack = [];
function callback() {
var now = +new Date();
if (now - last > delay) {
@denysdovhan
denysdovhan / findClass.js
Created June 22, 2014 19:31
Function for search all element with class or id.
var findClass = function(className) {
var output = []; // Ініціалізуємо масив
var node = (typeof className === 'undefined' ? document.getElementsByTagName('body')[0] : document.getElementByClassName(className)).getElementsByTagName('*');
for(var i=0; i<node.length; i++) { // перебираємо всі ноди
if(node[i].getAttribute('class')) { // якщо мають атрибут class
output[i] = node[i].getAttribute('class'); // заносимо список класів в вихідний масив
}
}
return output;
};
@denysdovhan
denysdovhan / contentloaded.js
Created June 24, 2014 12:51
Cross-browser DOMReady funciton
/*!
* contentloaded.js
*
* Author: Diego Perini (diego.perini at gmail.com)
* Summary: cross-browser wrapper for DOMContentLoaded
* Updated: 20101020
* License: MIT
* Version: 1.2
*
* URL:
@denysdovhan
denysdovhan / loadCSS.js
Created July 1, 2014 20:10
load a CSS file asynchronously.
/*!
loadCSS: load a CSS file asynchronously.
[c]2014 @scottjehl, Filament Group, Inc.
Licensed MIT
*/
function loadCSS( href, before, media ){
"use strict";
// Arguments explained:
// `href` is the URL for your CSS file.
// `before` optionally defines the element we'll use as a reference for injecting our <link>
// Simple ajax function to avoid using jQuery (°-°)
var ajax = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
xhr.onreadystatechange = function (e) {
if (e.target.status === 200 && e.target.readyState === 4) {
callback(e.target.response);
}
};
@denysdovhan
denysdovhan / jsonp-usage.js
Created July 18, 2014 10:25
JSONP fucntion. (Cross-domain request)
doJSONP('http://some.url/', function (data) {
console.log(data);
});
@denysdovhan
denysdovhan / getXMLHttpRequest.js
Created July 18, 2014 10:50
Return a XMLHttpRequest objects
/**
* Return a XMLHttpRequest objects
* @return {Object} XMLHttpRequest
*/
function getXMLHttpRequest() {
if (window.XMLHttpRequest || window.ActiveXObject) {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else {
try {
// Оборачиваем весь код в функцыю-замыкание
// чтобы изолировать код
(function() {
'use strict'; // Использовать строгий синтаксис
var simpleNumbers = function (N) { // Оглашаем функцыю
var simple = 2, // Простое число
simples = [1]; // Массив из простых чисел

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

# Download and install XAMPP (Ubuntu 12.10)
# Depends on python-gtk2:i386 and python-glade2:i386 for the Control Panel
# If all else fails, XAMPP has step by step instructions at: http://www.apachefriends.org/en/xampp-linux.html
sudo add-apt-repository ppa:upubuntu-com/xampp;
sudo apt-get update;
sudo apt-get install xampp;
# Append the following if you're on a 64-bit system (~250MB)
sudo apt-get install ia32-libs