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
znak kl.zkratka Alt+# HTML kód název
" ---------- Alt+34 " uvozovka/quote
# Ctrl+Alt+X Alt+35 mřížka/hash/sharp
$ Ctrl+Alt+ů Alt+36 dollar
& Ctrl+Alt+C Alt+38 & ampersand
' ---------- Alt+39 ' apostrof
* Ctrl+Alt+- Alt+42 hvězdička/asterisk
/ ---------- Alt+47 / lomítko/slash
: ---------- Alt+58 dvojtečka/colon
@Kcko
Kcko / js-fns-prototypes.js
Last active December 25, 2015 04:39
JavaScript: string fns prototypes
// stripslashes
String.prototype.stripslashes = function(){
return this.replace(/<.*?>/g, '');
};
String.prototype.htmlspecialchars = function(){
var str = this.replace(/&/g, '&amp;');
str = str.replace(/</g, '&lt;');
str = str.replace(/>/g, '&gt;');
str = str.replace(/"/g, '&quot;');
return str;
@Kcko
Kcko / zip-folder.php
Last active December 25, 2015 04:39
PHP: Zip folder
<?
class zipuj_helper
{
protected $jmeno_zipu;
protected $root;
protected $zip;
public function __construct($root = ".", $jmeno_zipu = "zip.zip")
{
$this->root = $root;
$this->jmeno_zipu = $jmeno_zipu;
@Kcko
Kcko / unzip-folder.php
Last active December 25, 2015 04:39
PHP: Unzip folder
<?
$extract_dir = "./sprites/";
$extract_file = "sprites.zip";
$zip = new ZipArchive;
$res = $zip->open($extract_file);
if ($res === TRUE) {
$zip->extractTo($extract_dir);
$zip->close();
echo "OK";
} else {
@Kcko
Kcko / readable-filesize.php
Last active December 25, 2015 04:39
PHP: Readable filesize
<?
function HumanReadableFilesize($size) {
// Adapted from: http://www.php.net/manual/en/function.filesize.php
$mod = 1024;
$units = explode(' ','B KB MB GB TB PB');
for ($i = 0; $size > $mod; $i++) {
$size /= $mod;
}
return round($size, 2) . ' ' . $units[$i];
@Kcko
Kcko / csv-export.php
Last active December 25, 2015 04:39
PHP: CSV export from MySql to output
<?
$out = '';
$fields = dibi::fetchAll("SHOW COLUMNS FROM web_application");
foreach ($fields as $field)
{
$out .= '"'.$field->Field.'";';
}
$out = rtrim($out, ';');
$out .= PHP_EOL;
foreach ($this->model->csvExport() as $index => $row)
@Kcko
Kcko / jquery plugin function expression v2
Last active June 22, 2018 13:59
Jquery - plugin, funkce, vl. selektor
1/
(function($){
$.extend({
jYoutube: function( url, size ){
if(url === null){ return ""; }
size = (size === null) ? "big" : size;
var vid;
var results;
results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
@Kcko
Kcko / gist:6941782
Last active December 25, 2015 07:49
JavaScript: only num in input
<input onkeypress="return !isNaN(String.fromCharCode(event.charCode || event.keyCode))">
@Kcko
Kcko / gist:7008505
Last active December 25, 2015 16:49
Jquery plugin - tiny - ukázkový
(function($) {
$.fn.extend({
check : function() {
return this.filter(":radio, :checkbox").attr("checked", true);
},
uncheck : function() {
return this.filter(":radio, :checkbox").removeAttr("checked");
}
});
}(jQuery));
@Kcko
Kcko / array of date range.php
Last active December 26, 2015 07:39
Date range - vygenerování datum. rozmezí
<?php
function dateRange( $first, $last, $step = '+1 day', $format = 'Y/m/d' ) {
$dates = array();
$current = strtotime( $first );
$last = strtotime( $last );
while( $current <= $last ) {