Skip to content

Instantly share code, notes, and snippets.

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

Roman Janko Kcko

🦜
fly like a bird ...
View GitHub Profile
@Kcko
Kcko / autosave.js
Created July 12, 2017 17:51 — forked from d3nj3ll/autosave.js
Client-side Autosave Using localStorage with jQuery in textarea
$(document).ready(function() {
///////////////////////
//
// Recovery Below
//
///////////////////////
// Retrieve the object from storage onReady
var autosave = localStorage.getItem('file');
@Kcko
Kcko / NetteCsvResponse.php
Created May 29, 2017 10:37 — forked from VladaHejda/NetteCsvResponse.php
Nette CSV response
<?php
namespace Nette\Application\Responses;
use Nette;
/**
* CSV download response.
* Under New BSD license.
*
@Kcko
Kcko / SCSS.md
Created April 6, 2017 19:39 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@Kcko
Kcko / jquery-pub-sub.md
Last active January 29, 2019 19:23 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.

This is now an actual repo:

https://github.com/cowboy/jquery-tiny-pubsub

This is the Original jQuery Tiny Pub/Sub plugin updated for jQuery 1.7 (which makes it EVEN SMALLER because bind and unbind are replaced with on and off)

Note: Ignore the first argument passed to your subscribed callbacks (the jQuery event object).

Another Note: Previous versions (v0.4+) were written in an attempt to remove the first argument and create a more future-proof API, but unfortunately this resulted in much less elegant, larger and slower code. The point of this plugin is to be TINY, to be used in situations where only size (not performance or usability) is the primary concern (tweets, code golf, etc).**

@Kcko
Kcko / flatten.php
Created February 26, 2017 09:27 — forked from kohnmd/flatten.php
Function to recursively flatten multidimensional PHP array.
<?php
// Requires PHP 5.3+
// Found here: http://stackoverflow.com/a/1320156
function flatten_array(array $array) {
$flattened_array = array();
array_walk_recursive($array, function($a) use (&$flattened_array) { $flattened_array[] = $a; });
return $flattened_array;
}
@Kcko
Kcko / gist:b02e1586ceb9c2af4d41c770fc4620d9
Created February 22, 2017 19:35 — forked from grandmanitou/gist:8863248
Place multiple markers with infowindow on Google Maps API v3, use external links to trigger click and center map on desired location.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?language=fra&amp;sensor=false"></script>
<script type="text/javascript">
var map;
var Markers = {};
var infowindow;
var locations = [
[
'Samsung Store Madeleine',
'<strong>Samsung Store Madeleine</strong><p>5 Boulevard Malesherbes, 75008 Paris<br>10h – 20h</p>',
48.8701925,
@Kcko
Kcko / gist:74c6cfb3e890e1fe5dbee17328a31c3d
Created October 7, 2016 21:25 — forked from liunian/gist:9338301
Human Readable File Size with PHP
<?php
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
echo human_filesize(filesize('example.zip'));
@Kcko
Kcko / curl_example.php
Created October 2, 2016 07:51 — forked from carbontwelve/curl_example.php
PHP Curl to check if url is alive
<?php
function check_alive($url, $timeout = 10, $successOn = array(200, 301)) {
$ch = curl_init($url);
// Set request options
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_NOBODY => true,
CURLOPT_TIMEOUT => $timeout,
<html>
<head>
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="map" style="height: 400px; width: 500px;">
</div>
<script type="text/javascript">
@Kcko
Kcko / paginator.latte
Created April 13, 2016 18:50 — forked from MichalKalita/paginator.latte
Vykreslení objektu Nette\Utils\Paginator, použití {include ../paginator.latte, paginator => $paginator}, kde $paginator máme předán z presenteru
{** Bootstrapové vykreslení paginatoru *}
{default $maxOdkazu = 15}
{default $postupnychStranek = 4}
{var $min = $paginator->getBase()}
{var $max = $paginator->getPageCount()}
{var $pocet = ($max - $min)}
{var $aktStrana = $paginator->getPage()}
{var $doplnkovychStran = $maxOdkazu - 2 - ($postupnychStranek*2) + 1}