Skip to content

Instantly share code, notes, and snippets.

View mir4a's full-sized avatar
🤞

Myroslav mir4a

🤞
View GitHub Profile
@mir4a
mir4a / cl.js
Last active August 29, 2015 14:11 — forked from azproduction/cl.js
console.log($LINE$);
// LINE = lineNumber()
@mir4a
mir4a / gist:06380fca2e839a01ad6c
Created February 19, 2015 12:37
Real hell SCSS
div#home-store-info {
@extend .hidden-xs;
@extend .col-sm-12;
@extend .col-md-12;
margin-bottom: 20px;
div.store-info-block {
background-color: rgba(255, 255, 255, 0.4);
color: #1b6a8e;
@extend .row;
@mir4a
mir4a / fs.js
Last active August 29, 2015 14:27
Skip annoying ads on fs.to
javascript:
(function (){
var iframe_wrap = document.getElementsByClassName('b-iframe-aplayer')[0],
_i = iframe_wrap.getElementsByTagName('iframe')[0],
player = _i.contentDocument.getElementById('player'),
teasers = _i.contentDocument.getElementsByClassName('b-aplayer-teasers')[0],
duration = player.duration;
teasers.style.visibility = 'hidden';
player.currentTime = duration;
@mir4a
mir4a / click_on_day_at_datepicker.rb
Created September 11, 2015 16:09
Datepicker helper for Capybara with RSpec tests
def click_on_day_at_datepicker(date)
d = Date.parse(date)
month = d.strftime('%b')
day = d.day
# XPath select Month switcher
xpath_month_switcher_selector = '//div[contains(@class, "datepicker-days") and not(contains(@style,"display:none"))]//th[contains(@class, "datepicker-switch")]'
find(:xpath, xpath_month_switcher_selector).click
# XPath select particular Month
xpath_particular_month_selector = "//div[contains(@class, \"datepicker-months\") and not(contains(@style,\"display:none\"))]//*[text() = \"#{month}\"]"
find(:xpath, xpath_particular_month_selector).click
@mir4a
mir4a / ajax_requests.rb
Created September 11, 2015 16:14
Setter/getter for some particular global var and increment on each Ajax request for Capybara tests
def set_ajax_counter(global_var)
page.execute_script <<-SCRIPT
window["#{global_var}"] = 0;
$(document).on("ajaxSend", function(){
window["#{global_var}"]++;
console.log('increment ajax counter window["#{global_var}"] = ' + window["#{global_var}"]);
});
SCRIPT
end
@mir4a
mir4a / ya.photo.top
Created March 2, 2013 09:18
This bookmarklet only works on http://fotki.yandex.ru/top and strip all info blocks and left only the photos. Onclick on photo will load the XL sized photo onto simple lightbox.
javascript:
var script=document.createElement('script');
script.onload = function () {
stripPhoto();
};
script.src='http://code.jquery.com/jquery-1.9.1.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
function stripPhoto () {
var photos = $('.b-photoArray');
var body = $('body');
@mir4a
mir4a / tel.js
Last active December 15, 2015 05:49
Avoid enter any characters except numbers and plus sign
//<editor-fold desc="функция проверки введения только цифр">
var tel_01 = $('#con_tel');
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function onlyNumbers(input) {
input.on('keypress', function(e){
// check IE version from this function <script src="https://gist.github.com/mir4a/5211477/raw/b78e8f60b2cc195a7831672cd2ee0fe308f17e3f/check_ie.js"></script>
@mir4a
mir4a / zero.js
Last active December 15, 2015 05:49
Add zero to numbers less than 10
function zero(number) {
return (number < 10 ? '0' : '') + number;
}
@mir4a
mir4a / countdown.js
Last active December 15, 2015 05:49
Countdown timer
//<editor-fold desc="Таймер обратного отсчета">
var t_data = document.getElementById('tender_data'); // get element with data-set
var timer_end_date = t_data.getAttribute('data-timer-end'); // get data-set timer-end
var timerHour = $('.b-timer_wrap > .i-hour'); // where to write hours value
var timerMin = $('.b-timer_wrap > .i-minute'); // where to write minutes value
var timerSec = $('.b-timer_wrap > .i-sec'); // where to write seconds value
function zero(number) {
return (number < 10 ? '0' : '') + number;
}