Skip to content

Instantly share code, notes, and snippets.

@Bartunek
Bartunek / rem.styl
Created January 3, 2017 13:26 — forked from nDmitry/rem.styl
Stylus mixin for rem units with fallback.
/**
* rem with fallback to px
*
* Use px as unit and only within a property.
* Default root font-size is standard 16px.
*
* Example:
* p {
* font-size: rem(18px);
* box-shadow: 0 0 rem(7px) #000;
@Bartunek
Bartunek / post-merge
Last active December 12, 2016 16:01 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@Bartunek
Bartunek / sass-var-interpolation.sublime-snippet
Created June 5, 2014 10:20
Sass variable interpolation syntax Sublime Text snippet
<snippet>
<content><![CDATA[
#{\$${1:variable}}
]]></content>
<tabTrigger>val</tabTrigger>
<scope>source.sass</scope>
</snippet>
@Bartunek
Bartunek / readmore.js
Created April 23, 2014 12:56
Simple read more jQuery plugin
/**
* Read more plugin
* Can be anywhere in js, after jQuery is loaded
*/
(function($){
$.fn.read_more = function (opts) {
opts = opts || {};
var textContent = opts.text || 'Číst více',
hideContent = opts.text || 'Skrýt',
@Bartunek
Bartunek / _mixins.scss
Created February 5, 2014 09:48
Basic sass mixins for CSS3 and some helpers
@function black($opacity){
@return rgba(0,0,0,$opacity)
}
@function white($opacity){
@return rgba(255,255,255,$opacity)
}
@function grid($col){
@return (($grid * $col) - $gutter)
}
@Bartunek
Bartunek / this-enabled-timers.js
Created January 22, 2014 10:29
Native timers extended for passage of 'this' object
/**
*
* Enable the passage of the 'this' object through the JavaScript timers
*
**/
var __nativeST__ = window.setTimeout, __nativeSI__ = window.setInterval;
window.setTimeout = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
var oThis = this, aArgs = Array.prototype.slice.call(arguments, 2);
return __nativeST__(vCallback instanceof Function ? function () {
@Bartunek
Bartunek / styled-select.js
Created January 22, 2014 10:04
Styled Select jQuery Plugin
(function($) {
$.fn.styledSelect = function() {
return this.each(function() {
var $this = $(this),
numberOfOptions = $(this).children('option').length;
$this.addClass('s-hidden');
$this.wrap('<div class="styledSelect'+(($this.attr("data-class")) ? " "+$this.attr("data-class") : "")+'"></div>');
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@Bartunek
Bartunek / url-params-function.js
Created January 17, 2014 10:10
Parsing and working with url parameters
// Function for parsing params from url (returning params in javascript object)
var parseUrlParams = function () {
var parReg = /[\?\&][a-zA-z0-9-~]+/g,
params = window.location.search.match(parReg),
result = {};
for (var i = params.length - 1; i >= 0; i--) {
params[i] = params[i].substring(1);
var valReg = new RegExp('[?&]'+params[i]+'=([^&#]*)'),
val = window.location.search.match(valReg) ? window.location.search.match(valReg)[1] : null;