Skip to content

Instantly share code, notes, and snippets.

View mir4a's full-sized avatar
🤞

Myroslav mir4a

🤞
View GitHub Profile
@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 / check_ie.js
Last active March 20, 2016 21:09
Check IE version
//<editor-fold desc="Проверка версии IE">
function getInternetExplorerVersion()
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
@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;
}
@mir4a
mir4a / grid.css
Created April 5, 2013 13:29
Clear floating elements
/* `Clear Floated Elements
----------------------------------------------------------------------------------------------------*/
/* http://sonspring.com/journal/clearing-floats */
.clear {
clear: both;
display: block;
overflow: hidden;
visibility: hidden;
@mir4a
mir4a / style.less
Created April 9, 2013 11:01
Simple sticky footer with less
@footer_height: 100px;
body, html {
height: 100%;
}
.i-sticky {
min-height: 100%;
height: auto !important;
height: 100%;
<!DOCTYPE html>
<html>
<head>
<style>
html {
width: 100%;
height: 100%;
}
body {
@mir4a
mir4a / load.php
Created April 11, 2013 06:40
gettin access to hipchat api
<?php
$token = "ADMIN_TOKEN"; // replace with your admin token
$url = "https://api.hipchat.com/v1/users/list?auth_token=".$token; // this url gets all users and their attributes, for more info visit https://www.hipchat.com/docs/api/
$c = curl_init();
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); // required this for https access
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2); // this one too
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec($c); // return json data
@mir4a
mir4a / text_03.html
Last active December 16, 2015 14:49
regexp to format simple text to html tags in jetbrains
<!-- string to find -->
(^[а-яА-ЯёЁ a-zA-Z,. - -:;]+)
<!-- string to replace -->
<p>$1</p>