Skip to content

Instantly share code, notes, and snippets.

View Kcko's full-sized avatar
🦜
fly like a bird ...

Kcko

🦜
fly like a bird ...
View GitHub Profile
@Kcko
Kcko / Downlad file via iframe (no refresh page)
Last active August 29, 2015 13:56
Download via Iframe // wo refresh
<a href="" id="csv-export">export</a>
<iframe id="downloadIframe" src="" style="height: 0px; width: 0px; display: none;"></iframe>
<script>
$("#csv-export").click(function(e){
e.preventDefault();
oIFrm = document.getElementById('downloadIframe');
oIFrm.src = '' // URL to download file -- via php download headers;
});
</script>
@Kcko
Kcko / jquery-conditional-load
Created April 4, 2014 07:55
Jquery - conditional load
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.11.0.min.js" type="text/javascript"><\/script>')</script>
@Kcko
Kcko / ajax-done-fail
Created April 4, 2014 07:59
Ajax - with done || fail
$.ajax({ ... }).then(successHandler, failureHandler);
// OR
var jqxhr = $.ajax({ ... });
jqxhr.done(successHandler);
jqxhr.fail(failureHandler);
@Kcko
Kcko / Complete ajax
Created April 4, 2014 08:00
Complete ajax
var jqxhr = $.ajax({
url: url,
type: "GET", // default is GET but you can use other verbs based on your needs.
cache: true, // default is true, but false for dataType 'script' and 'jsonp', so set it on need basis.
data: {}, // add your request parameters in the data object.
dataType: "json", // specify the dataType for future reference
jsonp: "callback", // only specify this to match the name of callback parameter your API is expecting for JSONP requests.
statusCode: { // if you want to handle specific error codes, use the status code mapping settings.
404: handler404,
500: handler500
@Kcko
Kcko / jquery multiple on
Created April 4, 2014 08:02
jquery - multiple on
$("#myLink")
.addClass("bold")
.on("click", myClickHandler)
.on("mouseover", myMouseOverHandler)
.show();
@Kcko
Kcko / User RegExp
Last active August 29, 2015 14:00
Komplení regexp na username
$userRegExp = "#^[_A-Za-z0-9áäéëěíóöôúůüýčďňŕřšťžĺľÁÄÉËĚÍÓÖÔÚŮÜÝČĎŇŔŘŠŤŽĹĽ ]{3,40}\$#";
@Kcko
Kcko / convert-to-innodb
Created April 29, 2014 14:53
Convert tables to InnoDB
SET @DATABASE_NAME = 'test';
SELECT CONCAT('ALTER TABLE ', table_name, ' ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;
@Kcko
Kcko / Sticky navigation
Created May 3, 2014 11:06
Sticky navigation using jquery (sticky after viewport is overhead...)
$(document).ready(function () {
var aboveHeight = $('#topContainer').outerHeight();
$(window).scroll(function () {
if ($(window).scrollTop() > aboveHeight) {
$('#menu').addClass('fixed').css('top', '0').next()
.css('padding-top', '50px');
} else {
$('#menu').removeClass('fixed').next()
.css('padding-top', '0');
}
@Kcko
Kcko / Rem mixin.scss
Created May 15, 2014 07:37
Simple rem mixin
@mixin font-size($sizeValue: 1.6) {
font-size: ($sizeValue * 10) + px;
font-size: $sizeValue + rem;
}
@Kcko
Kcko / czech sorting.php
Last active August 29, 2015 14:01
czech sorting
<?php
setlocale(LC_ALL, 'cs_CZ.UTF-8');
header("content-type: text/html; charset=UTF-8");
$arr = explode(",", "č, d, b, a, š, ř, o, x, z, ž, á, s, m");
uasort($arr, "strcoll");
echo "<pre>" . print_r($arr, 1) . "</pre>";