Skip to content

Instantly share code, notes, and snippets.

View artursopelnik's full-sized avatar
🏠
Working from home

Artur Sopelnik artursopelnik

🏠
Working from home
View GitHub Profile
@artursopelnik
artursopelnik / countCSSRules.js
Created August 4, 2016 14:08 — forked from krisbulman/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE. — This snippet has been modified to count more than just the first level of CSSStyleRule objects within CSSMediaRule.
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@artursopelnik
artursopelnik / PHP_List_Currency_function
Created August 26, 2016 08:46
Php function return list of all the currencies.
function buildCurrency() {
$currency = array(
'ALL' => 'Albania Lek',
'AFN' => 'Afghanistan Afghani',
'ARS' => 'Argentina Peso',
'AWG' => 'Aruba Guilder',
'AUD' => 'Australia Dollar',
'AZN' => 'Azerbaijan New Manat',
'BSD' => 'Bahamas Dollar',
'BBD' => 'Barbados Dollar',
@artursopelnik
artursopelnik / .htaccess
Created September 23, 2016 07:58 — forked from seoagentur-hamburg/.htaccess
Die optimale .htaccess-Datei für mehr Speed und Sicherheit
# ----------------------------------------------------------------------
# | Komprimierung und Caching |
# ----------------------------------------------------------------------
# Serve resources with far-future expires headers.
#
# (!) If you don't control versioning with filename-based
# cache busting, you should consider lowering the cache times
# to something like one week.
#
@artursopelnik
artursopelnik / data-options.js
Created October 6, 2016 11:05 — forked from zoxon/data-options.js
Convert data-options attribute into an object of key/value pairs
/**
* Convert data-options attribute into an object of key/value pairs
* @private
* @param {String} options Item-specific options as a data attribute string
* @returns {Object}
*/
var getDataOptions = function ( options ) {
var settings = {};
// Trim whitespace from a string
@artursopelnik
artursopelnik / README
Created October 26, 2016 09:10 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@artursopelnik
artursopelnik / .jshintrc.js
Created November 4, 2016 18:51 — forked from connor/.jshintrc.js
jshintrc example
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
@artursopelnik
artursopelnik / scrollTargetPosition.js
Created November 18, 2016 09:03 — forked from hashchange/scrollTargetPosition.js
Returns the scroll target position for scrolling to the top of an element.
/**
* Returns the scroll target position for scrolling to the top of an element.
*
* Pass the result to a scrollTo method:
*
* - $scrollContainer.scrollTop( result ) for instant scrolling
* - $scrollContainer.scrollTo( result ) for animated scrolling with jQuery.scrollable
*
* @param {jQuery} $target the target element
* @param {jQuery} $scrollContainer either $(window), or a scrollable HTML element
function parseQueryString () {
var str = window.location.search,
objURL = {},
isArray = _.isArray,
first;
str.replace(
new RegExp('([^?=&]+)(=([^&]*))?', 'g'),
function ($0, $1, $2, $3) {
if (objURL[$1] && !isArray(objURL[$1])) {
// input[type="reset"] sucks. Do it manually
$(':input', this.form).each(function () {
var type = this.type,
tag = this.tagName.toLowerCase();
if (type == 'text' || type == 'search' || type == 'password' || tag == 'textarea') {
this.value = "";
} else if (type == 'checkbox' || type == 'radio') {
this.checked = false;